Removed all trailing whitespace from .js and .html files

This commit is contained in:
Richard Worth 2008-11-18 02:55:25 +00:00
parent ce69e7ced4
commit 29f7dc9a2c
82 changed files with 1299 additions and 1299 deletions

View File

@ -3,22 +3,22 @@
<head> <head>
<title>jQuery UI - Functional demos</title> <title>jQuery UI - Functional demos</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="jquery,user interface,ui,widgets,interaction,javascript" /> <meta name="keywords" content="jquery,user interface,ui,widgets,interaction,javascript" />
<meta name="description" content="jQuery UI is jQuery's user interface library that comes with many widgets, interaction modules and themes." /> <meta name="description" content="jQuery UI is jQuery's user interface library that comes with many widgets, interaction modules and themes." />
<meta name="author" content="Paul Bakaus" /> <meta name="author" content="Paul Bakaus" />
<link rel="shortcut icon" href="images/favicon.ico" /> <link rel="shortcut icon" href="images/favicon.ico" />
<link rel="icon" href="images/favicon.ico" type="image/x-icon" /> <link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/base.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/base.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/functional_demos.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/functional_demos.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/chilli-recipes.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/chilli-recipes.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../themes/default/ui.all.css" type="text/css" media="screen" title="Flora (Default)" /> <link rel="stylesheet" href="../../themes/default/ui.all.css" type="text/css" media="screen" title="Flora (Default)" />
<script type="text/javascript" src="../../jquery-1.2.6.js"></script> <script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script> <script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.accordion.js"></script> <script type="text/javascript" src="../../ui/ui.accordion.js"></script>
<script type="text/javascript" src="../../ui/ui.datepicker.js"></script> <script type="text/javascript" src="../../ui/ui.datepicker.js"></script>
@ -82,7 +82,7 @@
<script type="text/javascript" src="../../ui/effects.shake.js"></script> <script type="text/javascript" src="../../ui/effects.shake.js"></script>
<script type="text/javascript" src="../../ui/effects.slide.js"></script> <script type="text/javascript" src="../../ui/effects.slide.js"></script>
<script type="text/javascript" src="../../ui/effects.transfer.js"></script> <script type="text/javascript" src="../../ui/effects.transfer.js"></script>
<script src="js/behaviour.js" type="text/javascript"></script> <script src="js/behaviour.js" type="text/javascript"></script>
<script src="js/behaviour.functionaldemos.js" type="text/javascript"></script> <script src="js/behaviour.functionaldemos.js" type="text/javascript"></script>
@ -111,7 +111,7 @@
<h1 class="logo"> <h1 class="logo">
<a href="http://ui.jquery.com/" title="jQuery User Interface"><span>jQuery User Interface</span></a> <a href="http://ui.jquery.com/" title="jQuery User Interface"><span>jQuery User Interface</span></a>
</h1> </h1>
<div id="dock"> <div id="dock">
<div class="left"></div> <div class="left"></div>
@ -204,7 +204,7 @@
<li><a href="#ui.resizable" title="Goto Resizable's Component Page">Resizable</a></li> <li><a href="#ui.resizable" title="Goto Resizable's Component Page">Resizable</a></li>
<li><a href="#ui.selectable" title="Goto Selectable's Component Page">Selectable</a></li> <li><a href="#ui.selectable" title="Goto Selectable's Component Page">Selectable</a></li>
<li><a href="#ui.sortable" title="Goto Sortable's Component Page">Sortable</a></li> <li><a href="#ui.sortable" title="Goto Sortable's Component Page">Sortable</a></li>
</ul> </ul>
</div> </div>
<br style="clear:both;"> <br style="clear:both;">
@ -245,7 +245,7 @@
</div> </div>
</td> </td>
<td class="normal"> <td class="normal">
<div class="normal" id="containerDemo"> <div class="normal" id="containerDemo">
<h3> <h3>
Instructions Instructions
@ -254,14 +254,14 @@
The functional demos are provided to give users an idea of how jQuery UI works. You only need to copy and paste code from the demos. Have fun playing with it. The functional demos are provided to give users an idea of how jQuery UI works. You only need to copy and paste code from the demos. Have fun playing with it.
</p> </p>
<div id="functional-demo-face" style="margin-left: 10px;"> <div id="functional-demo-face" style="margin-left: 10px;">
<img src="images/functional-demo-face.png"> <img src="images/functional-demo-face.png">
</div> </div>
<br> <br>
</div> </div>
</td> </td>
</tr> </tr>
@ -270,7 +270,7 @@
</form> </div> </form> </div>
</div> </div>
</div> </div>
<div id="footer"> <div id="footer">
<div class="bg"></div> <div class="bg"></div>

View File

@ -1,9 +1,9 @@
$(document).ready(function() { $(document).ready(function() {
$('.component-links a').history(function() { $('.component-links a').history(function() {
loadDemo( $(this).attr('href').replace(/^#/, "") ); loadDemo( $(this).attr('href').replace(/^#/, "") );
}); });
$.ajaxHistory.initialize(); $.ajaxHistory.initialize();
}); });

View File

@ -1,21 +1,21 @@
$(document).ready(function() { $(document).ready(function() {
// link demos // link demos
$(".demoflow div.wrapper").click(function() { $(".demoflow div.wrapper").click(function() {
var demo = $(this).children('img').attr('_demo'); var demo = $(this).children('img').attr('_demo');
if (demo) { if (demo) {
location.href = '/repository/real-world/' + demo; location.href = '/repository/real-world/' + demo;
}else { }else {
//alert('Under construction!'); //alert('Under construction!');
} }
}); });
if ($("div.demoflow").size()) { if ($("div.demoflow").size()) {
var inst = new $.ui.carousel($("div.demoflow")[0], { height: 200, width: 310 }); var inst = new $.ui.carousel($("div.demoflow")[0], { height: 200, width: 310 });
$("div.demoflow-button-left, div.demoflow-button-right").bind("mousedown", function() { $("div.demoflow-button-left, div.demoflow-button-right").bind("mousedown", function() {
@ -26,14 +26,14 @@ $(document).ready(function() {
.bind("mouseup", function() { .bind("mouseup", function() {
window.clearInterval(inst.timer); window.clearInterval(inst.timer);
}); });
$('.demoflow div.shadow').hover(function() { $('.demoflow div.shadow').hover(function() {
this._lastopacity = $(this).css('opacity'); this._lastopacity = $(this).css('opacity');
$(this).stop().animate({opacity: 0 }, 300); $(this).stop().animate({opacity: 0 }, 300);
}, function() { }, function() {
$(this).stop().animate({opacity: this._lastopacity }, 300); $(this).stop().animate({opacity: this._lastopacity }, 300);
}); });
window.setTimeout(function() { window.setTimeout(function() {
inst.element.animate({ opacity: 1 },2000); inst.rotate(0,2000,0.45); inst.element.animate({ opacity: 1 },2000); inst.rotate(0,2000,0.45);
@ -47,13 +47,13 @@ $(document).ready(function() {
$('a').click(function(){ $('a').click(function(){
this.blur(); this.blur();
}); });
// smooth hover effects by DragonInteractive // smooth hover effects by DragonInteractive
var hover = hoverEffects(); var hover = hoverEffects();
hover.init(); hover.init();
}); });
$.ui.carousel = function(element, options) { $.ui.carousel = function(element, options) {
this.element = $(element); this.element = $(element);
@ -68,41 +68,41 @@ $(document).ready(function() {
paddingX: this.element.outerWidth() / 2, paddingX: this.element.outerWidth() / 2,
paddingY: this.element.outerHeight() / 2 paddingY: this.element.outerHeight() / 2
}); });
$("> *", this.element).css({ position: "absolute", top: 0, left: 0, zIndex: 1 }); $("> *", this.element).css({ position: "absolute", top: 0, left: 0, zIndex: 1 });
this.rotate(); this.rotate();
this.rotate("right"); this.rotate("right");
this.element.parent().bind("mousewheel", function(event ,delta) { this.element.parent().bind("mousewheel", function(event ,delta) {
if(self.autoRotator) window.clearInterval(self.autoRotator); if(self.autoRotator) window.clearInterval(self.autoRotator);
self.rotate(delta < 0 ? "right" : "left"); self.rotate(delta < 0 ? "right" : "left");
return false; return false;
}); });
}; };
$.ui.carousel.prototype.rotate = function(d,ani,speed) { $.ui.carousel.prototype.rotate = function(d,ani,speed) {
this.start = this.start + (d == "right" ? -(speed || 0.03) : (speed || 0.03)); this.start = this.start + (d == "right" ? -(speed || 0.03) : (speed || 0.03));
var o = this.options; var o = this.options;
var self = this; var self = this;
setTimeout(function(){ setTimeout(function(){
$("> *", self.element).each(function(i) { $("> *", self.element).each(function(i) {
var angle = self.start + i * self.step; var angle = self.start + i * self.step;
var x = self.radiusX * Math.cos(angle); var x = self.radiusX * Math.cos(angle);
var y = self.radiusY * Math.sin(angle); var y = self.radiusY * Math.sin(angle);
var _self = this; var _self = this;
var width = o.width * ((self.radiusY+y) / (2 * self.radiusY)); var width = o.width * ((self.radiusY+y) / (2 * self.radiusY));
width = (width * width * width) / (o.width * o.width); //This makes the pieces smaller width = (width * width * width) / (o.width * o.width); //This makes the pieces smaller
var height = parseInt(width * o.height / o.width); var height = parseInt(width * o.height / o.width);
//This is highly custom - it will hide the elements at the back //This is highly custom - it will hide the elements at the back
$(_self).css({ visibility: height < 30 ? "hidden" : "visible" }); $(_self).css({ visibility: height < 30 ? "hidden" : "visible" });
if(height < 30 && !ani) return; //This imrpoves the speed, but cannot be used with animation if(height < 30 && !ani) return; //This imrpoves the speed, but cannot be used with animation
if(ani) { if(ani) {
$(_self).animate({ $(_self).animate({
top: Math.round(self.paddingY + y - height/2) + "px", top: Math.round(self.paddingY + y - height/2) + "px",
@ -122,7 +122,7 @@ $(document).ready(function() {
} }
$("div.shadow",_self).css({ opacity: 1 - (width / o.width) }); $("div.shadow",_self).css({ opacity: 1 - (width / o.width) });
}); });
}, 0); }, 0);
} }
@ -200,6 +200,6 @@ var hoverEffects = function() {
}) })
} }
}; };
return self; return self;
}; };

View File

@ -6,38 +6,38 @@ var uid = 0;
* @param {Object} model * @param {Object} model
*/ */
var uiRenderDemo = function(model) { var uiRenderDemo = function(model) {
var title = model.title, renderAt = $(model.renderAt); var title = model.title, renderAt = $(model.renderAt);
function nl2br( str ) { function nl2br( str ) {
return str.replace(/([^>])\n/g, '$1<br />\n'); return str.replace(/([^>])\n/g, '$1<br />\n');
} }
var js2html = function(code) { var js2html = function(code) {
var src = (js_beautify(code) || ""); var src = (js_beautify(code) || "");
//if ($.browser.msie) //if ($.browser.msie)
// src = src.replace(/([^>])\n/g, '$1<br />\n'); // src = src.replace(/([^>])\n/g, '$1<br />\n');
return src; return src;
}; };
renderAt.append( renderAt.append(
'<h3>'+ title +'</h3>' '<h3>'+ title +'</h3>'
); );
$.each(model.demos, function(i, demo) { $.each(model.demos, function(i, demo) {
/** /**
* Rendering each demo * Rendering each demo
*/ */
if (!demo) return; if (!demo) return;
var uiHtmlRendered = $('<div class="ui-html-rendered"></div>'); var uiHtmlRendered = $('<div class="ui-html-rendered"></div>');
if (model.onRenderStart) model.onRenderStart.apply(window); if (model.onRenderStart) model.onRenderStart.apply(window);
var gid = 'ui-gen-'+uid++, demoBox = $('<div id="'+gid+'"></div>'); var gid = 'ui-gen-'+uid++, demoBox = $('<div id="'+gid+'"></div>');
renderAt.append(demoBox); renderAt.append(demoBox);
@ -45,15 +45,15 @@ var uiRenderDemo = function(model) {
var detailsHtml = $( var detailsHtml = $(
'<br><div class="ui-details"><div class="menutitle">'+demo.title+'</div></div>' '<br><div class="ui-details"><div class="menutitle">'+demo.title+'</div></div>'
); );
var descBox = $( var descBox = $(
'<div class="ui-demo-description">'+(demo.desc||'')+'</div>' '<div class="ui-demo-description">'+(demo.desc||'')+'</div>'
); );
var optionsBox = $( var optionsBox = $(
'<div class="ui-demo-options"><label for="select-'+gid+'">Try more options on the fly: </label></div>' '<div class="ui-demo-options"><label for="select-'+gid+'">Try more options on the fly: </label></div>'
); );
var codesBox = $( var codesBox = $(
'<div id="code-'+gid+'"></div>' '<div id="code-'+gid+'"></div>'
) )
@ -62,19 +62,19 @@ var uiRenderDemo = function(model) {
var sourceTmpl = $( var sourceTmpl = $(
'<div></div>' '<div></div>'
); );
var preTmpl = $( var preTmpl = $(
'<span style="white-space: pre;"></span>' '<span style="white-space: pre;"></span>'
); );
var codeTmpl = $( var codeTmpl = $(
'<code></code>' '<code></code>'
); );
var htmlCode = '', sourceHtml = sourceTmpl.clone(), sourceJs = sourceTmpl.clone(), entitiesHtml = function(html) { var htmlCode = '', sourceHtml = sourceTmpl.clone(), sourceJs = sourceTmpl.clone(), entitiesHtml = function(html) {
return html.replace(/</g,"&lt;").replace(/>/g,"&gt;"); return html.replace(/</g,"&lt;").replace(/>/g,"&gt;");
}; };
// Render simple HTML // Render simple HTML
if (typeof demo.html == 'string') { if (typeof demo.html == 'string') {
uiHtmlRendered.html(demo.html); uiHtmlRendered.html(demo.html);
@ -82,9 +82,9 @@ var uiRenderDemo = function(model) {
} }
// Render data html by URL // Render data html by URL
if (typeof demo.html == 'object' && demo.html.url) { if (typeof demo.html == 'object' && demo.html.url) {
uiHtmlRendered.html("<img src='/images/ajax-loader.gif'>"); uiHtmlRendered.html("<img src='/images/ajax-loader.gif'>");
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: demo.html.url, url: demo.html.url,
@ -92,26 +92,26 @@ var uiRenderDemo = function(model) {
success: function(data) { success: function(data) {
uiHtmlRendered.html(data); uiHtmlRendered.html(data);
htmlCode = data; htmlCode = data;
// set html code view // set html code view
sourceHtml.html(preTmpl.clone().html( codeTmpl.clone().addClass('colored html').html(entitiesHtml(htmlCode)) )); sourceHtml.html(preTmpl.clone().html( codeTmpl.clone().addClass('colored html').html(entitiesHtml(htmlCode)) ));
$.each(demo.options, function(x, o) { $.each(demo.options, function(x, o) {
// eval the first source of <select> // eval the first source of <select>
if (!x) jQuery.globalEval(o.source); if (!x) jQuery.globalEval(o.source);
}); });
$('#'+gid).find('.colored.html').chili(); $('#'+gid).find('.colored.html').chili();
// fire renderEnd callback to ajax async transactions // fire renderEnd callback to ajax async transactions
if (model.onRenderEnd) model.onRenderEnd.apply(window); if (model.onRenderEnd) model.onRenderEnd.apply(window);
} }
}); });
} }
// set html code view // set html code view
sourceHtml.html(preTmpl.clone().html( codeTmpl.clone().addClass('colored html').html(entitiesHtml(htmlCode)) )); sourceHtml.html(preTmpl.clone().html( codeTmpl.clone().addClass('colored html').html(entitiesHtml(htmlCode)) ));
var select = $('<select id="select-'+ gid+'"></select>').change(function() { var select = $('<select id="select-'+ gid+'"></select>').change(function() {
var ecode = decodeURIComponent($(this).val()); var ecode = decodeURIComponent($(this).val());
@ -137,7 +137,7 @@ var uiRenderDemo = function(model) {
select, a, '<br>', codesBox.append('<br>JavaScript:<br>', sourceJs, '<br>HTML:<br>', sourceHtml) select, a, '<br>', codesBox.append('<br>JavaScript:<br>', sourceJs, '<br>HTML:<br>', sourceHtml)
) )
); );
// population select with the demo options // population select with the demo options
$.each(demo.options, function(x, o) { $.each(demo.options, function(x, o) {
if (o && o.desc) { if (o && o.desc) {
@ -150,28 +150,28 @@ var uiRenderDemo = function(model) {
} }
} }
}); });
$('#'+gid).find('.colored.javascript').chili(); $('#'+gid).find('.colored.javascript').chili();
$('#'+gid).find('.colored.html').chili(); $('#'+gid).find('.colored.html').chili();
// fire renderEnd callback to direct-html-render // fire renderEnd callback to direct-html-render
if (typeof demo.html != 'object' && model.onRenderEnd) model.onRenderEnd.apply(window); if (typeof demo.html != 'object' && model.onRenderEnd) model.onRenderEnd.apply(window);
}); });
}; };
var loadDemo = function(comp) { var loadDemo = function(comp) {
$("#dialog").dialog().remove(); $("#dialog").dialog().remove();
$('#containerDemo').html("<img src='images/ajax-loader.gif'>"); $('#containerDemo').html("<img src='images/ajax-loader.gif'>");
$("#containerDemo").ajaxError(function(request, settings){ $("#containerDemo").ajaxError(function(request, settings){
$(this).html("Oops, there is no template file for this component."); $(this).html("Oops, there is no template file for this component.");
}); });
$.get('templates/'+comp+'.html', function(data) { $.get('templates/'+comp+'.html', function(data) {
$('#containerDemo').html(data); $('#containerDemo').html(data);
}); });
}; };

View File

@ -1,11 +1,11 @@
<script type="text/javascript"> <script type="text/javascript">
var model = { var model = {
renderAt: '#containerDemo', renderAt: '#containerDemo',
title: 'Dialog Demos', title: 'Dialog Demos',
demos: [ demos: [
{ {

View File

@ -11,7 +11,7 @@
<img src="templates/images/P1010044.JPG" alt="Tatry 4" title="Drag me!" /> <img src="templates/images/P1010044.JPG" alt="Tatry 4" title="Drag me!" />
</li> </li>
</ul> </ul>
<div class="droppable-photos-container" style="text-align: center;">Drop here!</div> <div class="droppable-photos-container" style="text-align: center;">Drop here!</div>
</div> </div>

View File

@ -95,7 +95,7 @@
{ desc: 'Bounce ease in out', source: '$("#area").click(function(event) { moveToHere(event, "easeInOutBounce"); });' }, { desc: 'Bounce ease in out', source: '$("#area").click(function(event) { moveToHere(event, "easeInOutBounce"); });' },
] ]
} }
] ]
}; };

View File

@ -75,7 +75,7 @@
{ desc: 'Scale from bottom-right', source: '$("#doScale").click(function() { $("#scale").effect("scale", {origin: ["bottom", "right"], percent: 50}, 800); });' } { desc: 'Scale from bottom-right', source: '$("#doScale").click(function() { $("#scale").effect("scale", {origin: ["bottom", "right"], percent: 50}, 800); });' }
] ]
}, },
{ {
title: 'Size', title: 'Size',
desc: 'Changes the size of an element by specifying a width and height.', desc: 'Changes the size of an element by specifying a width and height.',
@ -126,7 +126,7 @@
{ desc: 'Transfer with extra class', source: '$("#doTransfer").click(function() { $("#transfer").effect("transfer", {to: "#target", className: "transferring"}, 800); });' } { desc: 'Transfer with extra class', source: '$("#doTransfer").click(function() { $("#transfer").effect("transfer", {to: "#target", className: "transferring"}, 800); });' }
] ]
} }
] ]
}; };

View File

@ -1,11 +1,11 @@
<script type="text/javascript"> <script type="text/javascript">
var model = { var model = {
renderAt: '#containerDemo', renderAt: '#containerDemo',
title: 'Progressbar Demos', title: 'Progressbar Demos',
demos: [ demos: [
{ {

View File

@ -1,11 +1,11 @@
<script type="text/javascript"> <script type="text/javascript">
var model = { var model = {
renderAt: '#containerDemo', renderAt: '#containerDemo',
title: 'Slider Demos', title: 'Slider Demos',
demos: [ demos: [
{ {
@ -20,7 +20,7 @@
} }
] ]
}, },
{ {
title: 'Multiple slides', title: 'Multiple slides',
desc: 'You can also have multiples slides.', desc: 'You can also have multiples slides.',

View File

@ -1,16 +1,16 @@
<div class="sortable-container"> <div class="sortable-container">
<div id="example1"> <div id="example1">
<button onclick="$('#selectedUsers').sortable('enable')" type="button">Enable</button> <button onclick="$('#selectedUsers').sortable('enable')" type="button">Enable</button>
<button onclick="$('#selectedUsers').sortable('disable')" type="button">Disable</button> <button onclick="$('#selectedUsers').sortable('disable')" type="button">Disable</button>
<button onclick="alert($('#selectedUsers').sortable('serialize'))" type="button">Serialize!</button> <button onclick="alert($('#selectedUsers').sortable('serialize'))" type="button">Serialize!</button>
<button onclick="alert($('#selectedUsers').sortable('toArray'))" type="button">ID's to Array!</button> <button onclick="alert($('#selectedUsers').sortable('toArray'))" type="button">ID's to Array!</button>
<br><br> <br><br>
<div id="sortable-ex" style="min-height: 110px; min-height:110px; height: auto !important;"> <div id="sortable-ex" style="min-height: 110px; min-height:110px; height: auto !important;">
<div style="float: left;"> <div style="float: left;">
Selected users Selected users
<ul id="selectedUsers" style="cursor: hand; cursor: pointer;"> <ul id="selectedUsers" style="cursor: hand; cursor: pointer;">
@ -21,7 +21,7 @@
<li id='user_Kate'>Kate</li> <li id='user_Kate'>Kate</li>
</ul> </ul>
</div> </div>
<div style="float: left; margin-left: 50px;"> <div style="float: left; margin-left: 50px;">
User list User list
<ul id="userList" style="cursor: hand; cursor: pointer;"> <ul id="userList" style="cursor: hand; cursor: pointer;">
@ -32,9 +32,9 @@
<li id='user_Daniel'>Daniel</li> <li id='user_Daniel'>Daniel</li>
</ul> </ul>
</div> </div>
<br style="clear: both;"> <br style="clear: both;">
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="sortable-container"> <div class="sortable-container">
<div id="example3"> <div id="example3">
<div style="min-height: 50px; min-height:50px; height:auto !important;"> <div style="min-height: 50px; min-height:50px; height:auto !important;">
<style type="text/css" media="screen"> <style type="text/css" media="screen">
#placeholderSortable li { #placeholderSortable li {
@ -15,9 +15,9 @@
<li id='user_Claire'>Claire</li> <li id='user_Claire'>Claire</li>
<li id='user_Daniel'>Daniel</li> <li id='user_Daniel'>Daniel</li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,21 +1,21 @@
<script type="text/javascript"> <script type="text/javascript">
var model = { var model = {
onRenderEnd: function() { onRenderEnd: function() {
$.ui.disableSelection($('#sortable-ex').get(0)); $.ui.disableSelection($('#sortable-ex').get(0));
}, },
renderAt: '#containerDemo', renderAt: '#containerDemo',
title: 'Sortable Demos', title: 'Sortable Demos',
demos: [ demos: [
{ {
title: 'Sortable', title: 'Sortable',
desc: 'With few lines of code you could have sortable elements. You can try more options on the fly!', desc: 'With few lines of code you could have sortable elements. You can try more options on the fly!',
html: { url: 'templates/ui.sortable.ex1.html' }, html: { url: 'templates/ui.sortable.ex1.html' },

View File

@ -1,11 +1,11 @@
<script type="text/javascript"> <script type="text/javascript">
var model = { var model = {
renderAt: '#containerDemo', renderAt: '#containerDemo',
title: 'Spinner Demos', title: 'Spinner Demos',
demos: [ demos: [
{ {

View File

@ -1,13 +1,13 @@
<div id="tabsEx1"> <div id="tabsEx1">
<input type="button" onclick="$('#tabsEx1 > ul').tabs('add', '#appended-tab', 'New Tab');" value="Add new tab"> <input type="button" onclick="$('#tabsEx1 > ul').tabs('add', '#appended-tab', 'New Tab');" value="Add new tab">
<input type="button" onclick="$('#tabsEx1 > ul').tabs('add', '#inserted-tab', 'New Tab', 1);" value="Insert tab"> <input type="button" onclick="$('#tabsEx1 > ul').tabs('add', '#inserted-tab', 'New Tab', 1);" value="Insert tab">
<input type="button" onclick="$('#tabsEx1 > ul').tabs('disable', 1);" value="Disable tab 2"> <input type="button" onclick="$('#tabsEx1 > ul').tabs('disable', 1);" value="Disable tab 2">
<input type="button" onclick="$('#tabsEx1 > ul').tabs('enable', 1);" value="Enable tab 2"> <input type="button" onclick="$('#tabsEx1 > ul').tabs('enable', 1);" value="Enable tab 2">
<input type="button" onclick="$('#tabsEx1 > ul').tabs('select', 2);" value="Select tab 3"> <input type="button" onclick="$('#tabsEx1 > ul').tabs('select', 2);" value="Select tab 3">
<br><br> <br><br>
<ul style="height: 30px;"> <ul style="height: 30px;">
<li><a href="#fragment-1"><span>One</span></a></li> <li><a href="#fragment-1"><span>One</span></a></li>
<li><a href="#fragment-2"><span>Two</span></a></li> <li><a href="#fragment-2"><span>Two</span></a></li>

View File

@ -1,5 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$("div.effect") $("div.effect")
.hover(function() { .hover(function() {
$(this).addClass("hover"); $(this).addClass("hover");
@ -7,16 +7,16 @@ $(document).ready(function() {
$(this).removeClass("hover"); $(this).removeClass("hover");
}) })
; ;
var effect = function(el, n, o) { var effect = function(el, n, o) {
$.extend(o, { $.extend(o, {
easing: "easeOutQuint" easing: "easeOutQuint"
}); });
$(el).bind("click", function() { $(el).bind("click", function() {
$(this).addClass("current").hide(n, o, 1000, function() { $(this).addClass("current").hide(n, o, 1000, function() {
var self = this; var self = this;
window.setTimeout(function() { window.setTimeout(function() {
@ -24,42 +24,42 @@ $(document).ready(function() {
},500); },500);
}); });
}); });
}; };
effect("#blindHorizontally", "blind", { direction: "horizontal" }); effect("#blindHorizontally", "blind", { direction: "horizontal" });
effect("#blindVertically", "blind", { direction: "vertical" }); effect("#blindVertically", "blind", { direction: "vertical" });
effect("#bounce3times", "bounce", { times: 3 }); effect("#bounce3times", "bounce", { times: 3 });
effect("#clipHorizontally", "clip", { direction: "horizontal" }); effect("#clipHorizontally", "clip", { direction: "horizontal" });
effect("#clipVertically", "clip", { direction: "vertical" }); effect("#clipVertically", "clip", { direction: "vertical" });
effect("#dropDown", "drop", { direction: "down" }); effect("#dropDown", "drop", { direction: "down" });
effect("#dropUp", "drop", { direction: "up" }); effect("#dropUp", "drop", { direction: "up" });
effect("#dropLeft", "drop", { direction: "left" }); effect("#dropLeft", "drop", { direction: "left" });
effect("#dropRight", "drop", { direction: "right" }); effect("#dropRight", "drop", { direction: "right" });
effect("#explode9", "explode", { }); effect("#explode9", "explode", { });
effect("#explode36", "explode", { pieces: 36 }); effect("#explode36", "explode", { pieces: 36 });
effect("#fold", "fold", { size: 50 }); effect("#fold", "fold", { size: 50 });
effect("#highlight", "highlight", { }); effect("#highlight", "highlight", { });
effect("#pulsate", "pulsate", { times: 2 }); effect("#pulsate", "pulsate", { times: 2 });
effect("#puff", "puff", { times: 2 }); effect("#puff", "puff", { times: 2 });
effect("#scale", "scale", { }); effect("#scale", "scale", { });
$("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); }); $("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); });
effect("#slideDown", "slide", { direction: "down" }); effect("#slideDown", "slide", { direction: "down" });
effect("#slideUp", "slide", { direction: "up" }); effect("#slideUp", "slide", { direction: "up" });
effect("#slideLeft", "slide", { direction: "left" }); effect("#slideLeft", "slide", { direction: "left" });
effect("#slideRight", "slide", { direction: "right" }); effect("#slideRight", "slide", { direction: "right" });
$("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); }); $("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); });
}); });

View File

@ -4,10 +4,10 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Effects Test Suite</title> <title>Effects Test Suite</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<script type="text/javascript" src="../../../jquery-1.2.6.js"></script> <script type="text/javascript" src="../../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../ui/effects.core.js"></script> <script type="text/javascript" src="../../../ui/effects.core.js"></script>
<script type="text/javascript" src="../../../ui/effects.blind.js"></script> <script type="text/javascript" src="../../../ui/effects.blind.js"></script>
<script type="text/javascript" src="../../../ui/effects.bounce.js"></script> <script type="text/javascript" src="../../../ui/effects.bounce.js"></script>
<script type="text/javascript" src="../../../ui/effects.clip.js"></script> <script type="text/javascript" src="../../../ui/effects.clip.js"></script>
@ -20,7 +20,7 @@
<script type="text/javascript" src="../../../ui/effects.shake.js"></script> <script type="text/javascript" src="../../../ui/effects.shake.js"></script>
<script type="text/javascript" src="../../../ui/effects.slide.js"></script> <script type="text/javascript" src="../../../ui/effects.slide.js"></script>
<script type="text/javascript" src="../../../ui/effects.transfer.js"></script> <script type="text/javascript" src="../../../ui/effects.transfer.js"></script>
<script type="text/javascript" src="demo.js"></script> <script type="text/javascript" src="demo.js"></script>
</head> </head>
<body> <body>
@ -38,121 +38,121 @@
<p>Blind vertically</p> <p>Blind vertically</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="bounce3times"> <div class="effect" id="bounce3times">
<p>Bounce 3 times</p> <p>Bounce 3 times</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="clipHorizontally"> <div class="effect" id="clipHorizontally">
<p>Clip horizontally</p> <p>Clip horizontally</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="clipVertically"> <div class="effect" id="clipVertically">
<p>Clip vertically</p> <p>Clip vertically</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropDown"> <div class="effect" id="dropDown">
<p>Drop down</p> <p>Drop down</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropUp"> <div class="effect" id="dropUp">
<p>Drop up</p> <p>Drop up</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropLeft"> <div class="effect" id="dropLeft">
<p>Drop left</p> <p>Drop left</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropRight"> <div class="effect" id="dropRight">
<p>Drop right</p> <p>Drop right</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="explode9"> <div class="effect" id="explode9">
<p>Explode in 9 pieces</p> <p>Explode in 9 pieces</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="explode36"> <div class="effect" id="explode36">
<p>Explode in 36 pieces</p> <p>Explode in 36 pieces</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="fold"> <div class="effect" id="fold">
<p>Fold</p> <p>Fold</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="highlight"> <div class="effect" id="highlight">
<p>Highlight</p> <p>Highlight</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="pulsate"> <div class="effect" id="pulsate">
<p>Pulsate 2 times</p> <p>Pulsate 2 times</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="puff"> <div class="effect" id="puff">
<p>Puff</p> <p>Puff</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="scale"> <div class="effect" id="scale">
<p>Scale</p> <p>Scale</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="shake"> <div class="effect" id="shake">
<p>Shake</p> <p>Shake</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideDown"> <div class="effect" id="slideDown">
<p>Slide down</p> <p>Slide down</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideUp"> <div class="effect" id="slideUp">
<p>Slide up</p> <p>Slide up</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideLeft"> <div class="effect" id="slideLeft">
<p>Slide left</p> <p>Slide left</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideRight"> <div class="effect" id="slideRight">
<p>Slide right</p> <p>Slide right</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="transfer"> <div class="effect" id="transfer">
<p>Transfer to first element</p> <p>Transfer to first element</p>

View File

@ -9,7 +9,7 @@
<script type="text/javascript" src="../../../ui/ui.core.js"></script> <script type="text/javascript" src="../../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../../ui/ui.resizable.js"></script> <script type="text/javascript" src="../../../ui/ui.resizable.js"></script>
<script type="text/javascript" src="../../../ui/ui.draggable.js"></script> <script type="text/javascript" src="../../../ui/ui.draggable.js"></script>
<script type="text/javascript" src="../../../ui/effects.core.js"></script> <script type="text/javascript" src="../../../ui/effects.core.js"></script>
<script type="text/javascript" src="../../../ui/effects.bounce.js"></script> <script type="text/javascript" src="../../../ui/effects.bounce.js"></script>
<script type="text/javascript" src="../../../ui/effects.scale.js"></script> <script type="text/javascript" src="../../../ui/effects.scale.js"></script>
@ -112,7 +112,7 @@
//animate:true, //animate:true,
handles: 'all', handles: 'all',
knobHandles: true, knobHandles: true,
//transparent: true, //transparent: true,
@ -127,9 +127,9 @@
resize: function(event, ui) { resize: function(event, ui) {
var self = $(this).data("resizable"); var self = $(this).data("resizable");
this.style.backgroundPosition = '-' + (self.position.left) + 'px -' + (self.position.top) + 'px'; this.style.backgroundPosition = '-' + (self.position.left) + 'px -' + (self.position.top) + 'px';
$("#log-top").html(self.position.top+"px"); $("#log-top").html(self.position.top+"px");
$("#log-left").html(self.position.left+"px"); $("#log-left").html(self.position.left+"px");

View File

@ -6,28 +6,28 @@
.filter(':first').addClass('first').find('.up').addClass('disabled').end().end() .filter(':first').addClass('first').find('.up').addClass('disabled').end().end()
.filter(':last').addClass('last').find('.down').addClass('disabled').end().end(); .filter(':last').addClass('last').find('.down').addClass('disabled').end().end();
}; };
function moveUpDown() { function moveUpDown() {
var link = $(this), var link = $(this),
dl = link.parents('dl'), dl = link.parents('dl'),
prev = dl.prev('dl'), prev = dl.prev('dl'),
next = dl.next('dl'); next = dl.next('dl');
if(link.is('.up') && prev.length > 0) if(link.is('.up') && prev.length > 0)
dl.insertBefore(prev); dl.insertBefore(prev);
if(link.is('.down') && next.length > 0) if(link.is('.down') && next.length > 0)
dl.insertAfter(next); dl.insertAfter(next);
updateUpDown(dl.parent()); updateUpDown(dl.parent());
}; };
function addControls() { function addControls() {
$(this).append('<span class="options"><a class="up">up</a><a class="down">down</a></span>') $(this).append('<span class="options"><a class="up">up</a><a class="down">down</a></span>')
.find('a.up, a.down').bind('click', moveUpDown); .find('a.up, a.down').bind('click', moveUpDown);
updateUpDown($(this).parents(".ui-sortable:first")); updateUpDown($(this).parents(".ui-sortable:first"));
} }
var counter = 1; var counter = 1;
function addItem() { function addItem() {
var sortable = $(this).parents('.ui-sortable:first'); var sortable = $(this).parents('.ui-sortable:first');
@ -38,11 +38,11 @@
sortable.append(html).sortable('refresh').find('a.up, a.down').bind('click', moveUpDown); sortable.append(html).sortable('refresh').find('a.up, a.down').bind('click', moveUpDown);
updateUpDown(sortable); updateUpDown(sortable);
}; };
function emptyTrashCan(item) { function emptyTrashCan(item) {
item.remove(); item.remove();
}; };
function sortableChange(event, ui) { function sortableChange(event, ui) {
if(ui.sender){ if(ui.sender){
var w = ui.element.width(); var w = ui.element.width();
@ -50,7 +50,7 @@
ui.helper.css("width",ui.element.children().width()); ui.helper.css("width",ui.element.children().width());
} }
}; };
function sortableUpdate(event, ui) { function sortableUpdate(event, ui) {
if(ui.element[0].id == 'trashcan'){ if(ui.element[0].id == 'trashcan'){
emptyTrashCan(ui.item); emptyTrashCan(ui.item);
@ -60,22 +60,22 @@
updateUpDown(ui.sender[0]); updateUpDown(ui.sender[0]);
} }
}; };
$(document).ready(function(){ $(document).ready(function(){
var els = ['#header', '#content', '#sidebar', '#footer', '#trashcan']; var els = ['#header', '#content', '#sidebar', '#footer', '#trashcan'];
var $els = $(els.toString()); var $els = $(els.toString());
$('h2', $els.slice(0,-1)).append('<span class="options"><a class="add">add</a></span>'); $('h2', $els.slice(0,-1)).append('<span class="options"><a class="add">add</a></span>');
$('dt', $els).each(addControls); $('dt', $els).each(addControls);
//$('dt', $els).append('<span class="options"><a class="up">up</a><a class="down">down</a></span>'); //$('dt', $els).append('<span class="options"><a class="up">up</a><a class="down">down</a></span>');
$('a.add').bind('click', addItem); $('a.add').bind('click', addItem);
//$('a.up, a.down').bind('click', moveUpDown); //$('a.up, a.down').bind('click', moveUpDown);
$els.each(function(){ $els.each(function(){
updateUpDown(this); updateUpDown(this);
}); });
$els.sortable({ $els.sortable({
items: '> dl', items: '> dl',
handle: 'dt', handle: 'dt',
@ -101,7 +101,7 @@
handle: 'dt' handle: 'dt'
}) })
}); });
$(window).bind('load',function(){ $(window).bind('load',function(){
setTimeout(function(){ setTimeout(function(){
// fixes the weird scrolling in IE while killing the fade // fixes the weird scrolling in IE while killing the fade

View File

@ -3,27 +3,27 @@
<head> <head>
<title>UI Sortable: Layout Demo</title> <title>UI Sortable: Layout Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="title" content="UI Sortable: Layout Demo" /> <meta name="title" content="UI Sortable: Layout Demo" />
<meta name="description" content="A sortable layout created with the jQuery UI suite" /> <meta name="description" content="A sortable layout created with the jQuery UI suite" />
<meta name="author" content="Joan Piedra" /> <meta name="author" content="Joan Piedra" />
<meta name="author-url" content="http://www.joanpiedra.com/" /> <meta name="author-url" content="http://www.joanpiedra.com/" />
<meta name="author-url" content="http://www.justaquit.com/" /> <meta name="author-url" content="http://www.justaquit.com/" />
<meta name="author-url" content="http://jquery.com/" /> <meta name="author-url" content="http://jquery.com/" />
<link rel="shortcut icon" href="http://jquery.com/favicon.ico" /> <link rel="shortcut icon" href="http://jquery.com/favicon.ico" />
<link rel="icon" href="http://jquery.com/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://jquery.com/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="demo.css" type="text/css" media="screen" /> <link rel="stylesheet" href="demo.css" type="text/css" media="screen" />
<!--[if IE]> <!--[if IE]>
<link rel="stylesheet" href="demo-ie.css" type="text/css" media="screen" /> <link rel="stylesheet" href="demo-ie.css" type="text/css" media="screen" />
<![endif]--> <![endif]-->
</head> </head>
<body id="uidemo"> <body id="uidemo">
<h1>UI Sortable: <em>Layout demo</em></h1> <h1>UI Sortable: <em>Layout demo</em></h1>
<div id="container"> <div id="container">
<div id="header" class="ui-sortable"> <div id="header" class="ui-sortable">
<h2>Header</h2> <h2>Header</h2>
@ -32,7 +32,7 @@
<dd>Main Navigation</dd> <dd>Main Navigation</dd>
</dl> </dl>
</div> </div>
<div id="content" class="ui-sortable"> <div id="content" class="ui-sortable">
<h2>Content</h2> <h2>Content</h2>
<dl class="sort"> <dl class="sort">
@ -40,7 +40,7 @@
<dd>Main blog post</dd> <dd>Main blog post</dd>
</dl> </dl>
</div> </div>
<div id="sidebar" class="ui-sortable"> <div id="sidebar" class="ui-sortable">
<h2>Sidebar</h2> <h2>Sidebar</h2>
<dl class="sort"> <dl class="sort">
@ -56,9 +56,9 @@
<dd>Random Links</dd> <dd>Random Links</dd>
</dl> </dl>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<div id="footer" class="ui-sortable"> <div id="footer" class="ui-sortable">
<h2>Footer</h2> <h2>Footer</h2>
<dl class="sort"> <dl class="sort">
@ -67,7 +67,7 @@
</dl> </dl>
</div> </div>
</div> </div>
<div id="meta"> <div id="meta">
<div id="components" class="ui-sortable"> <div id="components" class="ui-sortable">
<h2>Components</h2> <h2>Components</h2>
@ -81,20 +81,20 @@
<dd>Caption</dd> <dd>Caption</dd>
</dl> </dl>
</div> </div>
<div id="trashcan" class="ui-sortable"> <div id="trashcan" class="ui-sortable">
<h2>Trash can</h2> <h2>Trash can</h2>
<p>Drag modules here to delete them.</p> <p>Drag modules here to delete them.</p>
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<div id="overlay"> <div id="overlay">
<div id="preloader"><img src="loader.gif" alt="" /></div> <div id="preloader"><img src="loader.gif" alt="" /></div>
</div> </div>
<script type="text/javascript" src="../../../jquery-1.2.6.js"></script> <script type="text/javascript" src="../../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../ui/ui.core.js"></script> <script type="text/javascript" src="../../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../../ui/ui.draggable.js"></script> <script type="text/javascript" src="../../../ui/ui.draggable.js"></script>
<script type="text/javascript" src="../../../ui/ui.droppable.js"></script> <script type="text/javascript" src="../../../ui/ui.droppable.js"></script>

View File

@ -125,8 +125,8 @@
<div style="margin: 5px; padding: 5px;min-height:20px" class="ui-slider-2 ui-slider" id="sliderSize"> <div style="margin: 5px; padding: 5px;min-height:20px" class="ui-slider-2 ui-slider" id="sliderSize">
<a style="cursor: default;" href="javascript:void(0)"> <a style="cursor: default;" href="javascript:void(0)">
<div class="ui-slider-handle" style="left: 150px;min-height:20px"></div> <div class="ui-slider-handle" style="left: 150px;min-height:20px"></div>
</a> </a>
</div> </div>
</div> </div>
<div class="box" id="trash"> <div class="box" id="trash">
<h2>Trash (drag me back)</h2> <h2>Trash (drag me back)</h2>

View File

@ -117,15 +117,15 @@ $(window).bind('load', function() {
.displayBox(); .displayBox();
return false; return false;
}); });
var sliderChange = function(event, ui){ var sliderChange = function(event, ui){
$('.img_content').each(function(index, item){ $('.img_content').each(function(index, item){
var _new = 1.44 * $('#sliderSize').slider("value"); var _new = 1.44 * $('#sliderSize').slider("value");
$(this).css("width", _new+'px') $(this).css("width", _new+'px')
.parent().css("width", (_new+16)+'px'); .parent().css("width", (_new+16)+'px');
}); });
} }
$('#sliderSize').slider({ $('#sliderSize').slider({
@ -136,7 +136,7 @@ $(window).bind('load', function() {
slide : sliderChange, slide : sliderChange,
change : sliderChange change : sliderChange
}); });
}); });
function createGalleryItem(img) { function createGalleryItem(img) {

View File

@ -8,15 +8,15 @@
*/ */
(function($) { (function($) {
$.extend($.fn, { $.extend($.fn, {
livequery: function(type, fn, fn2) { livequery: function(type, fn, fn2) {
var self = this, q; var self = this, q;
// Handle different call patterns // Handle different call patterns
if ($.isFunction(type)) if ($.isFunction(type))
fn2 = fn, fn = type, type = undefined; fn2 = fn, fn = type, type = undefined;
// See if Live Query already exists // See if Live Query already exists
$.each( $.livequery.queries, function(i, query) { $.each( $.livequery.queries, function(i, query) {
if ( self.selector == query.selector && self.context == query.context && if ( self.selector == query.selector && self.context == query.context &&
@ -24,34 +24,34 @@ $.extend($.fn, {
// Found the query, exit the each loop // Found the query, exit the each loop
return (q = query) && false; return (q = query) && false;
}); });
// Create new Live Query if it wasn't found // Create new Live Query if it wasn't found
q = q || new $.livequery(this.selector, this.context, type, fn, fn2); q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
// Make sure it is running // Make sure it is running
q.stopped = false; q.stopped = false;
// Run it // Run it
$.livequery.run( q.id ); $.livequery.run( q.id );
// Contnue the chain // Contnue the chain
return this; return this;
}, },
expire: function(type, fn, fn2) { expire: function(type, fn, fn2) {
var self = this; var self = this;
// Handle different call patterns // Handle different call patterns
if ($.isFunction(type)) if ($.isFunction(type))
fn2 = fn, fn = type, type = undefined; fn2 = fn, fn = type, type = undefined;
// Find the Live Query based on arguments and stop it // Find the Live Query based on arguments and stop it
$.each( $.livequery.queries, function(i, query) { $.each( $.livequery.queries, function(i, query) {
if ( self.selector == query.selector && self.context == query.context && if ( self.selector == query.selector && self.context == query.context &&
(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped ) (!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
$.livequery.stop(query.id); $.livequery.stop(query.id);
}); });
// Continue the chain // Continue the chain
return this; return this;
} }
@ -65,14 +65,14 @@ $.livequery = function(selector, context, type, fn, fn2) {
this.fn2 = fn2; this.fn2 = fn2;
this.elements = []; this.elements = [];
this.stopped = false; this.stopped = false;
// The id is the index of the Live Query in $.livequery.queries // The id is the index of the Live Query in $.livequery.queries
this.id = $.livequery.queries.push(this)-1; this.id = $.livequery.queries.push(this)-1;
// Mark the functions for matching later on // Mark the functions for matching later on
fn.$lqguid = fn.$lqguid || $.livequery.guid++; fn.$lqguid = fn.$lqguid || $.livequery.guid++;
if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++; if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
// Return the Live Query // Return the Live Query
return this; return this;
}; };
@ -80,7 +80,7 @@ $.livequery = function(selector, context, type, fn, fn2) {
$.livequery.prototype = { $.livequery.prototype = {
stop: function() { stop: function() {
var query = this; var query = this;
if ( this.type ) if ( this.type )
// Unbind all bound events // Unbind all bound events
this.elements.unbind(this.type, this.fn); this.elements.unbind(this.type, this.fn);
@ -89,30 +89,30 @@ $.livequery.prototype = {
this.elements.each(function(i, el) { this.elements.each(function(i, el) {
query.fn2.apply(el); query.fn2.apply(el);
}); });
// Clear out matched elements // Clear out matched elements
this.elements = []; this.elements = [];
// Stop the Live Query from running until restarted // Stop the Live Query from running until restarted
this.stopped = true; this.stopped = true;
}, },
run: function() { run: function() {
// Short-circuit if stopped // Short-circuit if stopped
if ( this.stopped ) return; if ( this.stopped ) return;
var query = this; var query = this;
var oEls = this.elements, var oEls = this.elements,
els = $(this.selector, this.context), els = $(this.selector, this.context),
nEls = els.not(oEls); nEls = els.not(oEls);
// Set elements to the latest set of matched elements // Set elements to the latest set of matched elements
this.elements = els; this.elements = els;
if (this.type) { if (this.type) {
// Bind events to newly matched elements // Bind events to newly matched elements
nEls.bind(this.type, this.fn); nEls.bind(this.type, this.fn);
// Unbind events to elements no longer matched // Unbind events to elements no longer matched
if (oEls.length > 0) if (oEls.length > 0)
$.each(oEls, function(i, el) { $.each(oEls, function(i, el) {
@ -125,7 +125,7 @@ $.livequery.prototype = {
nEls.each(function() { nEls.each(function() {
query.fn.apply(this); query.fn.apply(this);
}); });
// Call the second function for elements no longer matched // Call the second function for elements no longer matched
if ( this.fn2 && oEls.length > 0 ) if ( this.fn2 && oEls.length > 0 )
$.each(oEls, function(i, el) { $.each(oEls, function(i, el) {
@ -142,7 +142,7 @@ $.extend($.livequery, {
queue: [], queue: [],
running: false, running: false,
timeout: null, timeout: null,
checkQueue: function() { checkQueue: function() {
if ( $.livequery.running && $.livequery.queue.length ) { if ( $.livequery.running && $.livequery.queue.length ) {
var length = $.livequery.queue.length; var length = $.livequery.queue.length;
@ -151,41 +151,41 @@ $.extend($.livequery, {
$.livequery.queries[ $.livequery.queue.shift() ].run(); $.livequery.queries[ $.livequery.queue.shift() ].run();
} }
}, },
pause: function() { pause: function() {
// Don't run anymore Live Queries until restarted // Don't run anymore Live Queries until restarted
$.livequery.running = false; $.livequery.running = false;
}, },
play: function() { play: function() {
// Restart Live Queries // Restart Live Queries
$.livequery.running = true; $.livequery.running = true;
// Request a run of the Live Queries // Request a run of the Live Queries
$.livequery.run(); $.livequery.run();
}, },
registerPlugin: function() { registerPlugin: function() {
$.each( arguments, function(i,n) { $.each( arguments, function(i,n) {
// Short-circuit if the method doesn't exist // Short-circuit if the method doesn't exist
if (!$.fn[n]) return; if (!$.fn[n]) return;
// Save a reference to the original method // Save a reference to the original method
var old = $.fn[n]; var old = $.fn[n];
// Create a new method // Create a new method
$.fn[n] = function() { $.fn[n] = function() {
// Call the original method // Call the original method
var r = old.apply(this, arguments); var r = old.apply(this, arguments);
// Request a run of the Live Queries // Request a run of the Live Queries
$.livequery.run(); $.livequery.run();
// Return the original methods result // Return the original methods result
return r; return r;
} }
}); });
}, },
run: function(id) { run: function(id) {
if (id != undefined) { if (id != undefined) {
// Put the particular Live Query in the queue if it doesn't already exist // Put the particular Live Query in the queue if it doesn't already exist
@ -198,13 +198,13 @@ $.extend($.livequery, {
if ( $.inArray(id, $.livequery.queue) < 0 ) if ( $.inArray(id, $.livequery.queue) < 0 )
$.livequery.queue.push( id ); $.livequery.queue.push( id );
}); });
// Clear timeout if it already exists // Clear timeout if it already exists
if ($.livequery.timeout) clearTimeout($.livequery.timeout); if ($.livequery.timeout) clearTimeout($.livequery.timeout);
// Create a timeout to check the queue and actually run the Live Queries // Create a timeout to check the queue and actually run the Live Queries
$.livequery.timeout = setTimeout($.livequery.checkQueue, 20); $.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
}, },
stop: function(id) { stop: function(id) {
if (id != undefined) if (id != undefined)
// Stop are particular Live Query // Stop are particular Live Query
@ -231,20 +231,20 @@ var init = $.prototype.init;
$.prototype.init = function(a,c) { $.prototype.init = function(a,c) {
// Call the original init and save the result // Call the original init and save the result
var r = init.apply(this, arguments); var r = init.apply(this, arguments);
// Copy over properties if they exist already // Copy over properties if they exist already
if (a && a.selector) if (a && a.selector)
r.context = a.context, r.selector = a.selector; r.context = a.context, r.selector = a.selector;
// Set properties // Set properties
if ( typeof a == 'string' ) if ( typeof a == 'string' )
r.context = c || document, r.selector = a; r.context = c || document, r.selector = a;
// Return the result // Return the result
return r; return r;
}; };
// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091) // Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
$.prototype.init.prototype = $.prototype; $.prototype.init.prototype = $.prototype;
})(jQuery); })(jQuery);

View File

@ -57,7 +57,7 @@
<div id="col-1"> <div id="col-1">
<div id="slider1" class="ui-slider-2"> <div id="slider1" class="ui-slider-2">
<div class="ui-slider-handle"></div> <div class="ui-slider-handle"></div>
<div class="ui-slider-handle"></div> <div class="ui-slider-handle"></div>
<span class="label-1">0</span> <span class="label-1">0</span>
<span class="label-2">100</span> <span class="label-2">100</span>
</div> </div>
@ -76,7 +76,7 @@
<option>bounce</option> <option>bounce</option>
</select> </select>
</div> </div>
<div id="col-2"> <div id="col-2">
<div>0</div> <div>0</div>
<div>10</div> <div>10</div>

View File

@ -7,7 +7,7 @@
<!-- jQuery --> <!-- jQuery -->
<script type="text/javascript" src="../../../jquery-1.2.6.js"></script> <script type="text/javascript" src="../../../jquery-1.2.6.js"></script>
<!-- jQuery UI --> <!-- jQuery UI -->
<script type="text/javascript" src="../../../ui/ui.core.js"></script> <script type="text/javascript" src="../../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../../ui/ui.resizable.js"></script> <script type="text/javascript" src="../../../ui/ui.resizable.js"></script>
@ -26,9 +26,9 @@
<span class="ui-toolbar-item-hide-icon"></span> <span>jQuery UI Resizable SplitPanel</span> <span class="ui-toolbar-item-hide-icon"></span> <span>jQuery UI Resizable SplitPanel</span>
</div> </div>
<table id="container" cellpadding="0" cellspacing="0" border="0"> <table id="container" cellpadding="0" cellspacing="0" border="0">
<tr> <tr>
<td class="ui-split-side-box"> <td class="ui-split-side-box">
<div class="ui-split-side"> <div class="ui-split-side">
<ul id="component-links"> <ul id="component-links">
@ -43,17 +43,17 @@
</ul> </ul>
</div> </div>
</td> </td>
<td class="ui-split-main-box"> <td class="ui-split-main-box">
<div class="ui-split-main1"> <div class="ui-split-main1">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien.
<br><br> <br><br>
Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus. Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus.
</div> </div>
</td> </td>
<td class="ui-split-main-box"> <td class="ui-split-main-box">
<div class="ui-split-main2"> <div class="ui-split-main2">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien.
@ -61,7 +61,7 @@
Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus. Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus.
</div> </div>
</td> </td>
<td class="ui-split-main-box"> <td class="ui-split-main-box">
<div class="ui-split-main3"> <div class="ui-split-main3">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum commodo mollis tortor. Ut dapibus turpis consequat quam. Nulla lacinia. Donec nunc. Donec sollicitudin. Vivamus orci. Pellentesque tempus velit vitae odio. Maecenas enim arcu, volutpat ac, viverra id, bibendum eu, felis. Vestibulum imperdiet arcu. Ut nisi. Cras vel lectus consectetuer mauris luctus ultrices. Duis fringilla pellentesque sapien.
@ -69,9 +69,9 @@
Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus. Cras tristique justo vel metus. Pellentesque dolor libero, ullamcorper ac, vehicula eget, porttitor at, dui. Ut a nibh. Nunc sit amet turpis. Aenean diam dui, consequat vel, scelerisque id, accumsan a, lectus. Duis ultrices, enim vitae pharetra tincidunt, elit nunc sollicitudin felis, dapibus pellentesque urna velit ut quam. Donec scelerisque vehicula dolor. Suspendisse lectus dui, posuere sit amet, sagittis nec, vulputate in, libero. Morbi tempus sagittis est. Phasellus in nisi. Sed a ligula. Vivamus condimentum quam non nibh. Fusce pellentesque, neque ac scelerisque luctus, leo elit bibendum elit, in rutrum leo erat tristique felis. Etiam consequat fringilla eros. Nullam neque. Aenean mollis, odio at consectetuer sollicitudin, tortor lorem facilisis nunc, sit amet condimentum lectus libero convallis dolor. Vivamus quis risus.
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@ -82,7 +82,7 @@
minWidth: 200, minWidth: 200,
maxWidth: 800 maxWidth: 800
}); });
$('div.ui-split-side').resizable({ $('div.ui-split-side').resizable({
handles: 'e', handles: 'e',
proxy: 'proxy', proxy: 'proxy',

View File

@ -2,13 +2,13 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Accordion Test Suite</title> <title>jQuery UI Accordion Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.accordion.js"></script> <script type="text/javascript" src="../ui/ui.accordion.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
@ -109,7 +109,7 @@
Cool kids are blue. Cool kids are blue.
</dd> </dd>
</dl> </dl>
<div id="list3"> <div id="list3">
<div> <div>
<div class="title">Tennis</div> <div class="title">Tennis</div>
@ -134,7 +134,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -133,7 +133,7 @@ test("accessibility", function () {
expect(9); expect(9);
var ac = $('#list1').accordion().accordion("activate", 1); var ac = $('#list1').accordion().accordion("activate", 1);
var headers = $(".ui-accordion-header"); var headers = $(".ui-accordion-header");
equals( headers.eq(1).attr("tabindex"), "0", "active header should have tabindex=0"); equals( headers.eq(1).attr("tabindex"), "0", "active header should have tabindex=0");
equals( headers.eq(0).attr("tabindex"), "-1", "inactive header should have tabindex=-1"); equals( headers.eq(0).attr("tabindex"), "-1", "inactive header should have tabindex=-1");
equals( ac.attr("role"), "tablist", "main role"); equals( ac.attr("role"), "tablist", "main role");

View File

@ -18,7 +18,7 @@
<script type="text/javascript" src="../ui/ui.sortable.js"></script> <script type="text/javascript" src="../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../ui/ui.spinner.js"></script> <script type="text/javascript" src="../ui/ui.spinner.js"></script>
<script type="text/javascript" src="../ui/ui.tabs.js"></script> <script type="text/javascript" src="../ui/ui.tabs.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="plugins/cookie/jquery.cookie.js"></script> <script type="text/javascript" src="plugins/cookie/jquery.cookie.js"></script>
@ -152,7 +152,7 @@
Cool kids are blue. Cool kids are blue.
</dd> </dd>
</dl> </dl>
<div id="list3"> <div id="list3">
<div> <div>
<div class="title">Tennis</div> <div class="title">Tennis</div>
@ -222,7 +222,7 @@
<div id="colon:test"></div> <div id="colon:test"></div>
<div style="height: 300px;" id="inline-style"></div> <div style="height: 300px;" id="inline-style"></div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -33,10 +33,10 @@
} }
} }
}); });
</script> </script>
<script type="text/javascript" src="../ui/ui.accordion.js"></script> <script type="text/javascript" src="../ui/ui.accordion.js"></script>
@ -51,7 +51,7 @@
<script type="text/javascript" src="../ui/ui.sortable.js"></script> <script type="text/javascript" src="../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../ui/ui.spinner.js"></script> <script type="text/javascript" src="../ui/ui.spinner.js"></script>
<script type="text/javascript" src="../ui/ui.tabs.js"></script> <script type="text/javascript" src="../ui/ui.tabs.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="plugins/cookie/jquery.cookie.js"></script> <script type="text/javascript" src="plugins/cookie/jquery.cookie.js"></script>

View File

@ -2,16 +2,16 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Core Test Suite</title> <title>jQuery UI Core Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<!--link rel="stylesheet" href="../themes/flora/flora.dialog.css" type="text/css" media="screen"--> <!--link rel="stylesheet" href="../themes/flora/flora.dialog.css" type="text/css" media="screen"-->
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="core.js"></script> <script type="text/javascript" src="core.js"></script>
<style type="text/css"> <style type="text/css">
html { border: 0; } html { border: 0; }
</style> </style>

View File

@ -7,7 +7,7 @@ module("selectors");
test("tabbable - enabled elements", function() { test("tabbable - enabled elements", function() {
expect(10); expect(10);
ok( $('#input1-1').is(':tabbable'), 'input, no type'); ok( $('#input1-1').is(':tabbable'), 'input, no type');
ok( $('#input1-2').is(':tabbable'), 'input, type text'); ok( $('#input1-2').is(':tabbable'), 'input, type text');
ok( $('#input1-3').is(':tabbable'), 'input, type checkbox'); ok( $('#input1-3').is(':tabbable'), 'input, type checkbox');
@ -22,7 +22,7 @@ test("tabbable - enabled elements", function() {
test("tabbable - disabled elements", function() { test("tabbable - disabled elements", function() {
expect(8); expect(8);
ok(!$('#input2-1').is(':tabbable'), 'input, no type'); ok(!$('#input2-1').is(':tabbable'), 'input, no type');
ok(!$('#input2-2').is(':tabbable'), 'input, type text'); ok(!$('#input2-2').is(':tabbable'), 'input, type text');
ok(!$('#input2-3').is(':tabbable'), 'input, type checkbox'); ok(!$('#input2-3').is(':tabbable'), 'input, type checkbox');
@ -35,7 +35,7 @@ test("tabbable - disabled elements", function() {
test("tabbable - hidden styles", function() { test("tabbable - hidden styles", function() {
expect(6); expect(6);
ok(!$('#input3-1').is(':tabbable'), 'input, hidden wrapper - display: none'); ok(!$('#input3-1').is(':tabbable'), 'input, hidden wrapper - display: none');
ok(!$('#anchor3-1').is(':tabbable'), 'anchor, hidden wrapper - display: none'); ok(!$('#anchor3-1').is(':tabbable'), 'anchor, hidden wrapper - display: none');
ok(!$('#input3-2').is(':tabbable'), 'input, hidden wrapper - visibility: hidden'); ok(!$('#input3-2').is(':tabbable'), 'input, hidden wrapper - visibility: hidden');
@ -46,7 +46,7 @@ test("tabbable - hidden styles", function() {
test("tabbable - tabindex", function() { test("tabbable - tabindex", function() {
expect(4); expect(4);
ok( $('#input4-1').is(':tabbable'), 'input, tabindex 0'); ok( $('#input4-1').is(':tabbable'), 'input, tabindex 0');
ok( $('#input4-2').is(':tabbable'), 'input, tabindex 10'); ok( $('#input4-2').is(':tabbable'), 'input, tabindex 10');
ok(!$('#input4-3').is(':tabbable'), 'input, tabindex -1'); ok(!$('#input4-3').is(':tabbable'), 'input, tabindex -1');
@ -57,20 +57,20 @@ module('jQuery extensions');
test("attr - aria", function() { test("attr - aria", function() {
expect(6); expect(6);
var el = $('#aria'); var el = $('#aria');
ok(!el.attr('role'), 'role is empty via attr'); ok(!el.attr('role'), 'role is empty via attr');
equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist'); equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist');
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined'); equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined');
el.attr('aria-expanded', true); el.attr('aria-expanded', true);
equals(el.attr('aria-expanded'), 'true', 'aria expanded is true'); equals(el.attr('aria-expanded'), 'true', 'aria expanded is true');
el.removeAttr('aria-expanded'); el.removeAttr('aria-expanded');
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing'); equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing');
el.attr('aria-expanded', false); el.attr('aria-expanded', false);
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false'); equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
}); });

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Datepicker Test Suite</title> <title>jQuery UI Datepicker Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
@ -10,7 +10,7 @@
<script type="text/javascript" src="../ui/ui.datepicker.js"></script> <script type="text/javascript" src="../ui/ui.datepicker.js"></script>
<script type="text/javascript" src="../ui/i18n/ui.datepicker-fr.js"></script> <script type="text/javascript" src="../ui/i18n/ui.datepicker-fr.js"></script>
<script type="text/javascript" src="../ui/i18n/ui.datepicker-he.js"></script> <script type="text/javascript" src="../ui/i18n/ui.datepicker-he.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>

View File

@ -5,18 +5,18 @@
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<!--link rel="stylesheet" href="../themes/flora/flora.dialog.css" type="text/css" media="screen"--> <!--link rel="stylesheet" href="../themes/flora/flora.dialog.css" type="text/css" media="screen"-->
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.dialog.js"></script> <script type="text/javascript" src="../ui/ui.dialog.js"></script>
<script type="text/javascript" src="../ui/ui.draggable.js"></script> <script type="text/javascript" src="../ui/ui.draggable.js"></script>
<script type="text/javascript" src="../ui/ui.resizable.js"></script> <script type="text/javascript" src="../ui/ui.resizable.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="dialog.js"></script> <script type="text/javascript" src="dialog.js"></script>
<style type="text/css"> <style type="text/css">
html { border: 0; } html { border: 0; }
</style> </style>

View File

@ -114,24 +114,24 @@ module("dialog");
test("init", function() { test("init", function() {
expect(6); expect(6);
$("<div></div>").appendTo('body').dialog().remove(); $("<div></div>").appendTo('body').dialog().remove();
ok(true, '.dialog() called on element'); ok(true, '.dialog() called on element');
$([]).dialog().remove(); $([]).dialog().remove();
ok(true, '.dialog() called on empty collection'); ok(true, '.dialog() called on empty collection');
$('<div></div>').dialog().remove(); $('<div></div>').dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement'); ok(true, '.dialog() called on disconnected DOMElement');
$('<div></div>').dialog().dialog("foo").remove(); $('<div></div>').dialog().dialog("foo").remove();
ok(true, 'arbitrary method called after init'); ok(true, 'arbitrary method called after init');
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
var foo = el.data("foo.dialog"); var foo = el.data("foo.dialog");
el.remove(); el.remove();
ok(true, 'arbitrary option getter after init'); ok(true, 'arbitrary option getter after init');
$('<div></div>').dialog().data("foo.dialog", "bar").remove(); $('<div></div>').dialog().data("foo.dialog", "bar").remove();
ok(true, 'arbitrary option setter after init'); ok(true, 'arbitrary option setter after init');
}); });
@ -193,22 +193,22 @@ test("defaults", function() {
test("title id", function() { test("title id", function() {
expect(3); expect(3);
var titleId; var titleId;
// reset the uuid so we know what values to expect // reset the uuid so we know what values to expect
$.ui.dialog.uuid = 0; $.ui.dialog.uuid = 0;
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id'); titleId = dlg().find('.ui-dialog-title').attr('id');
equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id'); equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
el.remove(); el.remove();
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id'); titleId = dlg().find('.ui-dialog-title').attr('id');
equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id'); equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
el.remove(); el.remove();
el = $('<div id="foo"/>').dialog(); el = $('<div id="foo"/>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id'); titleId = dlg().find('.ui-dialog-title').attr('id');
equals(titleId, 'ui-dialog-title-foo', 'carried over title id'); equals(titleId, 'ui-dialog-title-foo', 'carried over title id');
@ -219,11 +219,11 @@ module("dialog: Options");
test("autoOpen", function() { test("autoOpen", function() {
expect(2); expect(2);
el = $('<div></div>').dialog({ autoOpen: false }); el = $('<div></div>').dialog({ autoOpen: false });
isNotOpen('.dialog({ autoOpen: false })'); isNotOpen('.dialog({ autoOpen: false })');
el.remove(); el.remove();
el = $('<div></div>').dialog({ autoOpen: true }); el = $('<div></div>').dialog({ autoOpen: true });
isOpen('.dialog({ autoOpen: true })'); isOpen('.dialog({ autoOpen: true })');
el.remove(); el.remove();
@ -231,12 +231,12 @@ test("autoOpen", function() {
test("autoResize", function() { test("autoResize", function() {
expect(2); expect(2);
var actual, var actual,
before, before,
expected, expected,
handle; handle;
el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: false }); el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: false });
expected = { height: el.height() }; expected = { height: el.height() };
handle = $(".ui-resizable-se", dlg()); handle = $(".ui-resizable-se", dlg());
@ -256,7 +256,7 @@ test("autoResize", function() {
test("buttons", function() { test("buttons", function() {
expect(17); expect(17);
var buttons = { var buttons = {
"Ok": function(ev, ui) { "Ok": function(ev, ui) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
@ -269,20 +269,20 @@ test("buttons", function() {
equals(ev.target, btn[1], "event target"); equals(ev.target, btn[1], "event target");
} }
}; };
el = $('<div></div>').dialog({ buttons: buttons }); el = $('<div></div>').dialog({ buttons: buttons });
var btn = $("button", dlg()); var btn = $("button", dlg());
equals(btn.length, 2, "number of buttons"); equals(btn.length, 2, "number of buttons");
var i = 0; var i = 0;
$.each(buttons, function(key, val) { $.each(buttons, function(key, val) {
equals(btn.eq(i).text(), key, "text of button " + (i+1)); equals(btn.eq(i).text(), key, "text of button " + (i+1));
i++; i++;
}); });
equals(btn.parent().attr('className'), 'ui-dialog-buttonpane', "buttons in container"); equals(btn.parent().attr('className'), 'ui-dialog-buttonpane', "buttons in container");
btn.trigger("click"); btn.trigger("click");
var newButtons = { var newButtons = {
"Close": function(ev, ui) { "Close": function(ev, ui) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
@ -290,35 +290,35 @@ test("buttons", function() {
equals(ev.target, btn[0], "event target"); equals(ev.target, btn[0], "event target");
} }
}; };
equals(el.data("buttons.dialog"), buttons, '.data("buttons.dialog") getter'); equals(el.data("buttons.dialog"), buttons, '.data("buttons.dialog") getter');
el.data("buttons.dialog", newButtons); el.data("buttons.dialog", newButtons);
equals(el.data("buttons.dialog"), newButtons, '.data("buttons.dialog", ...) setter'); equals(el.data("buttons.dialog"), newButtons, '.data("buttons.dialog", ...) setter');
btn = $("button", dlg()); btn = $("button", dlg());
equals(btn.length, 1, "number of buttons after setter"); equals(btn.length, 1, "number of buttons after setter");
btn.trigger('click'); btn.trigger('click');
i = 0; i = 0;
$.each(newButtons, function(key, val) { $.each(newButtons, function(key, val) {
equals(btn.eq(i).text(), key, "text of button " + (i+1)); equals(btn.eq(i).text(), key, "text of button " + (i+1));
i += 1; i += 1;
}); });
el.remove(); el.remove();
}); });
test("dialogClass", function() { test("dialogClass", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added'); equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
el.remove(); el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo" }); el = $('<div></div>').dialog({ dialogClass: "foo" });
equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added'); equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
el.remove(); el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo bar" }); el = $('<div></div>').dialog({ dialogClass: "foo bar" });
equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added'); equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added'); equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
@ -327,13 +327,13 @@ test("dialogClass", function() {
test("draggable", function() { test("draggable", function() {
expect(4); expect(4);
el = $('<div></div>').dialog({ draggable: false }); el = $('<div></div>').dialog({ draggable: false });
shouldnotmove(); shouldnotmove();
el.data('draggable.dialog', true); el.data('draggable.dialog', true);
shouldmove(); shouldmove();
el.remove(); el.remove();
el = $('<div></div>').dialog({ draggable: true }); el = $('<div></div>').dialog({ draggable: true });
shouldmove(); shouldmove();
el.data('draggable.dialog', false); el.data('draggable.dialog', false);
@ -343,15 +343,15 @@ test("draggable", function() {
test("height", function() { test("height", function() {
expect(3); expect(3);
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(dlg().height(), defaults.height, "default height"); equals(dlg().height(), defaults.height, "default height");
el.remove(); el.remove();
el = $('<div></div>').dialog({ height: 437 }); el = $('<div></div>').dialog({ height: 437 });
equals(dlg().height(), 437, "explicit height"); equals(dlg().height(), 437, "explicit height");
el.remove(); el.remove();
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
el.data('height.dialog', 438); el.data('height.dialog', 438);
equals(dlg().height(), 438, "explicit height set after init"); equals(dlg().height(), 438, "explicit height set after init");
@ -360,17 +360,17 @@ test("height", function() {
test("maxHeight", function() { test("maxHeight", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ maxHeight: 400 }); el = $('<div></div>').dialog({ maxHeight: 400 });
drag('.ui-resizable-s', 1000, 1000); drag('.ui-resizable-s', 1000, 1000);
equals(heightAfter, 400, "maxHeight"); equals(heightAfter, 400, "maxHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxHeight: 400 }); el = $('<div></div>').dialog({ maxHeight: 400 });
drag('.ui-resizable-n', -1000, -1000); drag('.ui-resizable-n', -1000, -1000);
equals(heightAfter, 400, "maxHeight"); equals(heightAfter, 400, "maxHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600); el = $('<div></div>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600);
drag('.ui-resizable-n', -1000, -1000); drag('.ui-resizable-n', -1000, -1000);
equals(heightAfter, 600, "maxHeight"); equals(heightAfter, 600, "maxHeight");
@ -379,17 +379,17 @@ test("maxHeight", function() {
test("maxWidth", function() { test("maxWidth", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ maxWidth: 400 }); el = $('<div></div>').dialog({ maxWidth: 400 });
drag('.ui-resizable-e', 1000, 1000); drag('.ui-resizable-e', 1000, 1000);
equals(widthAfter, 400, "maxWidth"); equals(widthAfter, 400, "maxWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxWidth: 400 }); el = $('<div></div>').dialog({ maxWidth: 400 });
drag('.ui-resizable-w', -1000, -1000); drag('.ui-resizable-w', -1000, -1000);
equals(widthAfter, 400, "maxWidth"); equals(widthAfter, 400, "maxWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600); el = $('<div></div>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600);
drag('.ui-resizable-w', -1000, -1000); drag('.ui-resizable-w', -1000, -1000);
equals(widthAfter, 600, "maxWidth"); equals(widthAfter, 600, "maxWidth");
@ -398,17 +398,17 @@ test("maxWidth", function() {
test("minHeight", function() { test("minHeight", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ minHeight: 10 }); el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-s', -1000, -1000); drag('.ui-resizable-s', -1000, -1000);
equals(heightAfter, 10, "minHeight"); equals(heightAfter, 10, "minHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }); el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-n', 1000, 1000); drag('.ui-resizable-n', 1000, 1000);
equals(heightAfter, 10, "minHeight"); equals(heightAfter, 10, "minHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30); el = $('<div></div>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30);
drag('.ui-resizable-n', 1000, 1000); drag('.ui-resizable-n', 1000, 1000);
equals(heightAfter, 30, "minHeight"); equals(heightAfter, 30, "minHeight");
@ -417,17 +417,17 @@ test("minHeight", function() {
test("minWidth", function() { test("minWidth", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ minWidth: 10 }); el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-e', -1000, -1000); drag('.ui-resizable-e', -1000, -1000);
equals(widthAfter, 10, "minWidth"); equals(widthAfter, 10, "minWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minWidth: 10 }); el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-w', 1000, 1000); drag('.ui-resizable-w', 1000, 1000);
equals(widthAfter, 10, "minWidth"); equals(widthAfter, 10, "minWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30); el = $('<div></div>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30);
drag('.ui-resizable-w', 1000, 1000); drag('.ui-resizable-w', 1000, 1000);
equals(widthAfter, 30, "minWidth"); equals(widthAfter, 30, "minWidth");
@ -448,13 +448,13 @@ test("position", function() {
test("resizable", function() { test("resizable", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
shouldresize("[default]"); shouldresize("[default]");
el.data('resizable.dialog', false); el.data('resizable.dialog', false);
shouldnotresize('disabled after init'); shouldnotresize('disabled after init');
el.remove(); el.remove();
el = $('<div></div>').dialog({ resizable: false }); el = $('<div></div>').dialog({ resizable: false });
shouldnotresize("disabled in init options"); shouldnotresize("disabled in init options");
el.data('resizable.dialog', true); el.data('resizable.dialog', true);
@ -468,27 +468,27 @@ test("stack", function() {
test("title", function() { test("title", function() {
expect(5); expect(5);
function titleText() { function titleText() {
return dlg().find(".ui-dialog-title").html(); return dlg().find(".ui-dialog-title").html();
} }
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(titleText(), "&nbsp;", "[default]"); equals(titleText(), "&nbsp;", "[default]");
el.remove(); el.remove();
el = $('<div title="foo"/>').dialog(); el = $('<div title="foo"/>').dialog();
equals(titleText(), "foo", "title in element attribute"); equals(titleText(), "foo", "title in element attribute");
el.remove(); el.remove();
el = $('<div></div>').dialog({ title: 'foo' }); el = $('<div></div>').dialog({ title: 'foo' });
equals(titleText(), "foo", "title in init options"); equals(titleText(), "foo", "title in init options");
el.remove(); el.remove();
el = $('<div title="foo"/>').dialog({ title: 'bar' }); el = $('<div title="foo"/>').dialog({ title: 'bar' });
equals(titleText(), "bar", "title in init options should override title in element attribute"); equals(titleText(), "bar", "title in init options should override title in element attribute");
el.remove(); el.remove();
el = $('<div></div>').dialog().data('title.dialog', 'foo'); el = $('<div></div>').dialog().data('title.dialog', 'foo');
equals(titleText(), 'foo', 'title after init'); equals(titleText(), 'foo', 'title after init');
el.remove(); el.remove();
@ -496,11 +496,11 @@ test("title", function() {
test("width", function() { test("width", function() {
expect(3); expect(3);
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(dlg().width(), defaults.width, "default width"); equals(dlg().width(), defaults.width, "default width");
el.remove(); el.remove();
el = $('<div></div>').dialog({width: 437 }); el = $('<div></div>').dialog({width: 437 });
equals(dlg().width(), 437, "explicit width"); equals(dlg().width(), 437, "explicit width");
el.data('width.dialog', 438); el.data('width.dialog', 438);
@ -512,13 +512,13 @@ module("dialog: Methods");
test("isOpen", function() { test("isOpen", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
equals(el.dialog('isOpen'), true, "dialog is open after init"); equals(el.dialog('isOpen'), true, "dialog is open after init");
el.dialog('close'); el.dialog('close');
equals(el.dialog('isOpen'), false, "dialog is closed"); equals(el.dialog('isOpen'), false, "dialog is closed");
el.remove(); el.remove();
el = $('<div></div>').dialog({autoOpen: false}); el = $('<div></div>').dialog({autoOpen: false});
equals(el.dialog('isOpen'), false, "dialog is closed after init"); equals(el.dialog('isOpen'), false, "dialog is closed after init");
el.dialog('open'); el.dialog('open');
@ -530,7 +530,7 @@ module("dialog: Callbacks");
test("open", function() { test("open", function() {
expect(6); expect(6);
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
open: function(ev, ui) { open: function(ev, ui) {
@ -539,7 +539,7 @@ test("open", function() {
} }
}); });
el.remove(); el.remove();
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
autoOpen: false, autoOpen: false,
@ -550,7 +550,7 @@ test("open", function() {
}); });
el.dialog("open"); el.dialog("open");
el.remove(); el.remove();
el = $('<div></div>').dialog({ el = $('<div></div>').dialog({
autoOpen: false autoOpen: false
}); });
@ -564,7 +564,7 @@ test("open", function() {
test("dragStart", function() { test("dragStart", function() {
expect(2); expect(2);
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
dragStart: function(ev, ui) { dragStart: function(ev, ui) {
@ -579,7 +579,7 @@ test("dragStart", function() {
test("drag", function() { test("drag", function() {
var fired = false; var fired = false;
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
drag: function(ev, ui) { drag: function(ev, ui) {
@ -595,7 +595,7 @@ test("drag", function() {
test("dragStop", function() { test("dragStop", function() {
expect(2); expect(2);
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
dragStop: function(ev, ui) { dragStop: function(ev, ui) {
@ -610,7 +610,7 @@ test("dragStop", function() {
test("resizeStart", function() { test("resizeStart", function() {
expect(2); expect(2);
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
resizeStart: function(ev, ui) { resizeStart: function(ev, ui) {
@ -625,7 +625,7 @@ test("resizeStart", function() {
test("resize", function() { test("resize", function() {
var fired = false; var fired = false;
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
resize: function(ev, ui) { resize: function(ev, ui) {
@ -641,7 +641,7 @@ test("resize", function() {
test("resizeStop", function() { test("resizeStop", function() {
expect(2); expect(2);
el = $("<div></div>"); el = $("<div></div>");
el.dialog({ el.dialog({
resizeStop: function(ev, ui) { resizeStop: function(ev, ui) {
@ -656,7 +656,7 @@ test("resizeStop", function() {
test("close", function() { test("close", function() {
expect(4); expect(4);
el = $('<div></div>').dialog({ el = $('<div></div>').dialog({
close: function(ev, ui) { close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback'); ok(true, '.dialog("close") fires close callback');
@ -665,7 +665,7 @@ test("close", function() {
}); });
el.dialog("close"); el.dialog("close");
el.remove(); el.remove();
el = $('<div></div>').dialog().bind('dialogclose', function(ev, ui) { el = $('<div></div>').dialog().bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") firse dialogclose event'); ok(true, '.dialog("close") firse dialogclose event');
equals(this, el[0], 'context of event'); equals(this, el[0], 'context of event');
@ -676,7 +676,7 @@ test("close", function() {
test("beforeclose", function() { test("beforeclose", function() {
expect(6); expect(6);
el = $('<div></div>').dialog({ el = $('<div></div>').dialog({
beforeclose: function(ev, ui) { beforeclose: function(ev, ui) {
ok(true, '.dialog("close") fires beforeclose callback'); ok(true, '.dialog("close") fires beforeclose callback');
@ -687,7 +687,7 @@ test("beforeclose", function() {
el.dialog('close'); el.dialog('close');
isOpen('beforeclose callback should prevent dialog from closing'); isOpen('beforeclose callback should prevent dialog from closing');
el.remove(); el.remove();
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) { el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
ok(true, '.dialog("close") triggers dialogbeforeclose event'); ok(true, '.dialog("close") triggers dialogbeforeclose event');
equals(this, el[0], "context of event"); equals(this, el[0], "context of event");

View File

@ -4,16 +4,16 @@
<title>jQuery UI Draggable Test Suite</title> <title>jQuery UI Draggable Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.draggable.js"></script> <script type="text/javascript" src="../ui/ui.draggable.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="draggable.js"></script> <script type="text/javascript" src="draggable.js"></script>
<style type="text/css"> <style type="text/css">
html { border: 0; } html { border: 0; }
#main { #main {

View File

@ -98,7 +98,7 @@ test("init", function() {
test("destroy", function() { test("destroy", function() {
expect(6); expect(6);
$("<div></div>").appendTo('body').draggable().draggable("destroy").remove(); $("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
ok(true, '.draggable("destroy") called on element'); ok(true, '.draggable("destroy") called on element');
$([]).draggable().draggable("destroy"); $([]).draggable().draggable("destroy");
@ -186,7 +186,7 @@ test("No options, relative", function() {
test("No options, absolute", function() { test("No options, absolute", function() {
el = $("#draggable2").draggable(); el = $("#draggable2").draggable();
drag(el, 50, 50); drag(el, 50, 50);
moved(50, 50); moved(50, 50);
}); });
module("draggable: Options"); module("draggable: Options");
@ -230,7 +230,7 @@ test("{ cancel: 'span' }", function() {
el = $("#draggable2").draggable(); el = $("#draggable2").draggable();
drag("#draggable2 span", 50, 50); drag("#draggable2 span", 50, 50);
moved(50, 50); moved(50, 50);
el.draggable("destroy"); el.draggable("destroy");
el = $("#draggable2").draggable({ cancel: 'span' }); el = $("#draggable2").draggable({ cancel: 'span' });
@ -282,37 +282,37 @@ test("{ containment: 'parent' }, absolute", function() {
}); });
test("{ cursor: 'move' }", function() { test("{ cursor: 'move' }", function() {
function getCursor() { return $("body").css("cursor"); } function getCursor() { return $("body").css("cursor"); }
expect(2); expect(2);
var expected = "move", actual, before, after; var expected = "move", actual, before, after;
el = $("#draggable2").draggable({ el = $("#draggable2").draggable({
cursor: expected, cursor: expected,
start: function(event, ui) { start: function(event, ui) {
actual = getCursor(); actual = getCursor();
} }
}); });
before = getCursor(); before = getCursor();
drag("#draggable2", -1, -1); drag("#draggable2", -1, -1);
after = getCursor(); after = getCursor();
equals(actual, expected, "start callback: cursor '" + expected + "'"); equals(actual, expected, "start callback: cursor '" + expected + "'");
equals(after, before, "after drag: cursor restored"); equals(after, before, "after drag: cursor restored");
}); });
test("{ cursorAt: { left: -5, top: -5 } }", function() { test("{ cursorAt: { left: -5, top: -5 } }", function() {
expect(4); expect(4);
var dx = -3, dy = -3; var dx = -3, dy = -3;
var ox = 5, oy = 5; var ox = 5, oy = 5;
var cax = -5, cay = -5; var cax = -5, cay = -5;
var actual = null; var actual = null;
$("#draggable2").draggable({ $("#draggable2").draggable({
cursorAt: { left: cax, top: cay }, cursorAt: { left: cax, top: cay },
@ -321,7 +321,7 @@ test("{ cursorAt: { left: -5, top: -5 } }", function() {
} }
}); });
var el = $("#draggable2").data("draggable").element; var el = $("#draggable2").data("draggable").element;
var before = el.offset(); var before = el.offset();
var pos = { clientX: before.left + ox, clientY: before.top + oy }; var pos = { clientX: before.left + ox, clientY: before.top + oy };
$("#draggable2").simulate("mousedown", pos); $("#draggable2").simulate("mousedown", pos);
@ -333,10 +333,10 @@ test("{ cursorAt: { left: -5, top: -5 } }", function() {
left: before.left + ox - cax + dx, left: before.left + ox - cax + dx,
top: before.top + oy - cay + dy top: before.top + oy - cay + dy
}; };
equals(actual.left, expected.left, "Absolute: -1px left"); equals(actual.left, expected.left, "Absolute: -1px left");
equals(actual.top, expected.top, "Absolute: -1px top"); equals(actual.top, expected.top, "Absolute: -1px top");
var actual = null; var actual = null;
$("#draggable1").draggable({ $("#draggable1").draggable({
cursorAt: { left: cax, top: cay }, cursorAt: { left: cax, top: cay },
@ -345,7 +345,7 @@ test("{ cursorAt: { left: -5, top: -5 } }", function() {
} }
}); });
var el = $("#draggable2").data("draggable").element; var el = $("#draggable2").data("draggable").element;
var before = el.offset(); var before = el.offset();
var pos = { clientX: before.left + ox, clientY: before.top + oy }; var pos = { clientX: before.left + ox, clientY: before.top + oy };
$("#draggable2").simulate("mousedown", pos); $("#draggable2").simulate("mousedown", pos);
@ -357,10 +357,10 @@ test("{ cursorAt: { left: -5, top: -5 } }", function() {
left: before.left + ox - cax + dx, left: before.left + ox - cax + dx,
top: before.top + oy - cay + dy top: before.top + oy - cay + dy
}; };
equals(actual.left, expected.left, "Relative: -1px left"); equals(actual.left, expected.left, "Relative: -1px left");
equals(actual.top, expected.top, "Relative: -1px top"); equals(actual.top, expected.top, "Relative: -1px top");
}); });
test("{ distance: 10 }", function() { test("{ distance: 10 }", function() {
@ -374,7 +374,7 @@ test("{ distance: 10 }", function() {
drag(el, 9, 9); drag(el, 9, 9);
moved(0, 0, 'distance not met'); moved(0, 0, 'distance not met');
}); });
test("{ grid: [50, 50] }, relative", function() { test("{ grid: [50, 50] }, relative", function() {
@ -412,13 +412,13 @@ test("{ helper: 'clone' }, relative", function() {
test("{ helper: 'clone' }, absolute", function() { test("{ helper: 'clone' }, absolute", function() {
el = $("#draggable2").draggable({ helper: "clone" }); el = $("#draggable2").draggable({ helper: "clone" });
drag(el, 50, 50); drag(el, 50, 50);
moved(0, 0); moved(0, 0);
}); });
test("{ opacity: 0.5 }", function() { test("{ opacity: 0.5 }", function() {
expect(1); expect(1);
var opacity = null; var opacity = null;
el = $("#draggable2").draggable({ el = $("#draggable2").draggable({
opacity: 0.5, opacity: 0.5,
@ -426,19 +426,19 @@ test("{ opacity: 0.5 }", function() {
opacity = $(this).css("opacity"); opacity = $(this).css("opacity");
} }
}); });
drag("#draggable2", -1, -1); drag("#draggable2", -1, -1);
equals(opacity, 0.5, "start callback: opacity is"); equals(opacity, 0.5, "start callback: opacity is");
}); });
test("{ zIndex: 10 }", function() { test("{ zIndex: 10 }", function() {
expect(1); expect(1);
var expected = 10, actual; var expected = 10, actual;
var zIndex = null; var zIndex = null;
el = $("#draggable2").draggable({ el = $("#draggable2").draggable({
zIndex: expected, zIndex: expected,
@ -446,32 +446,32 @@ test("{ zIndex: 10 }", function() {
actual = $(this).css("zIndex"); actual = $(this).css("zIndex");
} }
}); });
drag("#draggable2", -1, -1); drag("#draggable2", -1, -1);
equals(actual, expected, "start callback: zIndex is"); equals(actual, expected, "start callback: zIndex is");
}); });
module("draggable: Callbacks"); module("draggable: Callbacks");
test("callbacks occurance count", function() { test("callbacks occurance count", function() {
expect(3); expect(3);
var start = 0, stop = 0, dragc = 0; var start = 0, stop = 0, dragc = 0;
el = $("#draggable2").draggable({ el = $("#draggable2").draggable({
start: function() { start++; }, start: function() { start++; },
drag: function() { dragc++; }, drag: function() { dragc++; },
stop: function() { stop++; } stop: function() { stop++; }
}); });
drag(el, 10, 10); drag(el, 10, 10);
equals(start, 1, "start callback should happen exactly once"); equals(start, 1, "start callback should happen exactly once");
equals(dragc, 3 + 1, "drag callback should happen exactly once per mousemove + 1"); equals(dragc, 3 + 1, "drag callback should happen exactly once per mousemove + 1");
equals(stop, 1, "stop callback should happen exactly once"); equals(stop, 1, "stop callback should happen exactly once");
}); });
module("draggable: Scroll offsets"); module("draggable: Scroll offsets");
@ -538,7 +538,7 @@ if(!($.browser.msie && $.browser.version < 7)) {
moved(50, 50); moved(50, 50);
$("#main")[0].scrollTop = 0; $("#main")[0].scrollTop = 0;
}); });
test("{ helper: 'original' }, fixed, with scroll offset on root", function() { test("{ helper: 'original' }, fixed, with scroll offset on root", function() {
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" }); el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
$(document).scrollTop(100); $(document).scrollTop(100);
@ -546,7 +546,7 @@ if(!($.browser.msie && $.browser.version < 7)) {
moved(50, 50); moved(50, 50);
$(document).scrollTop(0); $(document).scrollTop(0);
}); });
test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" }); el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
$(document).scrollTop(100); $(document).scrollTop(100);
@ -562,67 +562,67 @@ if(!($.browser.msie && $.browser.version < 7)) {
test("{ helper: 'clone' }, absolute", function() { test("{ helper: 'clone' }, absolute", function() {
var helperOffset = null; var helperOffset = null;
var origOffset = $("#draggable1").offset(); var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset(); helperOffset = ui.helper.offset();
} }); } });
drag(el, 1, 1); drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
}); });
test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
$("#main")[0].scrollTop = 100; $("#main")[0].scrollTop = 100;
var helperOffset = null; var helperOffset = null;
var origOffset = $("#draggable1").offset(); var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset(); helperOffset = ui.helper.offset();
} }); } });
drag(el, 1, 1); drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main")[0].scrollTop = 0; $("#main")[0].scrollTop = 0;
}); });
test("{ helper: 'clone' }, absolute with scroll offset on root", function() { test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
$(document).scrollTop(100); $(document).scrollTop(100);
var helperOffset = null; var helperOffset = null;
var origOffset = $("#draggable1").offset(); var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset(); helperOffset = ui.helper.offset();
} }); } });
drag(el, 1, 1); drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$(document).scrollTop(0); $(document).scrollTop(0);
}); });
test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() { test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
$(document).scrollTop(100); $(document).scrollTop(100);
$("#main")[0].scrollTop = 100; $("#main")[0].scrollTop = 100;
var helperOffset = null; var helperOffset = null;
var origOffset = $("#draggable1").offset(); var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset(); helperOffset = ui.helper.offset();
} }); } });
drag(el, 1, 1); drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$(document).scrollTop(0); $(document).scrollTop(0);
$("#main")[0].scrollTop = 0; $("#main")[0].scrollTop = 0;
@ -641,9 +641,9 @@ module("draggable: Tickets");
/* This needs to be rewritten /* This needs to be rewritten
test("#2965 cursorAt with margin", function() { test("#2965 cursorAt with margin", function() {
expect(2); expect(2);
var ox = 0, oy = 0; var ox = 0, oy = 0;
var actual, expected; var actual, expected;
@ -654,7 +654,7 @@ test("#2965 cursorAt with margin", function() {
} }
}); });
var el = $("#draggable2").data("draggable").element; var el = $("#draggable2").data("draggable").element;
$("#draggable2").css('margin', '0px !important'); $("#draggable2").css('margin', '0px !important');
var before = el.offset(); var before = el.offset();
@ -675,10 +675,10 @@ test("#2965 cursorAt with margin", function() {
$(document).simulate("mousemove", { clientX: pos.clientX + 1, clientY: pos.clientY + 1}); $(document).simulate("mousemove", { clientX: pos.clientX + 1, clientY: pos.clientY + 1});
$(document).simulate("mousemove", pos); $(document).simulate("mousemove", pos);
$("#draggable2").simulate("mouseup", pos); $("#draggable2").simulate("mouseup", pos);
equals(actual.left, expected.left, "10px margin. left"); equals(actual.left, expected.left, "10px margin. left");
equals(actual.top, expected.top, "10px margin. top"); equals(actual.top, expected.top, "10px margin. top");
}); });
*/ */

View File

@ -4,7 +4,7 @@
<title>jQuery UI Droppable Test Suite</title> <title>jQuery UI Droppable Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.draggable.js"></script> <script type="text/javascript" src="../ui/ui.draggable.js"></script>
@ -12,7 +12,7 @@
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="droppable.js"></script> <script type="text/javascript" src="droppable.js"></script>
<style type="text/css"> <style type="text/css">

View File

@ -55,7 +55,7 @@ test("init", function() {
test("destroy", function() { test("destroy", function() {
expect(6); expect(6);
$("<div></div>").appendTo('body').droppable().droppable("destroy").remove(); $("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
ok(true, '.droppable("destroy") called on element'); ok(true, '.droppable("destroy") called on element');
$([]).droppable().droppable("destroy"); $([]).droppable().droppable("destroy");

View File

@ -4,14 +4,14 @@
<title>jQuery UI Progressbar Test Suite</title> <title>jQuery UI Progressbar Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.progressbar.js"></script> <script type="text/javascript" src="../ui/ui.progressbar.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="progressbar.js"></script> <script type="text/javascript" src="progressbar.js"></script>
<style type="text/css"> <style type="text/css">
@ -34,6 +34,6 @@
<div id="main" style="position:absolute;top:-20000px"> <div id="main" style="position:absolute;top:-20000px">
<div id="progressbar"></div> <div id="progressbar"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -31,7 +31,7 @@ test("init", function() {
test("destroy", function() { test("destroy", function() {
expect(1); expect(1);
$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove(); $("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove();
ok(true, '.progressbar("destroy") called on element'); ok(true, '.progressbar("destroy") called on element');
}); });

View File

@ -4,14 +4,14 @@
<title>jQuery UI Resizable Test Suite</title> <title>jQuery UI Resizable Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.resizable.js"></script> <script type="text/javascript" src="../ui/ui.resizable.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="resizable.js"></script> <script type="text/javascript" src="resizable.js"></script>
<style type="text/css"> <style type="text/css">

View File

@ -35,10 +35,10 @@ var defaults = {
}; };
var drag = function(el, dx, dy, complete) { var drag = function(el, dx, dy, complete) {
// speed = sync -> Drag syncrhonously. // speed = sync -> Drag syncrhonously.
// speed = fast|slow -> Drag asyncrhonously - animated. // speed = fast|slow -> Drag asyncrhonously - animated.
//this mouseover is to work around a limitation in resizable //this mouseover is to work around a limitation in resizable
//TODO: fix resizable so handle doesn't require mouseover in order to be used //TODO: fix resizable so handle doesn't require mouseover in order to be used
$(el).simulate("mouseover"); $(el).simulate("mouseover");
@ -127,7 +127,7 @@ test("defaults", function() {
test("n", function() { test("n", function() {
expect(2); expect(2);
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 0, -50); drag(handle, 0, -50);
@ -139,7 +139,7 @@ test("n", function() {
test("s", function() { test("s", function() {
expect(2); expect(2);
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 0, 50); drag(handle, 0, 50);
@ -151,7 +151,7 @@ test("s", function() {
test("e", function() { test("e", function() {
expect(2); expect(2);
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 50); drag(handle, 50);
@ -163,7 +163,7 @@ test("e", function() {
test("w", function() { test("w", function() {
expect(2); expect(2);
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50); drag(handle, -50);
@ -175,7 +175,7 @@ test("w", function() {
test("ne", function() { test("ne", function() {
expect(4); expect(4);
var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' }); var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' });
drag(handle, -50, -50); drag(handle, -50, -50);
@ -189,7 +189,7 @@ test("ne", function() {
test("se", function() { test("se", function() {
expect(4); expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 50, 50); drag(handle, 50, 50);
@ -203,7 +203,7 @@ test("se", function() {
test("sw", function() { test("sw", function() {
expect(4); expect(4);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50, -50); drag(handle, -50, -50);
@ -217,7 +217,7 @@ test("sw", function() {
test("nw", function() { test("nw", function() {
expect(4); expect(4);
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' }); var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50, -50); drag(handle, -50, -50);
@ -233,7 +233,7 @@ module("resizable: Options");
test("aspectRatio: 'preserve' (e)", function() { test("aspectRatio: 'preserve' (e)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80); drag(handle, 80);
@ -247,7 +247,7 @@ test("aspectRatio: 'preserve' (e)", function() {
test("aspectRatio: 'preserve' (w)", function() { test("aspectRatio: 'preserve' (w)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, -80); drag(handle, -80);
@ -261,7 +261,7 @@ test("aspectRatio: 'preserve' (w)", function() {
test("aspectRatio: 'preserve' (n)", function() { test("aspectRatio: 'preserve' (n)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 0, -80); drag(handle, 0, -80);
@ -275,7 +275,7 @@ test("aspectRatio: 'preserve' (n)", function() {
test("aspectRatio: 'preserve' (s)", function() { test("aspectRatio: 'preserve' (s)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 0, 80); drag(handle, 0, 80);
@ -289,7 +289,7 @@ test("aspectRatio: 'preserve' (s)", function() {
test("aspectRatio: 'preserve' (se)", function() { test("aspectRatio: 'preserve' (se)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80, 80); drag(handle, 80, 80);
@ -303,7 +303,7 @@ test("aspectRatio: 'preserve' (se)", function() {
test("aspectRatio: 'preserve' (sw)", function() { test("aspectRatio: 'preserve' (sw)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, -80, 80); drag(handle, -80, 80);
@ -317,7 +317,7 @@ test("aspectRatio: 'preserve' (sw)", function() {
test("aspectRatio: 'preserve' (ne)", function() { test("aspectRatio: 'preserve' (ne)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80, -80); drag(handle, 80, -80);
@ -331,7 +331,7 @@ test("aspectRatio: 'preserve' (ne)", function() {
test("grid", function() { test("grid", function() {
expect(4); expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] }); var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] });
drag(handle, 3, 9); drag(handle, 3, 9);
@ -345,13 +345,13 @@ test("grid", function() {
test("grid (wrapped)", function() { test("grid (wrapped)", function() {
expect(4); expect(4);
var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] }); var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] });
drag(handle, 3, 9); drag(handle, 3, 9);
equals( target.width(), 103, "compare width"); equals( target.width(), 103, "compare width");
equals( target.height(), 100, "compare height"); equals( target.height(), 100, "compare height");
drag(handle, 15, 11); drag(handle, 15, 11);
equals( target.width(), 118, "compare width"); equals( target.width(), 118, "compare width");
equals( target.height(), 120, "compare height"); equals( target.height(), 120, "compare height");
@ -361,11 +361,11 @@ test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
expect(4); expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, -50, -50); drag(handle, -50, -50);
equals( target.width(), 60, "compare minWidth" ); equals( target.width(), 60, "compare minWidth" );
equals( target.height(), 60, "compare minHeight" ); equals( target.height(), 60, "compare minHeight" );
drag(handle, 70, 70); drag(handle, 70, 70);
equals( target.width(), 100, "compare maxWidth" ); equals( target.width(), 100, "compare maxWidth" );
equals( target.height(), 100, "compare maxHeight" ); equals( target.height(), 100, "compare maxHeight" );
@ -373,13 +373,13 @@ test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect(4);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, 50, -50); drag(handle, 50, -50);
equals( target.width(), 60, "compare minWidth" ); equals( target.width(), 60, "compare minWidth" );
equals( target.height(), 60, "compare minHeight" ); equals( target.height(), 60, "compare minHeight" );
drag(handle, -70, 70); drag(handle, -70, 70);
equals( target.width(), 100, "compare maxWidth" ); equals( target.width(), 100, "compare maxWidth" );
equals( target.height(), 100, "compare maxHeight" ); equals( target.height(), 100, "compare maxHeight" );
@ -387,13 +387,13 @@ test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect(4);
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, -50, 50); drag(handle, -50, 50);
equals( target.width(), 60, "compare minWidth" ); equals( target.width(), 60, "compare minWidth" );
equals( target.height(), 60, "compare minHeight" ); equals( target.height(), 60, "compare minHeight" );
drag(handle, 70, -70); drag(handle, 70, -70);
equals( target.width(), 100, "compare maxWidth" ); equals( target.width(), 100, "compare maxWidth" );
equals( target.height(), 100, "compare maxHeight" ); equals( target.height(), 100, "compare maxHeight" );
@ -401,13 +401,13 @@ test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect(4);
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, 70, 70); drag(handle, 70, 70);
equals( target.width(), 60, "compare minWidth" ); equals( target.width(), 60, "compare minWidth" );
equals( target.height(), 60, "compare minHeight" ); equals( target.height(), 60, "compare minHeight" );
drag(handle, -70, -70); drag(handle, -70, -70);
equals( target.width(), 100, "compare maxWidth" ); equals( target.width(), 100, "compare maxWidth" );
equals( target.height(), 100, "compare maxHeight" ); equals( target.height(), 100, "compare maxHeight" );

View File

@ -5,16 +5,16 @@
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<!--link rel="stylesheet" href="../themes/flora/flora.selectable.css" type="text/css" media="screen"--> <!--link rel="stylesheet" href="../themes/flora/flora.selectable.css" type="text/css" media="screen"-->
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.selectable.js"></script> <script type="text/javascript" src="../ui/ui.selectable.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="selectable.js"></script> <script type="text/javascript" src="selectable.js"></script>
<style type="text/css"> <style type="text/css">
html { border: 0; } html { border: 0; }
</style> </style>

View File

@ -23,7 +23,7 @@ $.fn.extend({
$.simulate = function(el, type, options) { $.simulate = function(el, type, options) {
this.target = el; this.target = el;
this.options = options; this.options = options;
if (/^drag$/.test(type)) { if (/^drag$/.test(type)) {
this[type].apply(this, [this.target, options]); this[type].apply(this, [this.target, options]);
} else { } else {
@ -52,9 +52,9 @@ $.extend($.simulate.prototype, {
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
button: 0, relatedTarget: undefined button: 0, relatedTarget: undefined
}, options); }, options);
var relatedTarget = $(e.relatedTarget)[0]; var relatedTarget = $(e.relatedTarget)[0];
if ($.isFunction(document.createEvent)) { if ($.isFunction(document.createEvent)) {
evt = document.createEvent("MouseEvents"); evt = document.createEvent("MouseEvents");
evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail, evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail,
@ -70,12 +70,12 @@ $.extend($.simulate.prototype, {
}, },
keyboardEvent: function(type, options) { keyboardEvent: function(type, options) {
var evt; var evt;
var e = $.extend({ bubbles: true, cancelable: true, view: window, var e = $.extend({ bubbles: true, cancelable: true, view: window,
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
keyCode: 0, charCode: 0 keyCode: 0, charCode: 0
}, options); }, options);
if ($.isFunction(document.createEvent)) { if ($.isFunction(document.createEvent)) {
try { try {
evt = document.createEvent("KeyEvents"); evt = document.createEvent("KeyEvents");
@ -100,7 +100,7 @@ $.extend($.simulate.prototype, {
} }
return evt; return evt;
}, },
dispatchEvent: function(el, type, evt) { dispatchEvent: function(el, type, evt) {
if (el.dispatchEvent) { if (el.dispatchEvent) {
el.dispatchEvent(evt); el.dispatchEvent(evt);
@ -109,7 +109,7 @@ $.extend($.simulate.prototype, {
} }
return evt; return evt;
}, },
drag: function(el) { drag: function(el) {
var self = this, center = this.findCenter(this.target), var self = this, center = this.findCenter(this.target),
options = this.options, x = Math.floor(center.x), y = Math.floor(center.y), options = this.options, x = Math.floor(center.x), y = Math.floor(center.y),

View File

@ -4,14 +4,14 @@
<title>jQuery UI Slider Test Suite</title> <title>jQuery UI Slider Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.slider.js"></script> <script type="text/javascript" src="../ui/ui.slider.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="slider.js"></script> <script type="text/javascript" src="slider.js"></script>
<style type="text/css"> <style type="text/css">
@ -37,6 +37,6 @@
<div class="ui-slider-handle" style="position: absolute; height: 21px; left: 0px; bottom: 0px; width: 17px;"></div> <div class="ui-slider-handle" style="position: absolute; height: 21px; left: 0px; bottom: 0px; width: 17px;"></div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -54,24 +54,24 @@ module("slider");
test("init", function() { test("init", function() {
expect(6); expect(6);
$("<div></div>").appendTo('body').slider().remove(); $("<div></div>").appendTo('body').slider().remove();
ok(true, '.slider() called on element'); ok(true, '.slider() called on element');
$([]).slider().remove(); $([]).slider().remove();
ok(true, '.slider() called on empty collection'); ok(true, '.slider() called on empty collection');
$('<div></div>').slider().remove(); $('<div></div>').slider().remove();
ok(true, '.slider() called on disconnected DOMElement'); ok(true, '.slider() called on disconnected DOMElement');
$('<div></div>').slider().slider("foo").remove(); $('<div></div>').slider().slider("foo").remove();
ok(true, 'arbitrary method called after init'); ok(true, 'arbitrary method called after init');
el = $('<div></div>').slider(); el = $('<div></div>').slider();
var foo = el.data("foo.slider"); var foo = el.data("foo.slider");
el.remove(); el.remove();
ok(true, 'arbitrary option getter after init'); ok(true, 'arbitrary option getter after init');
$('<div></div>').slider().data("foo.slider", "bar").remove(); $('<div></div>').slider().data("foo.slider", "bar").remove();
ok(true, 'arbitrary option setter after init'); ok(true, 'arbitrary option setter after init');
}); });
@ -166,12 +166,12 @@ test("destroy and recreate", function() {
slider.slider("moveTo", "+=20"); slider.slider("moveTo", "+=20");
equals(slider.slider("value"), 20); equals(slider.slider("value"), 20);
slider.slider("destroy"); slider.slider("destroy");
slider.slider("moveTo", "+=30"); slider.slider("moveTo", "+=30");
ok(true, "nothing happens after slider is destroyed"); ok(true, "nothing happens after slider is destroyed");
slider.slider().slider("moveTo", "30"); slider.slider().slider("moveTo", "30");
equals(Math.round(slider.slider("value")), 30); equals(Math.round(slider.slider("value")), 30);
}) })

View File

@ -4,16 +4,16 @@
<title>jQuery UI Sortable Test Suite</title> <title>jQuery UI Sortable Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.sortable.js"></script> <script type="text/javascript" src="../ui/ui.sortable.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="sortable.js"></script> <script type="text/javascript" src="sortable.js"></script>
<style type="text/css"> <style type="text/css">
html { border: 0; } html { border: 0; }
#main { #main {

View File

@ -94,7 +94,7 @@ test("enable", function() {
el = $("#sortable").sortable({ disabled: true }); el = $("#sortable").sortable({ disabled: true });
sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })'); sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })');
el.sortable("enable"); el.sortable("enable");
equals(el.data("disabled.sortable"), false, "disabled.sortable getter"); equals(el.data("disabled.sortable"), false, "disabled.sortable getter");
@ -102,7 +102,7 @@ test("enable", function() {
el.sortable({ disabled: true }); el.sortable({ disabled: true });
el.data("disabled.sortable", false); el.data("disabled.sortable", false);
equals(el.data("disabled.sortable"), false, "disabled.sortable setter"); equals(el.data("disabled.sortable"), false, "disabled.sortable setter");
sort($("li", el)[0], 0, 40, 2, '.data("disabled.sortable", false)'); sort($("li", el)[0], 0, 40, 2, '.data("disabled.sortable", false)');
}); });
@ -133,12 +133,12 @@ test("defaults", function() {
}); });
test("#3019: Stop fires too early", function() { test("#3019: Stop fires too early", function() {
var helper = null; var helper = null;
el = $("#sortable").sortable({ stop: function(event, ui) { el = $("#sortable").sortable({ stop: function(event, ui) {
helper = ui.helper; helper = ui.helper;
}}); }});
sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable'); sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable');
equals(helper, null, "helper should be false"); equals(helper, null, "helper should be false");

View File

@ -4,14 +4,14 @@
<title>jQuery UI Spinner Test Suite</title> <title>jQuery UI Spinner Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.spinner.js"></script> <script type="text/javascript" src="../ui/ui.spinner.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script> <script type="text/javascript" src="simulate/jquery.simulate.js"></script>
<script type="text/javascript" src="spinner.js"></script> <script type="text/javascript" src="spinner.js"></script>
<style type="text/css"> <style type="text/css">
@ -34,6 +34,6 @@
<div id="main" style="position:absolute;top:-20000px"> <div id="main" style="position:absolute;top:-20000px">
<input type="text" id="spin" /> <input type="text" id="spin" />
</div> </div>
</body> </body>
</html> </html>

View File

@ -226,7 +226,7 @@ test("decimal options", function() {
el.simulate("keyup",{keyCode:$.simulate.VK_UP}); el.simulate("keyup",{keyCode:$.simulate.VK_UP});
equals(el.val(), "7.0", "keydown 11 times"); equals(el.val(), "7.0", "keydown 11 times");
}); });
test("spin without auto-incremental stepping", function() { test("spin without auto-incremental stepping", function() {
@ -344,7 +344,7 @@ test("currency formats", function() {
expect(8); expect(8);
// default // default
el = $("#spin").spinner({ currency: 'HK$', stepping: 1500.50, start: 1000 }); el = $("#spin").spinner({ currency: 'HK$', stepping: 1500.50, start: 1000 });
equals(el.val(), "HK$1,000.00", "Hong Kong Dollar"); equals(el.val(), "HK$1,000.00", "Hong Kong Dollar");
@ -355,7 +355,7 @@ test("currency formats", function() {
equals(el.val(), "HK$2,500.50", "Hong Kong Dollar step-up once"); equals(el.val(), "HK$2,500.50", "Hong Kong Dollar step-up once");
// space and comma // space and comma
el.spinner('destroy').val('').spinner({ currency: '$', group: ' ', point: '.', stepping: 1500.50, start: 1000 }); el.spinner('destroy').val('').spinner({ currency: '$', group: ' ', point: '.', stepping: 1500.50, start: 1000 });
equals(el.val(), "$1 000.00", "Australian Dollar"); equals(el.val(), "$1 000.00", "Australian Dollar");
@ -366,7 +366,7 @@ test("currency formats", function() {
equals(el.val(), "$2 500.50", "Australian Dollar step-up once"); equals(el.val(), "$2 500.50", "Australian Dollar step-up once");
// apos and point // apos and point
el.spinner('destroy').val('').spinner({ currency: 'Fr ', group: "'", point: '.', stepping: 1500.50, start: 1000 }); el.spinner('destroy').val('').spinner({ currency: 'Fr ', group: "'", point: '.', stepping: 1500.50, start: 1000 });
equals(el.val(), "Fr 1'000.00", "Swiss Franc"); equals(el.val(), "Fr 1'000.00", "Swiss Franc");
@ -375,9 +375,9 @@ test("currency formats", function() {
.simulate("keyup",{keyCode:$.simulate.VK_UP}); .simulate("keyup",{keyCode:$.simulate.VK_UP});
equals(el.val(), "Fr 2'500.50", "Swiss Franc step-up once"); equals(el.val(), "Fr 2'500.50", "Swiss Franc step-up once");
// point and comma // point and comma
el.spinner('destroy').val('').spinner({ currency: 'RUB', group: ".", point: ',', stepping: 1.5, start: 1000 }); el.spinner('destroy').val('').spinner({ currency: 'RUB', group: ".", point: ',', stepping: 1.5, start: 1000 });
equals(el.val(), "RUB1.000,00", "Russian Ruble"); equals(el.val(), "RUB1.000,00", "Russian Ruble");
@ -386,7 +386,7 @@ test("currency formats", function() {
.simulate("keyup",{keyCode:$.simulate.VK_UP}); .simulate("keyup",{keyCode:$.simulate.VK_UP});
equals(el.val(), "RUB1.001,50", "Russian Ruble step-up once"); equals(el.val(), "RUB1.001,50", "Russian Ruble step-up once");
}); });

View File

@ -33,7 +33,7 @@
<ol id="tests"></ol> <ol id="tests"></ol>
<div id="main" style="position:absolute;top:-20000px"> <div id="main" style="position:absolute;top:-20000px">
<div id="tabs1"> <div id="tabs1">
<ul> <ul>
<li><a href="#fragment-1">1</a></li> <li><a href="#fragment-1">1</a></li>
@ -52,7 +52,7 @@
<div id="colon:test"></div> <div id="colon:test"></div>
<div style="height: 300px;" id="inline-style"></div> <div style="height: 300px;" id="inline-style"></div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -37,7 +37,7 @@ function defer(defered, ms) {
setTimeout(function() { setTimeout(function() {
queue.shift()(); queue.shift()();
if (!queue.length) start(); if (!queue.length) start();
}, ms || 100); }, ms || 100);
} }
module('tabs'); module('tabs');
@ -47,17 +47,17 @@ module('tabs');
var el = $('#tabs1 > ul').tabs(); var el = $('#tabs1 > ul').tabs();
ok(true, '.tabs() called on element'); ok(true, '.tabs() called on element');
el.tabs('destroy').tabs({ selected: 1 }); el.tabs('destroy').tabs({ selected: 1 });
equals( el.data('selected.tabs'), 1, 'selected.tabs set' ); equals( el.data('selected.tabs'), 1, 'selected.tabs set' );
equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 1, 'second tab active'); equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 1, 'second tab active');
equals( $('div', '#tabs1').index( $('div.ui-tabs-hide', '#tabs1') ), 0, 'first panel should be hidden' ); equals( $('div', '#tabs1').index( $('div.ui-tabs-hide', '#tabs1') ), 0, 'first panel should be hidden' );
}); });
test('destroy', function() { test('destroy', function() {
expect(0); expect(0);
}); });
test("defaults", function() { test("defaults", function() {
@ -71,37 +71,37 @@ module('tabs');
test('add', function() { test('add', function() {
expect(0); expect(0);
}); });
test('remove', function() { test('remove', function() {
expect(0); expect(0);
}); });
test('enable', function() { test('enable', function() {
expect(0); expect(0);
}); });
test('disable', function() { test('disable', function() {
expect(0); expect(0);
}); });
test('select', function() { test('select', function() {
expect(0); expect(0);
}); });
test('load', function() { test('load', function() {
expect(0); expect(0);
}); });
test('url', function() { test('url', function() {
expect(0); expect(0);
}); });
@ -109,33 +109,33 @@ module('tabs: Options');
test('select: null', function() { test('select: null', function() {
expect(3); expect(3);
var el = $('#tabs1 > ul'); var el = $('#tabs1 > ul');
el.tabs({ selected: null }); el.tabs({ selected: null });
equals( el.data('selected.tabs'), null, 'option set' ); equals( el.data('selected.tabs'), null, 'option set' );
equals( $('li.ui-tabs-selected', el).length, 0, 'all tabs should be deselected' ); equals( $('li.ui-tabs-selected', el).length, 0, 'all tabs should be deselected' );
equals( $('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden' ); equals( $('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden' );
// TODO select == null with cookie // TODO select == null with cookie
// TODO select == null with select method // TODO select == null with select method
}); });
test('deselectable: true', function() { test('deselectable: true', function() {
expect(7); expect(7);
var el = $('#tabs1 > ul'); var el = $('#tabs1 > ul');
el.tabs({ deselectable: true }); el.tabs({ deselectable: true });
equals( el.data('deselectable.tabs'), true, 'option set' ); equals( el.data('deselectable.tabs'), true, 'option set' );
equals( $('li.ui-tabs-deselectable', el).length, 1, 'class "ui-tabs-deselectable" attached once'); equals( $('li.ui-tabs-deselectable', el).length, 1, 'class "ui-tabs-deselectable" attached once');
equals( $('li', el).index( $('li.ui-tabs-deselectable', el) ), 0, 'class "ui-tabs-deselectable" attached to first tab'); equals( $('li', el).index( $('li.ui-tabs-deselectable', el) ), 0, 'class "ui-tabs-deselectable" attached to first tab');
el.tabs('select', 1); el.tabs('select', 1);
equals( $('li.ui-tabs-deselectable', el).length, 1, 'class "ui-tabs-deselectable" attached once'); equals( $('li.ui-tabs-deselectable', el).length, 1, 'class "ui-tabs-deselectable" attached once');
equals( $('li', el).index( $('li.ui-tabs-deselectable', el) ), 1, 'class "ui-tabs-deselectable" attached to second tab'); equals( $('li', el).index( $('li.ui-tabs-deselectable', el) ), 1, 'class "ui-tabs-deselectable" attached to second tab');
el.tabs('select', 1); el.tabs('select', 1);
equals( $('li.ui-tabs-deselectable', el).length, 0, 'class "ui-tabs-deselectable" not attached'); equals( $('li.ui-tabs-deselectable', el).length, 0, 'class "ui-tabs-deselectable" not attached');
defer(function() { defer(function() {
@ -146,32 +146,32 @@ module('tabs: Options');
test('cookie', function() { test('cookie', function() {
expect(5); expect(5);
var el = $('#tabs1 > ul'); var el = $('#tabs1 > ul');
var cookieName = 'ui-tabs-' + $.data(el[0]); var cookieName = 'ui-tabs-' + $.data(el[0]);
$.cookie(cookieName, null); // blank state $.cookie(cookieName, null); // blank state
var cookie = function() { var cookie = function() {
return parseInt($.cookie(cookieName), 10); return parseInt($.cookie(cookieName), 10);
}; };
el.tabs({ cookie: {} }); el.tabs({ cookie: {} });
equals(cookie(), 0, 'initial cookie value, no cookie given'); equals(cookie(), 0, 'initial cookie value, no cookie given');
el.tabs('destroy'); el.tabs('destroy');
el.tabs({ selected: 1, cookie: {} }); el.tabs({ selected: 1, cookie: {} });
equals(cookie(), 1, 'initial cookie value, given selected'); equals(cookie(), 1, 'initial cookie value, given selected');
el.tabs('select', 2); el.tabs('select', 2);
equals(cookie(), 2, 'cookie value after tabs select'); equals(cookie(), 2, 'cookie value after tabs select');
el.tabs('destroy'); el.tabs('destroy');
$.cookie(cookieName, 1); $.cookie(cookieName, 1);
el.tabs({ cookie: {} }); el.tabs({ cookie: {} });
equals(cookie(), 1, 'initial cookie value, from existing cookie'); equals(cookie(), 1, 'initial cookie value, from existing cookie');
el.tabs('destroy'); el.tabs('destroy');
ok($.cookie(cookieName) === null, 'erase cookie after destroy'); ok($.cookie(cookieName) === null, 'erase cookie after destroy');
}); });
@ -183,42 +183,42 @@ module('tabs: Tickets');
var el = $('#tabs2 > ul').tabs(); var el = $('#tabs2 > ul').tabs();
ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' ); ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' );
ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' ); ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' );
el.tabs('select', 1).tabs('select', 0); el.tabs('select', 1).tabs('select', 0);
defer(function() { defer(function() {
ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' ); ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' );
ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' ); ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' );
}); });
}); });
test('panel containing inline style, #????', function() { test('panel containing inline style, #????', function() {
expect(3); expect(3);
var inlineStyle = function(property) { var inlineStyle = function(property) {
return $('#inline-style')[0].style[property]; return $('#inline-style')[0].style[property];
}; };
var expected = inlineStyle('height'); var expected = inlineStyle('height');
var el = $('#tabs2 > ul').tabs(); var el = $('#tabs2 > ul').tabs();
equals(inlineStyle('height'), expected, 'init should not remove inline style'); equals(inlineStyle('height'), expected, 'init should not remove inline style');
el.tabs('select', 1); el.tabs('select', 1);
defer(function() { defer(function() {
equals(inlineStyle('height'), expected, 'show tab should not remove inline style'); equals(inlineStyle('height'), expected, 'show tab should not remove inline style');
el.tabs('select', 0); el.tabs('select', 0);
defer(function() { defer(function() {
equals(inlineStyle('height'), expected, 'hide tab should not remove inline style'); equals(inlineStyle('height'), expected, 'hide tab should not remove inline style');
}); });
}); });
}); });
// test('', function() { // test('', function() {
// expect(0); // expect(0);
// //
// }); // });
})(jQuery); })(jQuery);

View File

@ -2,9 +2,9 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Test Suite</title> <title>jQuery UI Test Suite</title>
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen"> <link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
<script type="text/javascript" src="../jquery-1.2.6.js"></script> <script type="text/javascript" src="../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../ui/ui.core.js"></script> <script type="text/javascript" src="../ui/ui.core.js"></script>
<script type="text/javascript" src="../ui/ui.accordion.js"></script> <script type="text/javascript" src="../ui/ui.accordion.js"></script>
@ -19,10 +19,10 @@
<script type="text/javascript" src="../ui/ui.sortable.js"></script> <script type="text/javascript" src="../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../ui/ui.spinner.js"></script> <script type="text/javascript" src="../ui/ui.spinner.js"></script>
<script type="text/javascript" src="../ui/ui.tabs.js"></script> <script type="text/javascript" src="../ui/ui.tabs.js"></script>
<script type="text/javascript" src="qunit/testrunner.js"></script> <script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="ui.js"></script> <script type="text/javascript" src="ui.js"></script>
</head> </head>
<body class="flora"> <body class="flora">

View File

@ -4,10 +4,10 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Effects Test Suite</title> <title>Effects Test Suite</title>
<link rel="stylesheet" href="effects.all.css" type="text/css" media="screen" title="no title" charset="utf-8" /> <link rel="stylesheet" href="effects.all.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<script type="text/javascript" src="../../jquery-1.2.6.js"></script> <script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/effects.core.js"></script> <script type="text/javascript" src="../../ui/effects.core.js"></script>
<script type="text/javascript" src="../../ui/effects.blind.js"></script> <script type="text/javascript" src="../../ui/effects.blind.js"></script>
<script type="text/javascript" src="../../ui/effects.bounce.js"></script> <script type="text/javascript" src="../../ui/effects.bounce.js"></script>
<script type="text/javascript" src="../../ui/effects.clip.js"></script> <script type="text/javascript" src="../../ui/effects.clip.js"></script>
@ -20,7 +20,7 @@
<script type="text/javascript" src="../../ui/effects.shake.js"></script> <script type="text/javascript" src="../../ui/effects.shake.js"></script>
<script type="text/javascript" src="../../ui/effects.slide.js"></script> <script type="text/javascript" src="../../ui/effects.slide.js"></script>
<script type="text/javascript" src="../../ui/effects.transfer.js"></script> <script type="text/javascript" src="../../ui/effects.transfer.js"></script>
<script type="text/javascript" src="effects.all.js"></script> <script type="text/javascript" src="effects.all.js"></script>
</head> </head>
<body> <body>
@ -38,121 +38,121 @@
<p>Blind vertically</p> <p>Blind vertically</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="bounce3times"> <div class="effect" id="bounce3times">
<p>Bounce 3 times</p> <p>Bounce 3 times</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="clipHorizontally"> <div class="effect" id="clipHorizontally">
<p>Clip horizontally</p> <p>Clip horizontally</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="clipVertically"> <div class="effect" id="clipVertically">
<p>Clip vertically</p> <p>Clip vertically</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropDown"> <div class="effect" id="dropDown">
<p>Drop down</p> <p>Drop down</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropUp"> <div class="effect" id="dropUp">
<p>Drop up</p> <p>Drop up</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropLeft"> <div class="effect" id="dropLeft">
<p>Drop left</p> <p>Drop left</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="dropRight"> <div class="effect" id="dropRight">
<p>Drop right</p> <p>Drop right</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="explode9"> <div class="effect" id="explode9">
<p>Explode in 9 pieces</p> <p>Explode in 9 pieces</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="explode36"> <div class="effect" id="explode36">
<p>Explode in 36 pieces</p> <p>Explode in 36 pieces</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="fold"> <div class="effect" id="fold">
<p>Fold</p> <p>Fold</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="highlight"> <div class="effect" id="highlight">
<p>Highlight</p> <p>Highlight</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="pulsate"> <div class="effect" id="pulsate">
<p>Pulsate 2 times</p> <p>Pulsate 2 times</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="puff"> <div class="effect" id="puff">
<p>Puff</p> <p>Puff</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="scale"> <div class="effect" id="scale">
<p>Scale</p> <p>Scale</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="shake"> <div class="effect" id="shake">
<p>Shake</p> <p>Shake</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideDown"> <div class="effect" id="slideDown">
<p>Slide down</p> <p>Slide down</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideUp"> <div class="effect" id="slideUp">
<p>Slide up</p> <p>Slide up</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideLeft"> <div class="effect" id="slideLeft">
<p>Slide left</p> <p>Slide left</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="slideRight"> <div class="effect" id="slideRight">
<p>Slide right</p> <p>Slide right</p>
</div> </div>
</li> </li>
<li> <li>
<div class="effect" id="transfer"> <div class="effect" id="transfer">
<p>Transfer to first element</p> <p>Transfer to first element</p>

View File

@ -1,5 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$("div.effect") $("div.effect")
.hover(function() { .hover(function() {
$(this).addClass("hover"); $(this).addClass("hover");
@ -7,16 +7,16 @@ $(document).ready(function() {
$(this).removeClass("hover"); $(this).removeClass("hover");
}) })
; ;
var effect = function(el, n, o) { var effect = function(el, n, o) {
$.extend(o, { $.extend(o, {
easing: "easeOutQuint" easing: "easeOutQuint"
}); });
$(el).bind("click", function() { $(el).bind("click", function() {
$(this).addClass("current").hide(n, o, 1000, function() { $(this).addClass("current").hide(n, o, 1000, function() {
var self = this; var self = this;
window.setTimeout(function() { window.setTimeout(function() {
@ -24,42 +24,42 @@ $(document).ready(function() {
},500); },500);
}); });
}); });
}; };
effect("#blindHorizontally", "blind", { direction: "horizontal" }); effect("#blindHorizontally", "blind", { direction: "horizontal" });
effect("#blindVertically", "blind", { direction: "vertical" }); effect("#blindVertically", "blind", { direction: "vertical" });
effect("#bounce3times", "bounce", { times: 3 }); effect("#bounce3times", "bounce", { times: 3 });
effect("#clipHorizontally", "clip", { direction: "horizontal" }); effect("#clipHorizontally", "clip", { direction: "horizontal" });
effect("#clipVertically", "clip", { direction: "vertical" }); effect("#clipVertically", "clip", { direction: "vertical" });
effect("#dropDown", "drop", { direction: "down" }); effect("#dropDown", "drop", { direction: "down" });
effect("#dropUp", "drop", { direction: "up" }); effect("#dropUp", "drop", { direction: "up" });
effect("#dropLeft", "drop", { direction: "left" }); effect("#dropLeft", "drop", { direction: "left" });
effect("#dropRight", "drop", { direction: "right" }); effect("#dropRight", "drop", { direction: "right" });
effect("#explode9", "explode", { }); effect("#explode9", "explode", { });
effect("#explode36", "explode", { pieces: 36 }); effect("#explode36", "explode", { pieces: 36 });
effect("#fold", "fold", { size: 50 }); effect("#fold", "fold", { size: 50 });
effect("#highlight", "highlight", { }); effect("#highlight", "highlight", { });
effect("#pulsate", "pulsate", { times: 2 }); effect("#pulsate", "pulsate", { times: 2 });
effect("#puff", "puff", { times: 2 }); effect("#puff", "puff", { times: 2 });
effect("#scale", "scale", { }); effect("#scale", "scale", { });
$("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); }); $("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); });
effect("#slideDown", "slide", { direction: "down" }); effect("#slideDown", "slide", { direction: "down" });
effect("#slideUp", "slide", { direction: "up" }); effect("#slideUp", "slide", { direction: "up" });
effect("#slideLeft", "slide", { direction: "left" }); effect("#slideLeft", "slide", { direction: "left" });
effect("#slideRight", "slide", { direction: "right" }); effect("#slideRight", "slide", { direction: "right" });
$("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); }); $("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); });
}); });

View File

@ -6,11 +6,11 @@
<script type="text/javascript" src="../../ui/ui.core.js"></script> <script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.sortable.js"></script> <script type="text/javascript" src="../../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../../ui/ui.draggable.js"></script> <script type="text/javascript" src="../../ui/ui.draggable.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready( function() { $(document).ready( function() {
$('ul').not(".draggable").sortable({ items: "li" }); $('ul').not(".draggable").sortable({ items: "li" });
$("ul.draggable li").draggable({ helper: "clone", connectToSortable: "ul" }); $("ul.draggable li").draggable({ helper: "clone", connectToSortable: "ul" });

View File

@ -20,7 +20,7 @@ $(function(){
} }
}; };
} }
var itemList = [ var itemList = [
{url: "http://ejohn.org", title: "John Resig"}, {url: "http://ejohn.org", title: "John Resig"},
{url: "http://bassistance.de/", title: "J&ouml;rn Zaefferer"}, {url: "http://bassistance.de/", title: "J&ouml;rn Zaefferer"},
@ -36,7 +36,7 @@ $(function(){
{url: "http://www.codylindley.com/", title: "Cody Lindley"}, {url: "http://www.codylindley.com/", title: "Cody Lindley"},
{url: "http://malsup.com/jquery/", title: "Mike Alsup"} {url: "http://malsup.com/jquery/", title: "Mike Alsup"}
]; ];
var opts = { var opts = {
's1': {}, 's1': {},
's2': {stepping: 0.25}, 's2': {stepping: 0.25},
@ -52,7 +52,7 @@ $(function(){
ui.add('<a href="'+ itemList[i].url +'" target="_blank">'+ itemList[i].title +'</a>'); ui.add('<a href="'+ itemList[i].url +'" target="_blank">'+ itemList[i].title +'</a>');
} }
}, },
// method 2: use the format and items options in combination // method 2: use the format and items options in combination
format: '%(title) <a href="%(url)" target="_blank">&raquo;</a>', format: '%(title) <a href="%(url)" target="_blank">&raquo;</a>',
items: itemList items: itemList

View File

@ -23,7 +23,7 @@ $("ul.sortable").tree({
}); });
}); });
</script> </script>

View File

@ -18,18 +18,18 @@ $.effects.blind = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left']; var el = $(this), props = ['position','top','left'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
var direction = o.options.direction || 'vertical'; // Default direction var direction = o.options.direction || 'vertical'; // Default direction
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
var ref = (direction == 'vertical') ? 'height' : 'width'; var ref = (direction == 'vertical') ? 'height' : 'width';
var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
if(mode == 'show') wrapper.css(ref, 0); // Shift if(mode == 'show') wrapper.css(ref, 0); // Shift
// Animation // Animation
var animation = {}; var animation = {};
animation[ref] = mode == 'show' ? distance : 0; animation[ref] = mode == 'show' ? distance : 0;
@ -41,9 +41,9 @@ $.effects.blind = function(o) {
if(o.callback) o.callback.apply(el[0], arguments); // Callback if(o.callback) o.callback.apply(el[0], arguments); // Callback
el.dequeue(); el.dequeue();
}); });
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -36,7 +36,7 @@ $.effects.bounce = function(o) {
if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
if (mode == 'hide') distance = distance / (times * 2); if (mode == 'hide') distance = distance / (times * 2);
if (mode != 'hide') times--; if (mode != 'hide') times--;
// Animate // Animate
if (mode == 'show') { // Show Bounce if (mode == 'show') { // Show Bounce
var animation = {opacity: 1}; var animation = {opacity: 1};
@ -72,7 +72,7 @@ $.effects.bounce = function(o) {
el.queue('fx', function() { el.dequeue(); }); el.queue('fx', function() { el.dequeue(); });
el.dequeue(); el.dequeue();
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,11 +18,11 @@ $.effects.clip = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left','height','width']; var el = $(this), props = ['position','top','left','height','width'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
var direction = o.options.direction || 'vertical'; // Default direction var direction = o.options.direction || 'vertical'; // Default direction
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
@ -33,12 +33,12 @@ $.effects.clip = function(o) {
}; };
var distance = (direction == 'vertical') ? animate.height() : animate.width(); var distance = (direction == 'vertical') ? animate.height() : animate.width();
if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
// Animation // Animation
var animation = {}; var animation = {};
animation[ref.size] = mode == 'show' ? distance : 0; animation[ref.size] = mode == 'show' ? distance : 0;
animation[ref.position] = mode == 'show' ? 0 : distance / 2; animation[ref.position] = mode == 'show' ? 0 : distance / 2;
// Animate // Animate
animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == 'hide') el.hide(); // Hide if(mode == 'hide') el.hide(); // Hide
@ -46,9 +46,9 @@ $.effects.clip = function(o) {
if(o.callback) o.callback.apply(el[0], arguments); // Callback if(o.callback) o.callback.apply(el[0], arguments); // Callback
el.dequeue(); el.dequeue();
}}); }});
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -300,7 +300,7 @@ var colors = {
yellow:[255,255,0], yellow:[255,255,0],
transparent: [255,255,255] transparent: [255,255,255]
}; };
/* /*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
* *

View File

@ -18,11 +18,11 @@ $.effects.drop = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left','opacity']; var el = $(this), props = ['position','top','left','opacity'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
var direction = o.options.direction || 'left'; // Default Direction var direction = o.options.direction || 'left'; // Default Direction
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
$.effects.createWrapper(el); // Create Wrapper $.effects.createWrapper(el); // Create Wrapper
@ -30,11 +30,11 @@ $.effects.drop = function(o) {
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2); var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
// Animation // Animation
var animation = {opacity: mode == 'show' ? 1 : 0}; var animation = {opacity: mode == 'show' ? 1 : 0};
animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
// Animate // Animate
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == 'hide') el.hide(); // Hide if(mode == 'hide') el.hide(); // Hide
@ -42,9 +42,9 @@ $.effects.drop = function(o) {
if(o.callback) o.callback.apply(this, arguments); // Callback if(o.callback) o.callback.apply(this, arguments); // Callback
el.dequeue(); el.dequeue();
}}); }});
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,15 +18,15 @@ $.effects.explode = function(o) {
var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode; o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
var el = $(this).show().css('visibility', 'hidden'); var el = $(this).show().css('visibility', 'hidden');
var offset = el.offset(); var offset = el.offset();
//Substract the margins - not fixing the problem yet. //Substract the margins - not fixing the problem yet.
offset.top -= parseInt(el.css("marginTop")) || 0; offset.top -= parseInt(el.css("marginTop")) || 0;
offset.left -= parseInt(el.css("marginLeft")) || 0; offset.left -= parseInt(el.css("marginLeft")) || 0;
var width = el.outerWidth(true); var width = el.outerWidth(true);
var height = el.outerHeight(true); var height = el.outerHeight(true);
@ -62,18 +62,18 @@ $.effects.explode = function(o) {
// Set a timeout, to call the callback approx. when the other animations have finished // Set a timeout, to call the callback approx. when the other animations have finished
setTimeout(function() { setTimeout(function() {
o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide(); o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
if(o.callback) o.callback.apply(el[0]); // Callback if(o.callback) o.callback.apply(el[0]); // Callback
el.dequeue(); el.dequeue();
$('.effects-explode').remove(); $('.effects-explode').remove();
}, o.duration || 500); }, o.duration || 500);
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,12 +18,12 @@ $.effects.fold = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left']; var el = $(this), props = ['position','top','left'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
var size = o.options.size || 15; // Default fold size var size = o.options.size || 15; // Default fold size
var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
@ -33,12 +33,12 @@ $.effects.fold = function(o) {
var percent = /([0-9]+)%/.exec(size); var percent = /([0-9]+)%/.exec(size);
if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1]; if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1];
if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
// Animation // Animation
var animation1 = {}, animation2 = {}; var animation1 = {}, animation2 = {};
animation1[ref[0]] = mode == 'show' ? distance[0] : size; animation1[ref[0]] = mode == 'show' ? distance[0] : size;
animation2[ref[1]] = mode == 'show' ? distance[1] : 0; animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
// Animate // Animate
wrapper.animate(animation1, o.duration / 2, o.options.easing) wrapper.animate(animation1, o.duration / 2, o.options.easing)
.animate(animation2, o.duration / 2, o.options.easing, function() { .animate(animation2, o.duration / 2, o.options.easing, function() {
@ -47,9 +47,9 @@ $.effects.fold = function(o) {
if(o.callback) o.callback.apply(el[0], arguments); // Callback if(o.callback) o.callback.apply(el[0], arguments); // Callback
el.dequeue(); el.dequeue();
}); });
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -15,23 +15,23 @@
$.effects.highlight = function(o) { $.effects.highlight = function(o) {
return this.queue(function() { return this.queue(function() {
// Create element // Create element
var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; var el = $(this), props = ['backgroundImage','backgroundColor','opacity'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
var color = o.options.color || "#ffff99"; // Default highlight color var color = o.options.color || "#ffff99"; // Default highlight color
var oldColor = el.css("backgroundColor"); var oldColor = el.css("backgroundColor");
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
el.css({backgroundImage: 'none', backgroundColor: color}); // Shift el.css({backgroundImage: 'none', backgroundColor: color}); // Shift
// Animation // Animation
var animation = {backgroundColor: oldColor }; var animation = {backgroundColor: oldColor };
if (mode == "hide") animation['opacity'] = 0; if (mode == "hide") animation['opacity'] = 0;
// Animate // Animate
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == "hide") el.hide(); if(mode == "hide") el.hide();
@ -40,9 +40,9 @@ $.effects.highlight = function(o) {
if(o.callback) o.callback.apply(this, arguments); if(o.callback) o.callback.apply(this, arguments);
el.dequeue(); el.dequeue();
}}); }});
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -15,14 +15,14 @@
$.effects.pulsate = function(o) { $.effects.pulsate = function(o) {
return this.queue(function() { return this.queue(function() {
// Create element // Create element
var el = $(this); var el = $(this);
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
var times = o.options.times || 5; // Default # of times var times = o.options.times || 5; // Default # of times
// Adjust // Adjust
if (mode == 'hide') times--; if (mode == 'hide') times--;
if (el.is(':hidden')) { // Show fadeIn if (el.is(':hidden')) { // Show fadeIn
@ -31,7 +31,7 @@ $.effects.pulsate = function(o) {
el.animate({opacity: 1}, o.duration / 2, o.options.easing); el.animate({opacity: 1}, o.duration / 2, o.options.easing);
times = times-2; times = times-2;
} }
// Animate // Animate
for (var i = 0; i < times; i++) { // Pulsate for (var i = 0; i < times; i++) { // Pulsate
el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing); el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing);
@ -49,7 +49,7 @@ $.effects.pulsate = function(o) {
el.queue('fx', function() { el.dequeue(); }); el.queue('fx', function() { el.dequeue(); });
el.dequeue(); el.dequeue();
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,34 +18,34 @@ $.effects.puff = function(o) {
// Create element // Create element
var el = $(this); var el = $(this);
// Set options // Set options
var options = $.extend(true, {}, o.options); var options = $.extend(true, {}, o.options);
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
var percent = parseInt(o.options.percent) || 150; // Set default puff percent var percent = parseInt(o.options.percent) || 150; // Set default puff percent
options.fade = true; // It's not a puff if it doesn't fade! :) options.fade = true; // It's not a puff if it doesn't fade! :)
var original = {height: el.height(), width: el.width()}; // Save original var original = {height: el.height(), width: el.width()}; // Save original
// Adjust // Adjust
var factor = percent / 100; var factor = percent / 100;
el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor}; el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};
// Animation // Animation
options.from = el.from; options.from = el.from;
options.percent = (mode == 'hide') ? percent : 100; options.percent = (mode == 'hide') ? percent : 100;
options.mode = mode; options.mode = mode;
// Animate // Animate
el.effect('scale', options, o.duration, o.callback); el.effect('scale', options, o.duration, o.callback);
el.dequeue(); el.dequeue();
}); });
}; };
$.effects.scale = function(o) { $.effects.scale = function(o) {
return this.queue(function() { return this.queue(function() {
// Create element // Create element
var el = $(this); var el = $(this);
@ -61,33 +61,33 @@ $.effects.scale = function(o) {
} }
var original = {height: el.height(), width: el.width()}; // Save original var original = {height: el.height(), width: el.width()}; // Save original
el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
// Adjust // Adjust
var factor = { // Set scaling factor var factor = { // Set scaling factor
y: direction != 'horizontal' ? (percent / 100) : 1, y: direction != 'horizontal' ? (percent / 100) : 1,
x: direction != 'vertical' ? (percent / 100) : 1 x: direction != 'vertical' ? (percent / 100) : 1
}; };
el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
if (o.options.fade) { // Fade option to support puff if (o.options.fade) { // Fade option to support puff
if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
}; };
// Animation // Animation
options.from = el.from; options.to = el.to; options.mode = mode; options.from = el.from; options.to = el.to; options.mode = mode;
// Animate // Animate
el.effect('size', options, o.duration, o.callback); el.effect('size', options, o.duration, o.callback);
el.dequeue(); el.dequeue();
}); });
}; };
$.effects.size = function(o) { $.effects.size = function(o) {
return this.queue(function() { return this.queue(function() {
// Create element // Create element
var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
var props1 = ['position','top','left','overflow','opacity']; // Always restore var props1 = ['position','top','left','overflow','opacity']; // Always restore
@ -95,7 +95,7 @@ $.effects.size = function(o) {
var cProps = ['fontSize']; var cProps = ['fontSize'];
var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
var restore = o.options.restore || false; // Default restore var restore = o.options.restore || false; // Default restore
@ -138,7 +138,7 @@ $.effects.size = function(o) {
$.effects.save(el, restore ? props : props1); el.show(); // Save & Show $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
$.effects.createWrapper(el); // Create Wrapper $.effects.createWrapper(el); // Create Wrapper
el.css('overflow','hidden').css(el.from); // Shift el.css('overflow','hidden').css(el.from); // Shift
// Animate // Animate
if (scale == 'content' || scale == 'both') { // Scale the children if (scale == 'content' || scale == 'both') { // Scale the children
vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
@ -164,7 +164,7 @@ $.effects.size = function(o) {
}); // Animate children }); // Animate children
}); });
}; };
// Animate // Animate
el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == 'hide') el.hide(); // Hide if(mode == 'hide') el.hide(); // Hide
@ -172,7 +172,7 @@ $.effects.size = function(o) {
if(o.callback) o.callback.apply(this, arguments); // Callback if(o.callback) o.callback.apply(this, arguments); // Callback
el.dequeue(); el.dequeue();
}}); }});
}); });
}; };

View File

@ -18,26 +18,26 @@ $.effects.shake = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left']; var el = $(this), props = ['position','top','left'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
var direction = o.options.direction || 'left'; // Default direction var direction = o.options.direction || 'left'; // Default direction
var distance = o.options.distance || 20; // Default distance var distance = o.options.distance || 20; // Default distance
var times = o.options.times || 3; // Default # of times var times = o.options.times || 3; // Default # of times
var speed = o.duration || o.options.duration || 140; // Default speed per shake var speed = o.duration || o.options.duration || 140; // Default speed per shake
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
$.effects.createWrapper(el); // Create Wrapper $.effects.createWrapper(el); // Create Wrapper
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
// Animation // Animation
var animation = {}, animation1 = {}, animation2 = {}; var animation = {}, animation1 = {}, animation2 = {};
animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2; animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2; animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
// Animate // Animate
el.animate(animation, speed, o.options.easing); el.animate(animation, speed, o.options.easing);
for (var i = 1; i < times; i++) { // Shakes for (var i = 1; i < times; i++) { // Shakes
@ -51,7 +51,7 @@ $.effects.shake = function(o) {
el.queue('fx', function() { el.dequeue(); }); el.queue('fx', function() { el.dequeue(); });
el.dequeue(); el.dequeue();
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,11 +18,11 @@ $.effects.slide = function(o) {
// Create element // Create element
var el = $(this), props = ['position','top','left']; var el = $(this), props = ['position','top','left'];
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
var direction = o.options.direction || 'left'; // Default Direction var direction = o.options.direction || 'left'; // Default Direction
// Adjust // Adjust
$.effects.save(el, props); el.show(); // Save & Show $.effects.save(el, props); el.show(); // Save & Show
$.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
@ -30,11 +30,11 @@ $.effects.slide = function(o) {
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true})); var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
// Animation // Animation
var animation = {}; var animation = {};
animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
// Animate // Animate
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == 'hide') el.hide(); // Hide if(mode == 'hide') el.hide(); // Hide
@ -42,9 +42,9 @@ $.effects.slide = function(o) {
if(o.callback) o.callback.apply(this, arguments); // Callback if(o.callback) o.callback.apply(this, arguments); // Callback
el.dequeue(); el.dequeue();
}}); }});
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -18,14 +18,14 @@ $.effects.transfer = function(o) {
// Create element // Create element
var el = $(this); var el = $(this);
// Set options // Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
var target = $(o.options.to); // Find Target var target = $(o.options.to); // Find Target
var position = el.offset(); var position = el.offset();
var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body); var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body);
if(o.options.className) transfer.addClass(o.options.className); if(o.options.className) transfer.addClass(o.options.className);
// Set target css // Set target css
transfer.addClass(o.options.className); transfer.addClass(o.options.className);
transfer.css({ transfer.css({
@ -35,7 +35,7 @@ $.effects.transfer = function(o) {
width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')), width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),
position: 'absolute' position: 'absolute'
}); });
// Animation // Animation
position = target.offset(); position = target.offset();
animation = { animation = {
@ -44,16 +44,16 @@ $.effects.transfer = function(o) {
height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')) width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth'))
}; };
// Animate // Animate
transfer.animate(animation, o.duration, o.options.easing, function() { transfer.animate(animation, o.duration, o.options.easing, function() {
transfer.remove(); // Remove div transfer.remove(); // Remove div
if(o.callback) o.callback.apply(el[0], arguments); // Callback if(o.callback) o.callback.apply(el[0], arguments); // Callback
el.dequeue(); el.dequeue();
}); });
}); });
}; };
})(jQuery); })(jQuery);

View File

@ -15,7 +15,7 @@
$.widget("ui.accordion", { $.widget("ui.accordion", {
_init: function() { _init: function() {
var options = this.options; var options = this.options;
if ( options.navigation ) { if ( options.navigation ) {
var current = this.element.find("a").filter(options.navigationFilter); var current = this.element.find("a").filter(options.navigationFilter);
if ( current.length ) { if ( current.length ) {
@ -27,23 +27,23 @@ $.widget("ui.accordion", {
} }
} }
} }
// calculate active if not specified, using the first header // calculate active if not specified, using the first header
options.headers = this.element.find(options.header); options.headers = this.element.find(options.header);
options.active = findActive(options.headers, options.active); options.active = findActive(options.headers, options.active);
// IE7-/Win - Extra vertical space in Lists fixed // IE7-/Win - Extra vertical space in Lists fixed
if ($.browser.msie) { if ($.browser.msie) {
this.element.find('a').css('zoom', '1'); this.element.find('a').css('zoom', '1');
} }
if (!this.element.hasClass("ui-accordion")) { if (!this.element.hasClass("ui-accordion")) {
this.element.addClass("ui-accordion"); this.element.addClass("ui-accordion");
$('<span class="ui-accordion-left"/>').insertBefore(options.headers); $('<span class="ui-accordion-left"/>').insertBefore(options.headers);
$('<span class="ui-accordion-right"/>').appendTo(options.headers); $('<span class="ui-accordion-right"/>').appendTo(options.headers);
options.headers.addClass("ui-accordion-header"); options.headers.addClass("ui-accordion-header");
} }
var maxHeight; var maxHeight;
if ( options.fillSpace ) { if ( options.fillSpace ) {
maxHeight = this.element.parent().height(); maxHeight = this.element.parent().height();
@ -60,7 +60,7 @@ $.widget("ui.accordion", {
maxHeight = Math.max(maxHeight, $(this).outerHeight()); maxHeight = Math.max(maxHeight, $(this).outerHeight());
}).height(maxHeight); }).height(maxHeight);
} }
this.element.attr('role','tablist'); this.element.attr('role','tablist');
var self=this; var self=this;
@ -69,14 +69,14 @@ $.widget("ui.accordion", {
.bind('keydown', function(event) { return self._keydown(event); }) .bind('keydown', function(event) { return self._keydown(event); })
.next() .next()
.attr('role','tabpanel'); .attr('role','tabpanel');
options.headers options.headers
.not(options.active || "") .not(options.active || "")
.attr('aria-expanded','false') .attr('aria-expanded','false')
.attr("tabIndex", "-1") .attr("tabIndex", "-1")
.next() .next()
.hide(); .hide();
// make sure at least one header is in the tab order // make sure at least one header is in the tab order
if (!options.active.length) { if (!options.active.length) {
options.headers.eq(0).attr('tabIndex','0'); options.headers.eq(0).attr('tabIndex','0');
@ -86,26 +86,26 @@ $.widget("ui.accordion", {
.attr("tabIndex", "0") .attr("tabIndex", "0")
.parent().andSelf().addClass(options.selectedClass); .parent().andSelf().addClass(options.selectedClass);
} }
// only need links in taborder for Safari // only need links in taborder for Safari
if (!$.browser.safari) if (!$.browser.safari)
options.headers.find('a').attr('tabIndex','-1'); options.headers.find('a').attr('tabIndex','-1');
if (options.event) { if (options.event) {
this.element.bind((options.event) + ".accordion", clickHandler); this.element.bind((options.event) + ".accordion", clickHandler);
} }
}, },
_keydown: function(event) { _keydown: function(event) {
if (this.options.disabled || event.altKey || event.ctrlKey) if (this.options.disabled || event.altKey || event.ctrlKey)
return; return;
var keyCode = $.keyCode; var keyCode = $.keyCode;
var length = this.options.headers.length; var length = this.options.headers.length;
var currentIndex = this.options.headers.index(event.target); var currentIndex = this.options.headers.index(event.target);
var toFocus = false; var toFocus = false;
switch(event.keyCode) { switch(event.keyCode) {
case keyCode.RIGHT: case keyCode.RIGHT:
case keyCode.DOWN: case keyCode.DOWN:
@ -119,7 +119,7 @@ $.widget("ui.accordion", {
case keyCode.ENTER: case keyCode.ENTER:
return clickHandler.call(this.element[0], { target: event.target }); return clickHandler.call(this.element[0], { target: event.target });
} }
if (toFocus) { if (toFocus) {
$(event.target).attr('tabIndex','-1'); $(event.target).attr('tabIndex','-1');
$(toFocus).attr('tabIndex','0'); $(toFocus).attr('tabIndex','0');
@ -129,14 +129,14 @@ $.widget("ui.accordion", {
return true; return true;
}, },
activate: function(index) { activate: function(index) {
// call clickHandler with custom event // call clickHandler with custom event
clickHandler.call(this.element[0], { clickHandler.call(this.element[0], {
target: findActive( this.options.headers, index )[0] target: findActive( this.options.headers, index )[0]
}); });
}, },
destroy: function() { destroy: function() {
this.options.headers.parent().andSelf().removeClass(this.options.selectedClass); this.options.headers.parent().andSelf().removeClass(this.options.selectedClass);
this.options.headers.prev(".ui-accordion-left").remove(); this.options.headers.prev(".ui-accordion-left").remove();
@ -146,7 +146,7 @@ $.widget("ui.accordion", {
this.options.headers.next().css("height", ""); this.options.headers.next().css("height", "");
} }
$.removeData(this.element[0], "accordion"); $.removeData(this.element[0], "accordion");
this.element.removeClass("ui-accordion").unbind(".accordion"); this.element.removeClass("ui-accordion").unbind(".accordion");
} }
}); });
@ -162,7 +162,7 @@ function completed(cancel) {
if (!$.data(this, "accordion")) { if (!$.data(this, "accordion")) {
return; return;
} }
var instance = $.data(this, "accordion"); var instance = $.data(this, "accordion");
var options = instance.options; var options = instance.options;
options.running = cancel ? 0 : --options.running; options.running = cancel ? 0 : --options.running;
@ -184,15 +184,15 @@ function toggle(toShow, toHide, data, clickedActive, down) {
options.toHide = toHide; options.toHide = toHide;
options.data = data; options.data = data;
var complete = scopeCallback(completed, this); var complete = scopeCallback(completed, this);
$.data(this, "accordion")._trigger("changestart", null, options.data); $.data(this, "accordion")._trigger("changestart", null, options.data);
// count elements to animate // count elements to animate
options.running = toHide.size() === 0 ? toShow.size() : toHide.size(); options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
if ( options.animated ) { if ( options.animated ) {
var animOptions = {}; var animOptions = {};
if ( !options.alwaysOpen && clickedActive ) { if ( !options.alwaysOpen && clickedActive ) {
animOptions = { animOptions = {
toShow: $([]), toShow: $([]),
@ -210,25 +210,25 @@ function toggle(toShow, toHide, data, clickedActive, down) {
autoHeight: options.autoHeight autoHeight: options.autoHeight
}; };
} }
if (!options.proxied) { if (!options.proxied) {
options.proxied = options.animated; options.proxied = options.animated;
} }
if (!options.proxiedDuration) { if (!options.proxiedDuration) {
options.proxiedDuration = options.duration; options.proxiedDuration = options.duration;
} }
options.animated = $.isFunction(options.proxied) ? options.animated = $.isFunction(options.proxied) ?
options.proxied(animOptions) : options.proxied; options.proxied(animOptions) : options.proxied;
options.duration = $.isFunction(options.proxiedDuration) ? options.duration = $.isFunction(options.proxiedDuration) ?
options.proxiedDuration(animOptions) : options.proxiedDuration; options.proxiedDuration(animOptions) : options.proxiedDuration;
var animations = $.ui.accordion.animations, var animations = $.ui.accordion.animations,
duration = options.duration, duration = options.duration,
easing = options.animated; easing = options.animated;
if (!animations[easing]) { if (!animations[easing]) {
animations[easing] = function(options) { animations[easing] = function(options) {
this.slide(options, { this.slide(options, {
@ -237,9 +237,9 @@ function toggle(toShow, toHide, data, clickedActive, down) {
}); });
}; };
} }
animations[easing](animOptions); animations[easing](animOptions);
} else { } else {
if ( !options.alwaysOpen && clickedActive ) { if ( !options.alwaysOpen && clickedActive ) {
toShow.toggle(); toShow.toggle();
@ -258,7 +258,7 @@ function clickHandler(event) {
if (options.disabled) { if (options.disabled) {
return false; return false;
} }
// called only when using activate(false) to close all parts programmatically // called only when using activate(false) to close all parts programmatically
if ( !event.target && !options.alwaysOpen ) { if ( !event.target && !options.alwaysOpen ) {
options.active.parent().andSelf().toggleClass(options.selectedClass); options.active.parent().andSelf().toggleClass(options.selectedClass);
@ -276,14 +276,14 @@ function clickHandler(event) {
} }
// get the click target // get the click target
var clicked = $(event.target); var clicked = $(event.target);
// due to the event delegation model, we have to check if one // due to the event delegation model, we have to check if one
// of the parent elements is our actual header, and find that // of the parent elements is our actual header, and find that
// otherwise stick with the initial target // otherwise stick with the initial target
clicked = $( clicked.parents(options.header)[0] || clicked ); clicked = $( clicked.parents(options.header)[0] || clicked );
var clickedActive = clicked[0] == options.active[0]; var clickedActive = clicked[0] == options.active[0];
// if animations are still active, or the active header is the target, ignore click // if animations are still active, or the active header is the target, ignore click
if (options.running || (options.alwaysOpen && clickedActive)) { if (options.running || (options.alwaysOpen && clickedActive)) {
return false; return false;
@ -291,13 +291,13 @@ function clickHandler(event) {
if (!clicked.is(options.header)) { if (!clicked.is(options.header)) {
return; return;
} }
// switch classes // switch classes
options.active.parent().andSelf().toggleClass(options.selectedClass); options.active.parent().andSelf().toggleClass(options.selectedClass);
if ( !clickedActive ) { if ( !clickedActive ) {
clicked.parent().andSelf().addClass(options.selectedClass); clicked.parent().andSelf().addClass(options.selectedClass);
} }
// find elements to show and hide // find elements to show and hide
var toShow = clicked.next(), var toShow = clicked.next(),
toHide = options.active.next(), toHide = options.active.next(),
@ -309,10 +309,10 @@ function clickHandler(event) {
oldContent: toHide oldContent: toHide
}, },
down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
options.active = clickedActive ? $([]) : clicked; options.active = clickedActive ? $([]) : clicked;
toggle.call(this, toShow, toHide, data, clickedActive, down ); toggle.call(this, toShow, toHide, data, clickedActive, down );
return false; return false;
}; };

View File

@ -45,9 +45,9 @@ var _remove = $.fn.remove,
//Helper functions and ui object //Helper functions and ui object
$.ui = { $.ui = {
version: "@VERSION", version: "@VERSION",
// $.ui.plugin is deprecated. Use the proxy pattern instead. // $.ui.plugin is deprecated. Use the proxy pattern instead.
plugin: { plugin: {
add: function(module, option, set) { add: function(module, option, set) {
@ -60,7 +60,7 @@ $.ui = {
call: function(instance, name, args) { call: function(instance, name, args) {
var set = instance.plugins[name]; var set = instance.plugins[name];
if(!set) { return; } if(!set) { return; }
for (var i = 0; i < set.length; i++) { for (var i = 0; i < set.length; i++) {
if (instance.options[set[i][0]]) { if (instance.options[set[i][0]]) {
set[i][1].apply(instance.element, args); set[i][1].apply(instance.element, args);
@ -68,7 +68,7 @@ $.ui = {
} }
} }
}, },
contains: function(a, b) { contains: function(a, b) {
var safari2 = $.browser.safari && $.browser.version < 522; var safari2 = $.browser.safari && $.browser.version < 522;
if (a.contains && !safari2) { if (a.contains && !safari2) {
@ -80,15 +80,15 @@ $.ui = {
if (b == a) return true; if (b == a) return true;
return false; return false;
}, },
cssCache: {}, cssCache: {},
css: function(name) { css: function(name) {
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
//if (!$.browser.safari) //if (!$.browser.safari)
//tmp.appendTo('body'); //tmp.appendTo('body');
//Opera and Safari set width and height to 0px instead of auto //Opera and Safari set width and height to 0px instead of auto
//Safari returns rgba(0,0,0,0) when bgcolor is not set //Safari returns rgba(0,0,0,0) when bgcolor is not set
$.ui.cssCache[name] = !!( $.ui.cssCache[name] = !!(
@ -100,15 +100,15 @@ $.ui = {
}, },
hasScroll: function(el, a) { hasScroll: function(el, a) {
//If overflow is hidden, the element might have extra content, but the user wants to hide it //If overflow is hidden, the element might have extra content, but the user wants to hide it
if ($(el).css('overflow') == 'hidden') { return false; } if ($(el).css('overflow') == 'hidden') { return false; }
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
has = false; has = false;
if (el[scroll] > 0) { return true; } if (el[scroll] > 0) { return true; }
// TODO: determine which cases actually cause this to happen // TODO: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to // if the element doesn't have the scroll set, see if it's possible to
// set the scroll // set the scroll
@ -117,17 +117,17 @@ $.ui = {
el[scroll] = 0; el[scroll] = 0;
return has; return has;
}, },
isOverHeight: function(y, top, height) { isOverHeight: function(y, top, height) {
//Determines when y coordinate is over "b" element height //Determines when y coordinate is over "b" element height
return (y > top) && (y < (top + height)); return (y > top) && (y < (top + height));
}, },
isOverWidth: function(x, left, width) { isOverWidth: function(x, left, width) {
//Determines when x coordinate is over "b" element width //Determines when x coordinate is over "b" element width
return (x > left) && (x < (left + width)); return (x > left) && (x < (left + width));
}, },
isOver: function(y, x, top, left, height, width) { isOver: function(y, x, top, left, height, width) {
//Determines when x, y coordinates is over "b" element //Determines when x, y coordinates is over "b" element
return $.ui.isOverHeight(y, top, height) && $.ui.isOverWidth(x, left, width); return $.ui.isOverHeight(y, top, height) && $.ui.isOverWidth(x, left, width);
@ -141,10 +141,10 @@ if (isFF2) {
ariaNS = "http://www.w3.org/2005/07/aaa", ariaNS = "http://www.w3.org/2005/07/aaa",
ariaState = /^aria-/, ariaState = /^aria-/,
ariaRole = /^wairole:/; ariaRole = /^wairole:/;
$.attr = function(elem, name, value) { $.attr = function(elem, name, value) {
var set = value !== undefined; var set = value !== undefined;
return (name == 'role' return (name == 'role'
? (set ? (set
? attr.call(this, elem, name, "wairole:" + value) ? attr.call(this, elem, name, "wairole:" + value)
@ -156,7 +156,7 @@ if (isFF2) {
: attr.call(this, elem, name.replace(ariaState, "aaa:"))) : attr.call(this, elem, name.replace(ariaState, "aaa:")))
: attr.apply(this, arguments))); : attr.apply(this, arguments)));
}; };
$.fn.removeAttr = function(name) { $.fn.removeAttr = function(name) {
return (ariaState.test(name) return (ariaState.test(name)
? this.each(function() { ? this.each(function() {
@ -167,7 +167,7 @@ if (isFF2) {
//jQuery plugins //jQuery plugins
$.fn.extend({ $.fn.extend({
remove: function() { remove: function() {
// Safari has a native remove event which actually removes DOM elements, // Safari has a native remove event which actually removes DOM elements,
// so we have to use triggerHandler instead of trigger (#3037). // so we have to use triggerHandler instead of trigger (#3037).
@ -176,65 +176,65 @@ $.fn.extend({
}); });
return _remove.apply(this, arguments ); return _remove.apply(this, arguments );
}, },
enableSelection: function() { enableSelection: function() {
return this return this
.attr('unselectable', 'off') .attr('unselectable', 'off')
.css('MozUserSelect', '') .css('MozUserSelect', '')
.unbind('selectstart.ui'); .unbind('selectstart.ui');
}, },
disableSelection: function() { disableSelection: function() {
return this return this
.attr('unselectable', 'on') .attr('unselectable', 'on')
.css('MozUserSelect', 'none') .css('MozUserSelect', 'none')
.bind('selectstart.ui', function() { return false; }); .bind('selectstart.ui', function() { return false; });
}, },
scrollParent: function() { scrollParent: function() {
return $(this).parents().filter(function() { return $(this).parents().filter(function() {
return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
}).eq(0); }).eq(0);
} }
}); });
//Additional selectors //Additional selectors
$.extend($.expr[':'], { $.extend($.expr[':'], {
data: function(a, i, m) { data: function(a, i, m) {
return $.data(a, m[3]); return $.data(a, m[3]);
}, },
// TODO: add support for object, area // TODO: add support for object, area
tabbable: function(a, i, m) { tabbable: function(a, i, m) {
var nodeName = a.nodeName.toLowerCase(); var nodeName = a.nodeName.toLowerCase();
function isVisible(element) { function isVisible(element) {
return !($(element).is(':hidden') || $(element).parents(':hidden').length); return !($(element).is(':hidden') || $(element).parents(':hidden').length);
} }
return ( return (
// in tab order // in tab order
a.tabIndex >= 0 && a.tabIndex >= 0 &&
( // filter node types that participate in the tab order ( // filter node types that participate in the tab order
// anchor tag // anchor tag
('a' == nodeName && a.href) || ('a' == nodeName && a.href) ||
// enabled form element // enabled form element
(/input|select|textarea|button/.test(nodeName) && (/input|select|textarea|button/.test(nodeName) &&
'hidden' != a.type && !a.disabled) 'hidden' != a.type && !a.disabled)
) && ) &&
// visible on page // visible on page
isVisible(a) isVisible(a)
); );
} }
}); });
@ -246,7 +246,7 @@ function getter(namespace, plugin, method, args) {
var methods = $[namespace][plugin][type] || []; var methods = $[namespace][plugin][type] || [];
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
} }
var methods = getMethods('getter'); var methods = getMethods('getter');
if (args.length == 1 && typeof args[0] == 'string') { if (args.length == 1 && typeof args[0] == 'string') {
methods = methods.concat(getMethods('getterSetter')); methods = methods.concat(getMethods('getterSetter'));
@ -257,53 +257,53 @@ function getter(namespace, plugin, method, args) {
$.widget = function(name, prototype) { $.widget = function(name, prototype) {
var namespace = name.split(".")[0]; var namespace = name.split(".")[0];
name = name.split(".")[1]; name = name.split(".")[1];
// create plugin method // create plugin method
$.fn[name] = function(options) { $.fn[name] = function(options) {
var isMethodCall = (typeof options == 'string'), var isMethodCall = (typeof options == 'string'),
args = Array.prototype.slice.call(arguments, 1); args = Array.prototype.slice.call(arguments, 1);
// prevent calls to internal methods // prevent calls to internal methods
if (isMethodCall && options.substring(0, 1) == '_') { if (isMethodCall && options.substring(0, 1) == '_') {
return this; return this;
} }
// handle getter methods // handle getter methods
if (isMethodCall && getter(namespace, name, options, args)) { if (isMethodCall && getter(namespace, name, options, args)) {
var instance = $.data(this[0], name); var instance = $.data(this[0], name);
return (instance ? instance[options].apply(instance, args) return (instance ? instance[options].apply(instance, args)
: undefined); : undefined);
} }
// handle initialization and non-getter methods // handle initialization and non-getter methods
return this.each(function() { return this.each(function() {
var instance = $.data(this, name); var instance = $.data(this, name);
// constructor // constructor
(!instance && !isMethodCall && (!instance && !isMethodCall &&
$.data(this, name, new $[namespace][name](this, options))); $.data(this, name, new $[namespace][name](this, options)));
// method call // method call
(instance && isMethodCall && $.isFunction(instance[options]) && (instance && isMethodCall && $.isFunction(instance[options]) &&
instance[options].apply(instance, args)); instance[options].apply(instance, args));
}); });
}; };
// create widget constructor // create widget constructor
$[namespace] = $[namespace] || {}; $[namespace] = $[namespace] || {};
$[namespace][name] = function(element, options) { $[namespace][name] = function(element, options) {
var self = this; var self = this;
this.widgetName = name; this.widgetName = name;
this.widgetEventPrefix = $[namespace][name].eventPrefix || name; this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
this.widgetBaseClass = namespace + '-' + name; this.widgetBaseClass = namespace + '-' + name;
this.options = $.extend({}, this.options = $.extend({},
$.widget.defaults, $.widget.defaults,
$[namespace][name].defaults, $[namespace][name].defaults,
$.metadata && $.metadata.get(element)[name], $.metadata && $.metadata.get(element)[name],
options); options);
this.element = $(element) this.element = $(element)
.bind('setData.' + name, function(event, key, value) { .bind('setData.' + name, function(event, key, value) {
return self._setData(key, value); return self._setData(key, value);
@ -314,13 +314,13 @@ $.widget = function(name, prototype) {
.bind('remove', function() { .bind('remove', function() {
return self.destroy(); return self.destroy();
}); });
this._init(); this._init();
}; };
// add widget prototype // add widget prototype
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
// TODO: merge getter and getterSetter properties from widget prototype // TODO: merge getter and getterSetter properties from widget prototype
// and plugin prototype // and plugin prototype
$[namespace][name].getterSetter = 'option'; $[namespace][name].getterSetter = 'option';
@ -331,11 +331,11 @@ $.widget.prototype = {
destroy: function() { destroy: function() {
this.element.removeData(this.widgetName); this.element.removeData(this.widgetName);
}, },
option: function(key, value) { option: function(key, value) {
var options = key, var options = key,
self = this; self = this;
if (typeof key == "string") { if (typeof key == "string") {
if (value === undefined) { if (value === undefined) {
return this._getData(key); return this._getData(key);
@ -343,7 +343,7 @@ $.widget.prototype = {
options = {}; options = {};
options[key] = value; options[key] = value;
} }
$.each(options, function(key, value) { $.each(options, function(key, value) {
self._setData(key, value); self._setData(key, value);
}); });
@ -353,20 +353,20 @@ $.widget.prototype = {
}, },
_setData: function(key, value) { _setData: function(key, value) {
this.options[key] = value; this.options[key] = value;
if (key == 'disabled') { if (key == 'disabled') {
this.element[value ? 'addClass' : 'removeClass']( this.element[value ? 'addClass' : 'removeClass'](
this.widgetBaseClass + '-disabled'); this.widgetBaseClass + '-disabled');
} }
}, },
enable: function() { enable: function() {
this._setData('disabled', false); this._setData('disabled', false);
}, },
disable: function() { disable: function() {
this._setData('disabled', true); this._setData('disabled', true);
}, },
_trigger: function(type, event, data) { _trigger: function(type, event, data) {
var eventName = (type == this.widgetEventPrefix var eventName = (type == this.widgetEventPrefix
? type : this.widgetEventPrefix + type); ? type : this.widgetEventPrefix + type);
@ -385,7 +385,7 @@ $.widget.defaults = {
$.ui.mouse = { $.ui.mouse = {
_mouseInit: function() { _mouseInit: function() {
var self = this; var self = this;
this.element this.element
.bind('mousedown.'+this.widgetName, function(event) { .bind('mousedown.'+this.widgetName, function(event) {
return self._mouseDown(event); return self._mouseDown(event);
@ -396,46 +396,46 @@ $.ui.mouse = {
return false; return false;
} }
}); });
// Prevent text selection in IE // Prevent text selection in IE
if ($.browser.msie) { if ($.browser.msie) {
this._mouseUnselectable = this.element.attr('unselectable'); this._mouseUnselectable = this.element.attr('unselectable');
this.element.attr('unselectable', 'on'); this.element.attr('unselectable', 'on');
} }
this.started = false; this.started = false;
}, },
// TODO: make sure destroying one instance of mouse doesn't mess with // TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse // other instances of mouse
_mouseDestroy: function() { _mouseDestroy: function() {
this.element.unbind('.'+this.widgetName); this.element.unbind('.'+this.widgetName);
// Restore text selection in IE // Restore text selection in IE
($.browser.msie ($.browser.msie
&& this.element.attr('unselectable', this._mouseUnselectable)); && this.element.attr('unselectable', this._mouseUnselectable));
}, },
_mouseDown: function(event) { _mouseDown: function(event) {
// we may have missed mouseup (out of window) // we may have missed mouseup (out of window)
(this._mouseStarted && this._mouseUp(event)); (this._mouseStarted && this._mouseUp(event));
this._mouseDownEvent = event; this._mouseDownEvent = event;
var self = this, var self = this,
btnIsLeft = (event.which == 1), btnIsLeft = (event.which == 1),
elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
return true; return true;
} }
this.mouseDelayMet = !this.options.delay; this.mouseDelayMet = !this.options.delay;
if (!this.mouseDelayMet) { if (!this.mouseDelayMet) {
this._mouseDelayTimer = setTimeout(function() { this._mouseDelayTimer = setTimeout(function() {
self.mouseDelayMet = true; self.mouseDelayMet = true;
}, this.options.delay); }, this.options.delay);
} }
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
this._mouseStarted = (this._mouseStart(event) !== false); this._mouseStarted = (this._mouseStart(event) !== false);
if (!this._mouseStarted) { if (!this._mouseStarted) {
@ -443,7 +443,7 @@ $.ui.mouse = {
return true; return true;
} }
} }
// these delegates are required to keep context // these delegates are required to keep context
this._mouseMoveDelegate = function(event) { this._mouseMoveDelegate = function(event) {
return self._mouseMove(event); return self._mouseMove(event);
@ -454,44 +454,44 @@ $.ui.mouse = {
$(document) $(document)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate); .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
return false; return false;
}, },
_mouseMove: function(event) { _mouseMove: function(event) {
// IE mouseup check - mouseup happened when mouse was out of window // IE mouseup check - mouseup happened when mouse was out of window
if ($.browser.msie && !event.button) { if ($.browser.msie && !event.button) {
return this._mouseUp(event); return this._mouseUp(event);
} }
if (this._mouseStarted) { if (this._mouseStarted) {
this._mouseDrag(event); this._mouseDrag(event);
return false; return false;
} }
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
this._mouseStarted = this._mouseStarted =
(this._mouseStart(this._mouseDownEvent, event) !== false); (this._mouseStart(this._mouseDownEvent, event) !== false);
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
} }
return !this._mouseStarted; return !this._mouseStarted;
}, },
_mouseUp: function(event) { _mouseUp: function(event) {
$(document) $(document)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
if (this._mouseStarted) { if (this._mouseStarted) {
this._mouseStarted = false; this._mouseStarted = false;
this._preventClickEvent = true; this._preventClickEvent = true;
this._mouseStop(event); this._mouseStop(event);
} }
return false; return false;
}, },
_mouseDistanceMet: function(event) { _mouseDistanceMet: function(event) {
return (Math.max( return (Math.max(
Math.abs(this._mouseDownEvent.pageX - event.pageX), Math.abs(this._mouseDownEvent.pageX - event.pageX),
@ -499,11 +499,11 @@ $.ui.mouse = {
) >= this.options.distance ) >= this.options.distance
); );
}, },
_mouseDelayMet: function(event) { _mouseDelayMet: function(event) {
return this.mouseDelayMet; return this.mouseDelayMet;
}, },
// These are placeholder methods, to be overriden by extending plugin // These are placeholder methods, to be overriden by extending plugin
_mouseStart: function(event) {}, _mouseStart: function(event) {},
_mouseDrag: function(event) {}, _mouseDrag: function(event) {},

View File

@ -139,13 +139,13 @@ function Datepicker() {
$.extend(Datepicker.prototype, { $.extend(Datepicker.prototype, {
/* Class name added to elements to indicate already configured with a date picker. */ /* Class name added to elements to indicate already configured with a date picker. */
markerClassName: 'hasDatepicker', markerClassName: 'hasDatepicker',
/* Debug logging (if enabled). */ /* Debug logging (if enabled). */
log: function () { log: function () {
if (this.debug) if (this.debug)
console.log.apply('', arguments); console.log.apply('', arguments);
}, },
/* Override the default settings for all instances of the date picker. /* Override the default settings for all instances of the date picker.
@param settings object - the new settings to use as defaults (anonymous object) @param settings object - the new settings to use as defaults (anonymous object)
@return the manager object */ @return the manager object */
@ -153,7 +153,7 @@ $.extend(Datepicker.prototype, {
extendRemove(this._defaults, settings || {}); extendRemove(this._defaults, settings || {});
return this; return this;
}, },
/* Attach the date picker to a jQuery selection. /* Attach the date picker to a jQuery selection.
@param target element - the target input field or division or span @param target element - the target input field or division or span
@param settings object - the new settings to use for this date picker instance (anonymous) */ @param settings object - the new settings to use for this date picker instance (anonymous) */
@ -183,7 +183,7 @@ $.extend(Datepicker.prototype, {
this._inlineDatepicker(target, inst); this._inlineDatepicker(target, inst);
} }
}, },
/* Create a new instance object. */ /* Create a new instance object. */
_newInst: function(target, inline) { _newInst: function(target, inline) {
var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars
@ -194,7 +194,7 @@ $.extend(Datepicker.prototype, {
dpDiv: (!inline ? this.dpDiv : // presentation div dpDiv: (!inline ? this.dpDiv : // presentation div
$('<div class="' + this._inlineClass + '"></div>'))}; $('<div class="' + this._inlineClass + '"></div>'))};
}, },
/* Attach the date picker to an input field. */ /* Attach the date picker to an input field. */
_connectDatepicker: function(target, inst) { _connectDatepicker: function(target, inst) {
var input = $(target); var input = $(target);
@ -233,7 +233,7 @@ $.extend(Datepicker.prototype, {
}); });
$.data(target, PROP_NAME, inst); $.data(target, PROP_NAME, inst);
}, },
/* Attach an inline date picker to a div. */ /* Attach an inline date picker to a div. */
_inlineDatepicker: function(target, inst) { _inlineDatepicker: function(target, inst) {
var divSpan = $(target); var divSpan = $(target);
@ -250,7 +250,7 @@ $.extend(Datepicker.prototype, {
this._updateDatepicker(inst); this._updateDatepicker(inst);
this._updateAlternate(inst); this._updateAlternate(inst);
}, },
/* Pop-up the date picker in a "dialog" box. /* Pop-up the date picker in a "dialog" box.
@param input element - ignored @param input element - ignored
@param dateText string - the initial date to display (in the current format) @param dateText string - the initial date to display (in the current format)
@ -274,7 +274,7 @@ $.extend(Datepicker.prototype, {
} }
extendRemove(inst.settings, settings || {}); extendRemove(inst.settings, settings || {});
this._dialogInput.val(dateText); this._dialogInput.val(dateText);
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
if (!this._pos) { if (!this._pos) {
var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
@ -284,7 +284,7 @@ $.extend(Datepicker.prototype, {
this._pos = // should use actual width/height below this._pos = // should use actual width/height below
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
} }
// move input on screen for focus, but hidden behind dialog // move input on screen for focus, but hidden behind dialog
this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
inst.settings.onSelect = onSelect; inst.settings.onSelect = onSelect;
@ -296,7 +296,7 @@ $.extend(Datepicker.prototype, {
$.data(this._dialogInput[0], PROP_NAME, inst); $.data(this._dialogInput[0], PROP_NAME, inst);
return this; return this;
}, },
/* Detach a datepicker from its control. /* Detach a datepicker from its control.
@param target element - the target input field or division or span */ @param target element - the target input field or division or span */
_destroyDatepicker: function(target) { _destroyDatepicker: function(target) {
@ -316,7 +316,7 @@ $.extend(Datepicker.prototype, {
} else if (nodeName == 'div' || nodeName == 'span') } else if (nodeName == 'div' || nodeName == 'span')
$target.removeClass(this.markerClassName).empty(); $target.removeClass(this.markerClassName).empty();
}, },
/* Enable the date picker to a jQuery selection. /* Enable the date picker to a jQuery selection.
@param target element - the target input field or division or span */ @param target element - the target input field or division or span */
_enableDatepicker: function(target) { _enableDatepicker: function(target) {
@ -338,7 +338,7 @@ $.extend(Datepicker.prototype, {
this._disabledInputs = $.map(this._disabledInputs, this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry function(value) { return (value == target ? null : value); }); // delete entry
}, },
/* Disable the date picker to a jQuery selection. /* Disable the date picker to a jQuery selection.
@param target element - the target input field or division or span */ @param target element - the target input field or division or span */
_disableDatepicker: function(target) { _disableDatepicker: function(target) {
@ -374,7 +374,7 @@ $.extend(Datepicker.prototype, {
function(value) { return (value == target ? null : value); }); // delete entry function(value) { return (value == target ? null : value); }); // delete entry
this._disabledInputs[this._disabledInputs.length] = target; this._disabledInputs[this._disabledInputs.length] = target;
}, },
/* Is the first field in a jQuery collection disabled as a datepicker? /* Is the first field in a jQuery collection disabled as a datepicker?
@param target element - the target input field or division or span @param target element - the target input field or division or span
@return boolean - true if disabled, false if enabled */ @return boolean - true if disabled, false if enabled */
@ -387,7 +387,7 @@ $.extend(Datepicker.prototype, {
} }
return false; return false;
}, },
/* Retrieve the instance data for the target control. /* Retrieve the instance data for the target control.
@param target element - the target input field or division or span @param target element - the target input field or division or span
@return object - the associated instance data @return object - the associated instance data
@ -400,7 +400,7 @@ $.extend(Datepicker.prototype, {
throw 'Missing instance data for this datepicker'; throw 'Missing instance data for this datepicker';
} }
}, },
/* Update the settings for a date picker attached to an input field or division. /* Update the settings for a date picker attached to an input field or division.
@param target element - the target input field or division or span @param target element - the target input field or division or span
@param name object - the new settings to update or @param name object - the new settings to update or
@ -429,12 +429,12 @@ $.extend(Datepicker.prototype, {
this._updateDatepicker(inst); this._updateDatepicker(inst);
} }
}, },
// change method deprecated // change method deprecated
_changeDatepicker: function(target, name, value) { _changeDatepicker: function(target, name, value) {
this._optionDatepicker(target, name, value); this._optionDatepicker(target, name, value);
}, },
/* Redraw the date picker attached to an input field or division. /* Redraw the date picker attached to an input field or division.
@param target element - the target input field or division or span */ @param target element - the target input field or division or span */
_refreshDatepicker: function(target) { _refreshDatepicker: function(target) {
@ -443,7 +443,7 @@ $.extend(Datepicker.prototype, {
this._updateDatepicker(inst); this._updateDatepicker(inst);
} }
}, },
/* Set the dates for a jQuery selection. /* Set the dates for a jQuery selection.
@param target element - the target input field or division or span @param target element - the target input field or division or span
@param date Date - the new date @param date Date - the new date
@ -456,7 +456,7 @@ $.extend(Datepicker.prototype, {
this._updateAlternate(inst); this._updateAlternate(inst);
} }
}, },
/* Get the date(s) for the first entry in a jQuery selection. /* Get the date(s) for the first entry in a jQuery selection.
@param target element - the target input field or division or span @param target element - the target input field or division or span
@return Date - the current date or @return Date - the current date or
@ -467,7 +467,7 @@ $.extend(Datepicker.prototype, {
this._setDateFromField(inst); this._setDateFromField(inst);
return (inst ? this._getDate(inst) : null); return (inst ? this._getDate(inst) : null);
}, },
/* Handle keystrokes. */ /* Handle keystrokes. */
_doKeyDown: function(event) { _doKeyDown: function(event) {
var inst = $.datepicker._getInst(event.target); var inst = $.datepicker._getInst(event.target);
@ -535,7 +535,7 @@ $.extend(Datepicker.prototype, {
event.stopPropagation(); event.stopPropagation();
} }
}, },
/* Filter entered characters - based on date format. */ /* Filter entered characters - based on date format. */
_doKeyPress: function(event) { _doKeyPress: function(event) {
var inst = $.datepicker._getInst(event.target); var inst = $.datepicker._getInst(event.target);
@ -545,7 +545,7 @@ $.extend(Datepicker.prototype, {
return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
} }
}, },
/* Pop-up the date picker for a given input field. /* Pop-up the date picker for a given input field.
@param input element - the input field attached to the date picker or @param input element - the input field attached to the date picker or
event - if triggered by focus */ event - if triggered by focus */
@ -610,7 +610,7 @@ $.extend(Datepicker.prototype, {
$.datepicker._curInst = inst; $.datepicker._curInst = inst;
} }
}, },
/* Generate the date picker content. */ /* Generate the date picker content. */
_updateDatepicker: function(inst) { _updateDatepicker: function(inst) {
var dims = {width: inst.dpDiv.width() + 4, var dims = {width: inst.dpDiv.width() + 4,
@ -626,7 +626,7 @@ $.extend(Datepicker.prototype, {
if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst) if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst)
$(inst.input[0]).focus(); $(inst.input[0]).focus();
}, },
/* Check positioning to remain on screen. */ /* Check positioning to remain on screen. */
_checkOffset: function(inst, offset, isFixed) { _checkOffset: function(inst, offset, isFixed) {
var pos = inst.input ? this._findPos(inst.input[0]) : null; var pos = inst.input ? this._findPos(inst.input[0]) : null;
@ -652,7 +652,7 @@ $.extend(Datepicker.prototype, {
offset.top -= (isFixed ? scrollY : 0); offset.top -= (isFixed ? scrollY : 0);
return offset; return offset;
}, },
/* Find an object's position on the screen. */ /* Find an object's position on the screen. */
_findPos: function(obj) { _findPos: function(obj) {
while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
@ -661,7 +661,7 @@ $.extend(Datepicker.prototype, {
var position = $(obj).offset(); var position = $(obj).offset();
return [position.left, position.top]; return [position.left, position.top];
}, },
/* Hide the date picker from view. /* Hide the date picker from view.
@param input element - the input field attached to the date picker @param input element - the input field attached to the date picker
@param duration string - the duration over which to close the date picker */ @param duration string - the duration over which to close the date picker */
@ -706,13 +706,13 @@ $.extend(Datepicker.prototype, {
} }
this._curInst = null; this._curInst = null;
}, },
/* Tidy up after a dialog display. */ /* Tidy up after a dialog display. */
_tidyDialog: function(inst) { _tidyDialog: function(inst) {
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker'); inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
$('.' + this._promptClass, inst.dpDiv).remove(); $('.' + this._promptClass, inst.dpDiv).remove();
}, },
/* Close date picker if clicked elsewhere. */ /* Close date picker if clicked elsewhere. */
_checkExternalClick: function(event) { _checkExternalClick: function(event) {
if (!$.datepicker._curInst) if (!$.datepicker._curInst)
@ -724,7 +724,7 @@ $.extend(Datepicker.prototype, {
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
$.datepicker._hideDatepicker(null, ''); $.datepicker._hideDatepicker(null, '');
}, },
/* Adjust one of the date sub-fields. */ /* Adjust one of the date sub-fields. */
_adjustDate: function(id, offset, period) { _adjustDate: function(id, offset, period) {
var target = $(id); var target = $(id);
@ -732,7 +732,7 @@ $.extend(Datepicker.prototype, {
this._adjustInstDate(inst, offset, period); this._adjustInstDate(inst, offset, period);
this._updateDatepicker(inst); this._updateDatepicker(inst);
}, },
/* Action for current link. */ /* Action for current link. */
_gotoToday: function(id) { _gotoToday: function(id) {
var target = $(id); var target = $(id);
@ -751,7 +751,7 @@ $.extend(Datepicker.prototype, {
this._notifyChange(inst); this._notifyChange(inst);
this._adjustDate(target); this._adjustDate(target);
}, },
/* Action for selecting a new month/year. */ /* Action for selecting a new month/year. */
_selectMonthYear: function(id, select, period) { _selectMonthYear: function(id, select, period) {
var target = $(id); var target = $(id);
@ -763,7 +763,7 @@ $.extend(Datepicker.prototype, {
this._notifyChange(inst); this._notifyChange(inst);
this._adjustDate(target); this._adjustDate(target);
}, },
/* Restore input focus after not changing month/year. */ /* Restore input focus after not changing month/year. */
_clickMonthYear: function(id) { _clickMonthYear: function(id) {
var target = $(id); var target = $(id);
@ -772,7 +772,7 @@ $.extend(Datepicker.prototype, {
inst.input[0].focus(); inst.input[0].focus();
inst._selectingMonthYear = !inst._selectingMonthYear; inst._selectingMonthYear = !inst._selectingMonthYear;
}, },
/* Action for changing the first week day. */ /* Action for changing the first week day. */
_changeFirstDay: function(id, day) { _changeFirstDay: function(id, day) {
var target = $(id); var target = $(id);
@ -780,7 +780,7 @@ $.extend(Datepicker.prototype, {
inst.settings.firstDay = day; inst.settings.firstDay = day;
this._updateDatepicker(inst); this._updateDatepicker(inst);
}, },
/* Action for selecting a day. */ /* Action for selecting a day. */
_selectDay: function(id, month, year, td) { _selectDay: function(id, month, year, td) {
if ($(td).hasClass(this._unselectableClass)) if ($(td).hasClass(this._unselectableClass))
@ -822,7 +822,7 @@ $.extend(Datepicker.prototype, {
this._updateDatepicker(inst); this._updateDatepicker(inst);
} }
}, },
/* Erase the input field and hide the date picker. */ /* Erase the input field and hide the date picker. */
_clearDate: function(id) { _clearDate: function(id) {
var target = $(id); var target = $(id);
@ -833,7 +833,7 @@ $.extend(Datepicker.prototype, {
inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null; inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
this._selectDate(target, ''); this._selectDate(target, '');
}, },
/* Update the input field with the selected date. */ /* Update the input field with the selected date. */
_selectDate: function(id, dateStr) { _selectDate: function(id, dateStr) {
var target = $(id); var target = $(id);
@ -860,7 +860,7 @@ $.extend(Datepicker.prototype, {
this._lastInput = null; this._lastInput = null;
} }
}, },
/* Update any alternate field to synchronise with the main field. */ /* Update any alternate field to synchronise with the main field. */
_updateAlternate: function(inst) { _updateAlternate: function(inst) {
var altField = this._get(inst, 'altField'); var altField = this._get(inst, 'altField');
@ -875,7 +875,7 @@ $.extend(Datepicker.prototype, {
$(altField).each(function() { $(this).val(dateStr); }); $(altField).each(function() { $(this).val(dateStr); });
} }
}, },
/* Set as beforeShowDay function to prevent selection of weekends. /* Set as beforeShowDay function to prevent selection of weekends.
@param date Date - the date to customise @param date Date - the date to customise
@return [boolean, string] - is this date selectable?, what is its CSS class? */ @return [boolean, string] - is this date selectable?, what is its CSS class? */
@ -883,7 +883,7 @@ $.extend(Datepicker.prototype, {
var day = date.getDay(); var day = date.getDay();
return [(day > 0 && day < 6), '']; return [(day > 0 && day < 6), ''];
}, },
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
@param date Date - the date to get the week for @param date Date - the date to get the week for
@return number - the number of the week within the year that contains this date */ @return number - the number of the week within the year that contains this date */
@ -903,7 +903,7 @@ $.extend(Datepicker.prototype, {
} }
return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
}, },
/* Provide status text for a particular date. /* Provide status text for a particular date.
@param date the date to get the status for @param date the date to get the status for
@param inst the current datepicker instance @param inst the current datepicker instance
@ -912,7 +912,7 @@ $.extend(Datepicker.prototype, {
return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'), return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'),
date, $.datepicker._getFormatConfig(inst)); date, $.datepicker._getFormatConfig(inst));
}, },
/* Parse a string value into a date object. /* Parse a string value into a date object.
See formatDate below for the possible formats. See formatDate below for the possible formats.
@ -946,7 +946,7 @@ $.extend(Datepicker.prototype, {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches) if (matches)
iFormat++; iFormat++;
return matches; return matches;
}; };
// Extract a number from the string value // Extract a number from the string value
var getNumber = function(match) { var getNumber = function(match) {
@ -1050,7 +1050,7 @@ $.extend(Datepicker.prototype, {
throw 'Invalid date'; // E.g. 31/02/* throw 'Invalid date'; // E.g. 31/02/*
return date; return date;
}, },
/* Standard date formats. */ /* Standard date formats. */
ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601) ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
COOKIE: 'D, dd M yy', COOKIE: 'D, dd M yy',
@ -1063,7 +1063,7 @@ $.extend(Datepicker.prototype, {
RSS: 'D, d M y', // RFC 822 RSS: 'D, d M y', // RFC 822
TIMESTAMP: '@', TIMESTAMP: '@',
W3C: 'yy-mm-dd', // ISO 8601 W3C: 'yy-mm-dd', // ISO 8601
/* Format a date object into a string value. /* Format a date object into a string value.
The format can be combinations of the following: The format can be combinations of the following:
d - day of month (no leading zero) d - day of month (no leading zero)
@ -1081,7 +1081,7 @@ $.extend(Datepicker.prototype, {
@ - Unix timestamp (ms since 01/01/1970) @ - Unix timestamp (ms since 01/01/1970)
'...' - literal text '...' - literal text
'' - single quote '' - single quote
@param format string - the desired format of the date @param format string - the desired format of the date
@param date Date - the date value to format @param date Date - the date value to format
@param settings Object - attributes include: @param settings Object - attributes include:
@ -1102,7 +1102,7 @@ $.extend(Datepicker.prototype, {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches) if (matches)
iFormat++; iFormat++;
return matches; return matches;
}; };
// Format a number, with leading zero if necessary // Format a number, with leading zero if necessary
var formatNumber = function(match, value, len) { var formatNumber = function(match, value, len) {
@ -1164,7 +1164,7 @@ $.extend(Datepicker.prototype, {
} }
return output; return output;
}, },
/* Extract all possible characters from the date format. */ /* Extract all possible characters from the date format. */
_possibleChars: function (format) { _possibleChars: function (format) {
var chars = ''; var chars = '';
@ -1193,13 +1193,13 @@ $.extend(Datepicker.prototype, {
} }
return chars; return chars;
}, },
/* Get a setting value, defaulting if necessary. */ /* Get a setting value, defaulting if necessary. */
_get: function(inst, name) { _get: function(inst, name) {
return inst.settings[name] !== undefined ? return inst.settings[name] !== undefined ?
inst.settings[name] : this._defaults[name]; inst.settings[name] : this._defaults[name];
}, },
/* Parse existing date and initialise date picker. */ /* Parse existing date and initialise date picker. */
_setDateFromField: function(inst) { _setDateFromField: function(inst) {
var dateFormat = this._get(inst, 'dateFormat'); var dateFormat = this._get(inst, 'dateFormat');
@ -1229,7 +1229,7 @@ $.extend(Datepicker.prototype, {
inst.currentYear = (dates[0] ? date.getFullYear() : 0); inst.currentYear = (dates[0] ? date.getFullYear() : 0);
this._adjustInstDate(inst); this._adjustInstDate(inst);
}, },
/* Retrieve the default date shown on opening. */ /* Retrieve the default date shown on opening. */
_getDefaultDate: function(inst) { _getDefaultDate: function(inst) {
var date = this._determineDate(this._get(inst, 'defaultDate'), new Date()); var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
@ -1239,7 +1239,7 @@ $.extend(Datepicker.prototype, {
date = (maxDate && date > maxDate ? maxDate : date); date = (maxDate && date > maxDate ? maxDate : date);
return date; return date;
}, },
/* A date may be specified as an exact value or a relative one. */ /* A date may be specified as an exact value or a relative one. */
_determineDate: function(date, defaultDate) { _determineDate: function(date, defaultDate) {
var offsetNumeric = function(offset) { var offsetNumeric = function(offset) {
@ -1327,7 +1327,7 @@ $.extend(Datepicker.prototype, {
(!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') + (!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') +
this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear))); this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear)));
}, },
/* Retrieve the date(s) directly. */ /* Retrieve the date(s) directly. */
_getDate: function(inst) { _getDate: function(inst) {
var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
@ -1340,7 +1340,7 @@ $.extend(Datepicker.prototype, {
} else } else
return startDate; return startDate;
}, },
/* Generate the HTML for the current state of the date picker. */ /* Generate the HTML for the current state of the date picker. */
_generateHTML: function(inst) { _generateHTML: function(inst) {
var today = new Date(); var today = new Date();
@ -1535,7 +1535,7 @@ $.extend(Datepicker.prototype, {
inst._keyEvent = false; inst._keyEvent = false;
return html; return html;
}, },
/* Generate the month and year header. */ /* Generate the month and year header. */
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
selectedDate, secondary, showStatus, initStatus, monthNames) { selectedDate, secondary, showStatus, initStatus, monthNames) {
@ -1603,7 +1603,7 @@ $.extend(Datepicker.prototype, {
html += '</div>'; // Close datepicker_header html += '</div>'; // Close datepicker_header
return html; return html;
}, },
/* Provide code to set and clear the status panel. */ /* Provide code to set and clear the status panel. */
_addStatus: function(showStatus, id, text, initStatus) { _addStatus: function(showStatus, id, text, initStatus) {
return (showStatus ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + id + return (showStatus ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + id +
@ -1611,7 +1611,7 @@ $.extend(Datepicker.prototype, {
'onmouseout="jQuery(\'#ui-datepicker-status-' + id + 'onmouseout="jQuery(\'#ui-datepicker-status-' + id +
'\').html(\'' + initStatus + '\');"' : ''); '\').html(\'' + initStatus + '\');"' : '');
}, },
/* Adjust one of the date sub-fields. */ /* Adjust one of the date sub-fields. */
_adjustInstDate: function(inst, offset, period) { _adjustInstDate: function(inst, offset, period) {
var year = inst.drawYear + (period == 'Y' ? offset : 0); var year = inst.drawYear + (period == 'Y' ? offset : 0);
@ -1630,7 +1630,7 @@ $.extend(Datepicker.prototype, {
if (period == 'M' || period == 'Y') if (period == 'M' || period == 'Y')
this._notifyChange(inst); this._notifyChange(inst);
}, },
/* Notify change of month/year. */ /* Notify change of month/year. */
_notifyChange: function(inst) { _notifyChange: function(inst) {
var onChange = this._get(inst, 'onChangeMonthYear'); var onChange = this._get(inst, 'onChangeMonthYear');
@ -1638,30 +1638,30 @@ $.extend(Datepicker.prototype, {
onChange.apply((inst.input ? inst.input[0] : null), onChange.apply((inst.input ? inst.input[0] : null),
[inst.selectedYear, inst.selectedMonth + 1, inst]); [inst.selectedYear, inst.selectedMonth + 1, inst]);
}, },
/* Determine the number of months to show. */ /* Determine the number of months to show. */
_getNumberOfMonths: function(inst) { _getNumberOfMonths: function(inst) {
var numMonths = this._get(inst, 'numberOfMonths'); var numMonths = this._get(inst, 'numberOfMonths');
return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
}, },
/* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */ /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
_getMinMaxDate: function(inst, minMax, checkRange) { _getMinMaxDate: function(inst, minMax, checkRange) {
var date = this._determineDate(this._get(inst, minMax + 'Date'), null); var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
return (!checkRange || !inst.rangeStart ? date : return (!checkRange || !inst.rangeStart ? date :
(!date || inst.rangeStart > date ? inst.rangeStart : date)); (!date || inst.rangeStart > date ? inst.rangeStart : date));
}, },
/* Find the number of days in a given month. */ /* Find the number of days in a given month. */
_getDaysInMonth: function(year, month) { _getDaysInMonth: function(year, month) {
return 32 - new Date(year, month, 32).getDate(); return 32 - new Date(year, month, 32).getDate();
}, },
/* Find the day of the week of the first of a month. */ /* Find the day of the week of the first of a month. */
_getFirstDayOfMonth: function(year, month) { _getFirstDayOfMonth: function(year, month) {
return new Date(year, month, 1).getDay(); return new Date(year, month, 1).getDay();
}, },
/* Determines if we should allow a "next/prev" month display change. */ /* Determines if we should allow a "next/prev" month display change. */
_canAdjustMonth: function(inst, offset, curYear, curMonth) { _canAdjustMonth: function(inst, offset, curYear, curMonth) {
var numMonths = this._getNumberOfMonths(inst); var numMonths = this._getNumberOfMonths(inst);
@ -1671,7 +1671,7 @@ $.extend(Datepicker.prototype, {
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
return this._isInRange(inst, date); return this._isInRange(inst, date);
}, },
/* Is the given date in the accepted range? */ /* Is the given date in the accepted range? */
_isInRange: function(inst, date) { _isInRange: function(inst, date) {
// during range selection, use minimum of selected date and range start // during range selection, use minimum of selected date and range start
@ -1682,7 +1682,7 @@ $.extend(Datepicker.prototype, {
var maxDate = this._getMinMaxDate(inst, 'max'); var maxDate = this._getMinMaxDate(inst, 'max');
return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
}, },
/* Provide the configuration settings for formatting/parsing. */ /* Provide the configuration settings for formatting/parsing. */
_getFormatConfig: function(inst) { _getFormatConfig: function(inst) {
var shortYearCutoff = this._get(inst, 'shortYearCutoff'); var shortYearCutoff = this._get(inst, 'shortYearCutoff');
@ -1692,7 +1692,7 @@ $.extend(Datepicker.prototype, {
dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
}, },
/* Format the given date for display. */ /* Format the given date for display. */
_formatDate: function(inst, day, month, year) { _formatDate: function(inst, day, month, year) {
if (!day) { if (!day) {
@ -1727,14 +1727,14 @@ function isArray(a) {
Object - settings for attaching new datepicker functionality Object - settings for attaching new datepicker functionality
@return jQuery object */ @return jQuery object */
$.fn.datepicker = function(options){ $.fn.datepicker = function(options){
/* Initialise the date picker. */ /* Initialise the date picker. */
if (!$.datepicker.initialized) { if (!$.datepicker.initialized) {
$(document.body).append($.datepicker.dpDiv). $(document.body).append($.datepicker.dpDiv).
mousedown($.datepicker._checkExternalClick); mousedown($.datepicker._checkExternalClick);
$.datepicker.initialized = true; $.datepicker.initialized = true;
} }
var otherArgs = Array.prototype.slice.call(arguments, 1); var otherArgs = Array.prototype.slice.call(arguments, 1);
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate')) if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
return $.datepicker['_' + options + 'Datepicker']. return $.datepicker['_' + options + 'Datepicker'].

View File

@ -31,16 +31,16 @@ $.widget("ui.dialog", {
_init: function() { _init: function() {
this.originalTitle = this.element.attr('title'); this.originalTitle = this.element.attr('title');
this.options.title = this.options.title || this.originalTitle; this.options.title = this.options.title || this.originalTitle;
var self = this, var self = this,
options = this.options, options = this.options,
uiDialogContent = this.element uiDialogContent = this.element
.removeAttr('title') .removeAttr('title')
.addClass('ui-dialog-content') .addClass('ui-dialog-content')
.wrap('<div/>') .wrap('<div/>')
.wrap('<div/>'), .wrap('<div/>'),
uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent()) uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent())
.addClass('ui-dialog-container') .addClass('ui-dialog-container')
.css({ .css({
@ -48,7 +48,7 @@ $.widget("ui.dialog", {
width: '100%', width: '100%',
height: '100%' height: '100%'
}), }),
uiDialogTitlebar = (this.uiDialogTitlebar = $('<div/>')) uiDialogTitlebar = (this.uiDialogTitlebar = $('<div/>'))
.addClass('ui-dialog-titlebar') .addClass('ui-dialog-titlebar')
.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>') .append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>')
@ -56,7 +56,7 @@ $.widget("ui.dialog", {
self.moveToTop(); self.moveToTop();
}) })
.prependTo(uiDialogContainer), .prependTo(uiDialogContainer),
title = options.title || '&nbsp;', title = options.title || '&nbsp;',
titleId = $.ui.dialog.getTitleId(this.element), titleId = $.ui.dialog.getTitleId(this.element),
uiDialogTitle = $('<span/>') uiDialogTitle = $('<span/>')
@ -64,7 +64,7 @@ $.widget("ui.dialog", {
.attr('id', titleId) .attr('id', titleId)
.html(title) .html(title)
.prependTo(uiDialogTitlebar), .prependTo(uiDialogTitlebar),
uiDialog = (this.uiDialog = uiDialogContainer.parent()) uiDialog = (this.uiDialog = uiDialogContainer.parent())
.appendTo(document.body) .appendTo(document.body)
.hide() .hide()
@ -90,7 +90,7 @@ $.widget("ui.dialog", {
.mouseup(function() { .mouseup(function() {
self.moveToTop(); self.moveToTop();
}), }),
uiDialogButtonPane = (this.uiDialogButtonPane = $('<div/>')) uiDialogButtonPane = (this.uiDialogButtonPane = $('<div/>'))
.addClass('ui-dialog-buttonpane') .addClass('ui-dialog-buttonpane')
.css({ .css({
@ -98,7 +98,7 @@ $.widget("ui.dialog", {
bottom: 0 bottom: 0
}) })
.appendTo(uiDialog), .appendTo(uiDialog),
uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar) uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)
.hover( .hover(
function() { function() {
@ -115,19 +115,19 @@ $.widget("ui.dialog", {
self.close(); self.close();
return false; return false;
}); });
uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
(options.draggable && $.fn.draggable && this._makeDraggable()); (options.draggable && $.fn.draggable && this._makeDraggable());
(options.resizable && $.fn.resizable && this._makeResizable()); (options.resizable && $.fn.resizable && this._makeResizable());
this._createButtons(options.buttons); this._createButtons(options.buttons);
this._isOpen = false; this._isOpen = false;
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe()); (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
(options.autoOpen && this.open()); (options.autoOpen && this.open());
}, },
destroy: function() { destroy: function() {
(this.overlay && this.overlay.destroy()); (this.overlay && this.overlay.destroy());
this.uiDialog.hide(); this.uiDialog.hide();
@ -137,45 +137,45 @@ $.widget("ui.dialog", {
.removeClass('ui-dialog-content') .removeClass('ui-dialog-content')
.hide().appendTo('body'); .hide().appendTo('body');
this.uiDialog.remove(); this.uiDialog.remove();
(this.originalTitle && this.element.attr('title', this.originalTitle)); (this.originalTitle && this.element.attr('title', this.originalTitle));
}, },
close: function() { close: function() {
if (false === this._trigger('beforeclose', null, { options: this.options })) { if (false === this._trigger('beforeclose', null, { options: this.options })) {
return; return;
} }
(this.overlay && this.overlay.destroy()); (this.overlay && this.overlay.destroy());
this.uiDialog this.uiDialog
.hide(this.options.hide) .hide(this.options.hide)
.unbind('keypress.ui-dialog'); .unbind('keypress.ui-dialog');
this._trigger('close', null, { options: this.options }); this._trigger('close', null, { options: this.options });
$.ui.dialog.overlay.resize(); $.ui.dialog.overlay.resize();
this._isOpen = false; this._isOpen = false;
}, },
isOpen: function() { isOpen: function() {
return this._isOpen; return this._isOpen;
}, },
// the force parameter allows us to move modal dialogs to their correct // the force parameter allows us to move modal dialogs to their correct
// position on open // position on open
moveToTop: function(force) { moveToTop: function(force) {
if ((this.options.modal && !force) if ((this.options.modal && !force)
|| (!this.options.stack && !this.options.modal)) { || (!this.options.stack && !this.options.modal)) {
return this._trigger('focus', null, { options: this.options }); return this._trigger('focus', null, { options: this.options });
} }
var maxZ = this.options.zIndex, options = this.options; var maxZ = this.options.zIndex, options = this.options;
$('.ui-dialog:visible').each(function() { $('.ui-dialog:visible').each(function() {
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex); maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
}); });
(this.overlay && this.overlay.$el.css('z-index', ++maxZ)); (this.overlay && this.overlay.$el.css('z-index', ++maxZ));
//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
// http://ui.jquery.com/bugs/ticket/3193 // http://ui.jquery.com/bugs/ticket/3193
var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') };
@ -183,27 +183,27 @@ $.widget("ui.dialog", {
this.element.attr(saveScroll); this.element.attr(saveScroll);
this._trigger('focus', null, { options: this.options }); this._trigger('focus', null, { options: this.options });
}, },
open: function() { open: function() {
if (this._isOpen) { return; } if (this._isOpen) { return; }
this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null; this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
(this.uiDialog.next().length && this.uiDialog.appendTo('body')); (this.uiDialog.next().length && this.uiDialog.appendTo('body'));
this._position(this.options.position); this._position(this.options.position);
this.uiDialog.show(this.options.show); this.uiDialog.show(this.options.show);
(this.options.autoResize && this._size()); (this.options.autoResize && this._size());
this.moveToTop(true); this.moveToTop(true);
// prevent tabbing out of modal dialogs // prevent tabbing out of modal dialogs
(this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(event) { (this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(event) {
if (event.keyCode != $.keyCode.TAB) { if (event.keyCode != $.keyCode.TAB) {
return; return;
} }
var tabbables = $(':tabbable', this), var tabbables = $(':tabbable', this),
first = tabbables.filter(':first')[0], first = tabbables.filter(':first')[0],
last = tabbables.filter(':last')[0]; last = tabbables.filter(':last')[0];
if (event.target == last && !event.shiftKey) { if (event.target == last && !event.shiftKey) {
setTimeout(function() { setTimeout(function() {
first.focus(); first.focus();
@ -214,20 +214,20 @@ $.widget("ui.dialog", {
}, 1); }, 1);
} }
})); }));
this.uiDialog.find(':tabbable:first').focus(); this.uiDialog.find(':tabbable:first').focus();
this._trigger('open', null, { options: this.options }); this._trigger('open', null, { options: this.options });
this._isOpen = true; this._isOpen = true;
}, },
_createButtons: function(buttons) { _createButtons: function(buttons) {
var self = this, var self = this,
hasButtons = false, hasButtons = false,
uiDialogButtonPane = this.uiDialogButtonPane; uiDialogButtonPane = this.uiDialogButtonPane;
// remove any existing buttons // remove any existing buttons
uiDialogButtonPane.empty().hide(); uiDialogButtonPane.empty().hide();
$.each(buttons, function() { return !(hasButtons = true); }); $.each(buttons, function() { return !(hasButtons = true); });
if (hasButtons) { if (hasButtons) {
uiDialogButtonPane.show(); uiDialogButtonPane.show();
@ -239,11 +239,11 @@ $.widget("ui.dialog", {
}); });
} }
}, },
_makeDraggable: function() { _makeDraggable: function() {
var self = this, var self = this,
options = this.options; options = this.options;
this.uiDialog.draggable({ this.uiDialog.draggable({
cancel: '.ui-dialog-content', cancel: '.ui-dialog-content',
helper: options.dragHelper, helper: options.dragHelper,
@ -261,7 +261,7 @@ $.widget("ui.dialog", {
} }
}); });
}, },
_makeResizable: function(handles) { _makeResizable: function(handles) {
handles = (handles === undefined ? this.options.resizable : handles); handles = (handles === undefined ? this.options.resizable : handles);
var self = this, var self = this,
@ -269,7 +269,7 @@ $.widget("ui.dialog", {
resizeHandles = typeof handles == 'string' resizeHandles = typeof handles == 'string'
? handles ? handles
: 'n,e,s,w,se,sw,ne,nw'; : 'n,e,s,w,se,sw,ne,nw';
this.uiDialog.resizable({ this.uiDialog.resizable({
cancel: '.ui-dialog-content', cancel: '.ui-dialog-content',
helper: options.resizeHelper, helper: options.resizeHelper,
@ -292,12 +292,12 @@ $.widget("ui.dialog", {
} }
}); });
}, },
_position: function(pos) { _position: function(pos) {
var wnd = $(window), doc = $(document), var wnd = $(window), doc = $(document),
pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
minTop = pTop; minTop = pTop;
if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
pos = [ pos = [
pos == 'right' || pos == 'left' ? pos : 'center', pos == 'right' || pos == 'left' ? pos : 'center',
@ -337,13 +337,13 @@ $.widget("ui.dialog", {
pTop += (wnd.height() - this.uiDialog.height()) / 2; pTop += (wnd.height() - this.uiDialog.height()) / 2;
} }
} }
// prevent the dialog from being too high (make sure the titlebar // prevent the dialog from being too high (make sure the titlebar
// is accessible) // is accessible)
pTop = Math.max(pTop, minTop); pTop = Math.max(pTop, minTop);
this.uiDialog.css({top: pTop, left: pLeft}); this.uiDialog.css({top: pTop, left: pLeft});
}, },
_setData: function(key, value){ _setData: function(key, value){
(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value)); (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
switch (key) { switch (key) {
@ -364,17 +364,17 @@ $.widget("ui.dialog", {
case "resizable": case "resizable":
var uiDialog = this.uiDialog, var uiDialog = this.uiDialog,
isResizable = this.uiDialog.is(':data(resizable)'); isResizable = this.uiDialog.is(':data(resizable)');
// currently resizable, becoming non-resizable // currently resizable, becoming non-resizable
(isResizable && !value && uiDialog.resizable('destroy')); (isResizable && !value && uiDialog.resizable('destroy'));
// currently resizable, changing handles // currently resizable, changing handles
(isResizable && typeof value == 'string' && (isResizable && typeof value == 'string' &&
uiDialog.resizable('option', 'handles', value)); uiDialog.resizable('option', 'handles', value));
// currently non-resizable, becoming resizable // currently non-resizable, becoming resizable
(isResizable || this._makeResizable(value)); (isResizable || this._makeResizable(value));
break; break;
case "title": case "title":
$(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;'); $(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;');
@ -383,10 +383,10 @@ $.widget("ui.dialog", {
this.uiDialog.width(value); this.uiDialog.width(value);
break; break;
} }
$.widget.prototype._setData.apply(this, arguments); $.widget.prototype._setData.apply(this, arguments);
}, },
_size: function() { _size: function() {
var container = this.uiDialogContainer, var container = this.uiDialogContainer,
titlebar = this.uiDialogTitlebar, titlebar = this.uiDialogTitlebar,
@ -420,14 +420,14 @@ $.extend($.ui.dialog, {
width: 300, width: 300,
zIndex: 1000 zIndex: 1000
}, },
getter: 'isOpen', getter: 'isOpen',
uuid: 0, uuid: 0,
getTitleId: function($el) { getTitleId: function($el) {
return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
}, },
overlay: function(dialog) { overlay: function(dialog) {
this.$el = $.ui.dialog.overlay.create(dialog); this.$el = $.ui.dialog.overlay.create(dialog);
} }
@ -464,17 +464,17 @@ $.extend($.ui.dialog.overlay, {
return allow; return allow;
}); });
}, 1); }, 1);
// allow closing by pressing the escape key // allow closing by pressing the escape key
$(document).bind('keydown.dialog-overlay', function(event) { $(document).bind('keydown.dialog-overlay', function(event) {
(dialog.options.closeOnEscape && event.keyCode (dialog.options.closeOnEscape && event.keyCode
&& event.keyCode == $.keyCode.ESCAPE && dialog.close()); && event.keyCode == $.keyCode.ESCAPE && dialog.close());
}); });
// handle window resize // handle window resize
$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
} }
var $el = $('<div/>').appendTo(document.body) var $el = $('<div/>').appendTo(document.body)
.addClass('ui-dialog-overlay').css($.extend({ .addClass('ui-dialog-overlay').css($.extend({
borderWidth: 0, margin: 0, padding: 0, borderWidth: 0, margin: 0, padding: 0,
@ -482,23 +482,23 @@ $.extend($.ui.dialog.overlay, {
width: this.width(), width: this.width(),
height: this.height() height: this.height()
}, dialog.options.overlay)); }, dialog.options.overlay));
(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe()); (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
this.instances.push($el); this.instances.push($el);
return $el; return $el;
}, },
destroy: function($el) { destroy: function($el) {
this.instances.splice($.inArray(this.instances, $el), 1); this.instances.splice($.inArray(this.instances, $el), 1);
if (this.instances.length === 0) { if (this.instances.length === 0) {
$('a, :input').add([document, window]).unbind('.dialog-overlay'); $('a, :input').add([document, window]).unbind('.dialog-overlay');
} }
$el.remove(); $el.remove();
}, },
height: function() { height: function() {
// handle IE 6 // handle IE 6
if ($.browser.msie && $.browser.version < 7) { if ($.browser.msie && $.browser.version < 7) {
@ -510,7 +510,7 @@ $.extend($.ui.dialog.overlay, {
document.documentElement.offsetHeight, document.documentElement.offsetHeight,
document.body.offsetHeight document.body.offsetHeight
); );
if (scrollHeight < offsetHeight) { if (scrollHeight < offsetHeight) {
return $(window).height() + 'px'; return $(window).height() + 'px';
} else { } else {
@ -527,7 +527,7 @@ $.extend($.ui.dialog.overlay, {
return $(document).height() + 'px'; return $(document).height() + 'px';
} }
}, },
width: function() { width: function() {
// handle IE 6 // handle IE 6
if ($.browser.msie && $.browser.version < 7) { if ($.browser.msie && $.browser.version < 7) {
@ -539,7 +539,7 @@ $.extend($.ui.dialog.overlay, {
document.documentElement.offsetWidth, document.documentElement.offsetWidth,
document.body.offsetWidth document.body.offsetWidth
); );
if (scrollWidth < offsetWidth) { if (scrollWidth < offsetWidth) {
return $(window).width() + 'px'; return $(window).width() + 'px';
} else { } else {
@ -556,7 +556,7 @@ $.extend($.ui.dialog.overlay, {
return $(document).width() + 'px'; return $(document).width() + 'px';
} }
}, },
resize: function() { resize: function() {
/* If the dialog is draggable and the user drags it past the /* If the dialog is draggable and the user drags it past the
* right edge of the window, the document becomes wider so we * right edge of the window, the document becomes wider so we
@ -570,7 +570,7 @@ $.extend($.ui.dialog.overlay, {
$.each($.ui.dialog.overlay.instances, function() { $.each($.ui.dialog.overlay.instances, function() {
$overlays = $overlays.add(this); $overlays = $overlays.add(this);
}); });
$overlays.css({ $overlays.css({
width: 0, width: 0,
height: 0 height: 0

View File

@ -14,9 +14,9 @@
(function($) { (function($) {
$.widget("ui.droppable", { $.widget("ui.droppable", {
_setData: function(key, value) { _setData: function(key, value) {
if(key == 'accept') { if(key == 'accept') {
this.options.accept = value && $.isFunction(value) ? value : function(d) { this.options.accept = value && $.isFunction(value) ? value : function(d) {
return d.is(accept); return d.is(accept);
@ -24,27 +24,27 @@ $.widget("ui.droppable", {
} else { } else {
$.widget.prototype._setData.apply(this, arguments); $.widget.prototype._setData.apply(this, arguments);
} }
}, },
_init: function() { _init: function() {
var o = this.options, accept = o.accept; var o = this.options, accept = o.accept;
this.isover = 0; this.isout = 1; this.isover = 0; this.isout = 1;
this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) { this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) {
return d.is(accept); return d.is(accept);
}; };
//Store the droppable's proportions //Store the droppable's proportions
this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
// Add the reference and positions to the manager // Add the reference and positions to the manager
$.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || []; $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || [];
$.ui.ddmanager.droppables[this.options.scope].push(this); $.ui.ddmanager.droppables[this.options.scope].push(this);
(this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable")); (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable"));
}, },
plugins: {}, plugins: {},
ui: function(c) { ui: function(c) {
@ -62,39 +62,39 @@ $.widget("ui.droppable", {
for ( var i = 0; i < drop.length; i++ ) for ( var i = 0; i < drop.length; i++ )
if ( drop[i] == this ) if ( drop[i] == this )
drop.splice(i, 1); drop.splice(i, 1);
this.element this.element
.removeClass("ui-droppable-disabled") .removeClass("ui-droppable-disabled")
.removeData("droppable") .removeData("droppable")
.unbind(".droppable"); .unbind(".droppable");
}, },
_over: function(event) { _over: function(event) {
var draggable = $.ui.ddmanager.current; 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 (!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))) { if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
$.ui.plugin.call(this, 'over', [event, this.ui(draggable)]); $.ui.plugin.call(this, 'over', [event, this.ui(draggable)]);
this.element.triggerHandler("dropover", [event, this.ui(draggable)], this.options.over); this.element.triggerHandler("dropover", [event, this.ui(draggable)], this.options.over);
} }
}, },
_out: function(event) { _out: function(event) {
var draggable = $.ui.ddmanager.current; 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 (!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))) { if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
$.ui.plugin.call(this, 'out', [event, this.ui(draggable)]); $.ui.plugin.call(this, 'out', [event, this.ui(draggable)]);
this.element.triggerHandler("dropout", [event, this.ui(draggable)], this.options.out); this.element.triggerHandler("dropout", [event, this.ui(draggable)], this.options.out);
} }
}, },
_drop: function(event,custom) { _drop: function(event,custom) {
var draggable = custom || $.ui.ddmanager.current; 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 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
var childrenIntersection = false; var childrenIntersection = false;
this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() { this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
var inst = $.data(this, 'droppable'); var inst = $.data(this, 'droppable');
@ -103,29 +103,29 @@ $.widget("ui.droppable", {
} }
}); });
if(childrenIntersection) return false; if(childrenIntersection) return false;
if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
$.ui.plugin.call(this, 'drop', [event, this.ui(draggable)]); $.ui.plugin.call(this, 'drop', [event, this.ui(draggable)]);
this.element.triggerHandler("drop", [event, this.ui(draggable)], this.options.drop); this.element.triggerHandler("drop", [event, this.ui(draggable)], this.options.drop);
return this.element; return this.element;
} }
return false; return false;
}, },
_activate: function(event) { _activate: function(event) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
$.ui.plugin.call(this, 'activate', [event, this.ui(draggable)]); $.ui.plugin.call(this, 'activate', [event, this.ui(draggable)]);
if(draggable) this.element.triggerHandler("dropactivate", [event, this.ui(draggable)], this.options.activate); if(draggable) this.element.triggerHandler("dropactivate", [event, this.ui(draggable)], this.options.activate);
}, },
_deactivate: function(event) { _deactivate: function(event) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
$.ui.plugin.call(this, 'deactivate', [event, this.ui(draggable)]); $.ui.plugin.call(this, 'deactivate', [event, this.ui(draggable)]);
if(draggable) this.element.triggerHandler("dropdeactivate", [event, this.ui(draggable)], this.options.deactivate); if(draggable) this.element.triggerHandler("dropdeactivate", [event, this.ui(draggable)], this.options.deactivate);
} }
}); });
@ -143,14 +143,14 @@ $.extend($.ui.droppable, {
}); });
$.ui.intersect = function(draggable, droppable, toleranceMode) { $.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) return false; if (!droppable.offset) return false;
var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, 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; y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
var l = droppable.offset.left, r = l + droppable.proportions.width, var l = droppable.offset.left, r = l + droppable.proportions.width,
t = droppable.offset.top, b = t + droppable.proportions.height; t = droppable.offset.top, b = t + droppable.proportions.height;
switch (toleranceMode) { switch (toleranceMode) {
case 'fit': case 'fit':
return (l < x1 && x2 < r return (l < x1 && x2 < r
@ -183,7 +183,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
return false; return false;
break; break;
} }
}; };
/* /*
@ -193,58 +193,58 @@ $.ui.ddmanager = {
current: null, current: null,
droppables: { 'default': [] }, droppables: { 'default': [] },
prepareOffsets: function(t, event) { prepareOffsets: function(t, event) {
var m = $.ui.ddmanager.droppables[t.options.scope]; var m = $.ui.ddmanager.droppables[t.options.scope];
var type = event ? event.type : null; // workaround for #2317 var type = event ? event.type : null; // workaround for #2317
var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
droppablesLoop: for (var i = 0; i < m.length; i++) { droppablesLoop: 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; //No disabled and non-accepted if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue; //No disabled and non-accepted
for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
m[i].offset = m[i].element.offset(); m[i].offset = m[i].element.offset();
m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
} }
}, },
drop: function(draggable, event) { drop: function(draggable, event) {
var dropped = false; var dropped = false;
$.each($.ui.ddmanager.droppables[draggable.options.scope], function() { $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
if(!this.options) return; if(!this.options) return;
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
dropped = this._drop.call(this, event); dropped = this._drop.call(this, event);
if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
this.isout = 1; this.isover = 0; this.isout = 1; this.isover = 0;
this._deactivate.call(this, event); this._deactivate.call(this, event);
} }
}); });
return dropped; return dropped;
}, },
drag: function(draggable, event) { drag: function(draggable, event) {
//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. //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, event); if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
//Run through all droppables and check their positions based on specific tolerance options //Run through all droppables and check their positions based on specific tolerance options
$.each($.ui.ddmanager.droppables[draggable.options.scope], function() { $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
if(this.options.disabled || this.greedyChild || !this.visible) return; if(this.options.disabled || this.greedyChild || !this.visible) return;
var intersects = $.ui.intersect(draggable, this, this.options.tolerance); var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null); var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
if(!c) return; if(!c) return;
var parentInstance; var parentInstance;
if (this.options.greedy) { if (this.options.greedy) {
var parent = this.element.parents(':data(droppable):eq(0)'); var parent = this.element.parents(':data(droppable):eq(0)');
@ -253,17 +253,17 @@ $.ui.ddmanager = {
parentInstance.greedyChild = (c == 'isover' ? 1 : 0); parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
} }
} }
// we just moved into a greedy child // we just moved into a greedy child
if (parentInstance && c == 'isover') { if (parentInstance && c == 'isover') {
parentInstance['isover'] = 0; parentInstance['isover'] = 0;
parentInstance['isout'] = 1; parentInstance['isout'] = 1;
parentInstance._out.call(parentInstance, event); parentInstance._out.call(parentInstance, event);
} }
this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
this[c == "isover" ? "_over" : "_out"].call(this, event); this[c == "isover" ? "_over" : "_out"].call(this, event);
// we just moved out of a greedy child // we just moved out of a greedy child
if (parentInstance && c == 'isout') { if (parentInstance && c == 'isout') {
parentInstance['isout'] = 0; parentInstance['isout'] = 0;
@ -271,7 +271,7 @@ $.ui.ddmanager = {
parentInstance._over.call(parentInstance, event); parentInstance._over.call(parentInstance, event);
} }
}); });
} }
}; };

View File

@ -14,14 +14,14 @@
$.widget("ui.progressbar", { $.widget("ui.progressbar", {
_init: function() { _init: function() {
this._interval = this.options.interval; this._interval = this.options.interval;
var self = this, var self = this,
options = this.options, options = this.options,
identifier = 'progressbar' + (++$.ui.progressbar.uuid), identifier = 'progressbar' + (++$.ui.progressbar.uuid),
text = options.text || '0%'; text = options.text || '0%';
this.element this.element
.addClass("ui-progressbar") .addClass("ui-progressbar")
.width(options.width) .width(options.width)
@ -31,17 +31,17 @@ $.widget("ui.progressbar", {
"aria-valuemax": 100, "aria-valuemax": 100,
"aria-valuenow": 0 "aria-valuenow": 0
}); });
$.extend(this, { $.extend(this, {
active: false, active: false,
pixelState: 0, pixelState: 0,
percentState: 0, percentState: 0,
identifier: identifier identifier: identifier
}); });
this.wrapper = $('<div class="ui-progressbar-wrap"></div>') this.wrapper = $('<div class="ui-progressbar-wrap"></div>')
.appendTo(this.element); .appendTo(this.element);
this.bar = $('<div class="ui-progressbar-bar ui-hidden"></div>') this.bar = $('<div class="ui-progressbar-bar ui-hidden"></div>')
.css({ .css({
width: 0, width: 0,
@ -49,7 +49,7 @@ $.widget("ui.progressbar", {
zIndex: 100 zIndex: 100
}) })
.appendTo(this.wrapper); .appendTo(this.wrapper);
this.textElement = $('<div class="ui-progressbar-text"></div>') this.textElement = $('<div class="ui-progressbar-text"></div>')
.html(text) .html(text)
.css({ .css({
@ -57,7 +57,7 @@ $.widget("ui.progressbar", {
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo(this.bar); .appendTo(this.bar);
this.textBg = $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>') this.textBg = $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>')
.html(text) .html(text)
.css({ .css({
@ -70,7 +70,7 @@ $.widget("ui.progressbar", {
var self = this, var self = this,
options = this.options, options = this.options,
interval = options.interval; interval = options.interval;
this.bar.animate( this.bar.animate(
{ {
width: options.width width: options.width
@ -97,15 +97,15 @@ $.widget("ui.progressbar", {
} }
); );
}, },
destroy: function() { destroy: function() {
this.stop(); this.stop();
this.element this.element
.removeClass("ui-progressbar ui-progressbar-disabled") .removeClass("ui-progressbar ui-progressbar-disabled")
.removeData("progressbar").unbind(".progressbar") .removeData("progressbar").unbind(".progressbar")
.find('.ui-progressbar-wrap').remove(); .find('.ui-progressbar-wrap').remove();
delete $.easing[this.identifier]; delete $.easing[this.identifier];
}, },
@ -114,27 +114,27 @@ $.widget("ui.progressbar", {
this.disabled = true; this.disabled = true;
this.element.attr("aria-disabled", true); this.element.attr("aria-disabled", true);
}, },
enable: function() { enable: function() {
this.element.removeClass("ui-progressbar-disabled"); this.element.removeClass("ui-progressbar-disabled");
this.disabled = false; this.disabled = false;
this.element.attr("aria-disabled", false); this.element.attr("aria-disabled", false);
}, },
pause: function() { pause: function() {
if (this.disabled) return; if (this.disabled) return;
this.bar.stop(); this.bar.stop();
this._trigger('pause', null, this.ui()); this._trigger('pause', null, this.ui());
}, },
progress: function(percentState) { progress: function(percentState) {
this.bar.removeClass('ui-hidden'); this.bar.removeClass('ui-hidden');
this.percentState = percentState > 100 ? 100 : percentState; this.percentState = percentState > 100 ? 100 : percentState;
this.pixelState = (this.percentState/100) * this.options.width; this.pixelState = (this.percentState/100) * this.options.width;
this.bar.width(this.pixelState); this.bar.width(this.pixelState);
this.textElement.width(this.pixelState); this.textElement.width(this.pixelState);
var percent = Math.round(this.percentState); var percent = Math.round(this.percentState);
if (this.options.range && !this.options.text) { if (this.options.range && !this.options.text) {
this._setText(percent + '%'); this._setText(percent + '%');
@ -142,14 +142,14 @@ $.widget("ui.progressbar", {
this.element.attr("aria-valuenow", percent); this.element.attr("aria-valuenow", percent);
this._trigger('progress', null, this.ui()); this._trigger('progress', null, this.ui());
}, },
start: function() { start: function() {
var self = this, options = this.options; var self = this, options = this.options;
if (this.disabled) { if (this.disabled) {
return; return;
} }
$.easing[this.identifier] = function (x, t, b, c, d) { $.easing[this.identifier] = function (x, t, b, c, d) {
var inc = options.increment, var inc = options.increment,
width = options.width, width = options.width,
@ -157,26 +157,26 @@ $.widget("ui.progressbar", {
state = Math.round(x/step)*step; state = Math.round(x/step)*step;
return state > 1 ? 1 : state; return state > 1 ? 1 : state;
}; };
self.active = true; self.active = true;
if (options.duration < options.interval) { if (options.duration < options.interval) {
options.duration = options.interval; options.duration = options.interval;
} }
setTimeout( setTimeout(
function() { function() {
self.active = false; self.active = false;
}, },
options.duration options.duration
); );
this._animate(); this._animate();
this._trigger('start', null, this.ui()); this._trigger('start', null, this.ui());
return false; return false;
}, },
stop: function() { stop: function() {
this.bar.stop(); this.bar.stop();
this.bar.width(0); this.bar.width(0);
@ -185,7 +185,7 @@ $.widget("ui.progressbar", {
this.options.interval = this._interval; this.options.interval = this._interval;
this._trigger('stop', null, this.ui()); this._trigger('stop', null, this.ui());
}, },
ui: function() { ui: function() {
return { return {
options: this.options, options: this.options,
@ -193,17 +193,17 @@ $.widget("ui.progressbar", {
percentState: this.percentState percentState: this.percentState
}; };
}, },
_setData: function(key, value){ _setData: function(key, value){
switch (key) { switch (key) {
case 'text': case 'text':
this._setText(value); this._setText(value);
break; break;
} }
$.widget.prototype._setData.apply(this, arguments); $.widget.prototype._setData.apply(this, arguments);
}, },
_setText: function(text){ _setText: function(text){
this.textElement.add(this.textBg).html(text); this.textElement.add(this.textBg).html(text);
} }
@ -219,7 +219,7 @@ $.extend($.ui.progressbar, {
range: true, range: true,
text: '' text: ''
}, },
uuid: 0 uuid: 0
}); });

View File

@ -14,25 +14,25 @@
$.widget("ui.resizable", $.extend({}, $.ui.mouse, { $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
_init: function() { _init: function() {
var self = this, o = this.options; var self = this, o = this.options;
var elpos = this.element.css('position'); var elpos = this.element.css('position');
this.originalElement = this.element; this.originalElement = this.element;
// simulate .ui-resizable { position: relative; } // simulate .ui-resizable { position: relative; }
this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos }); this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos });
$.extend(o, { $.extend(o, {
_aspectRatio: !!(o.aspectRatio), _aspectRatio: !!(o.aspectRatio),
helper: o.helper || o.ghost || o.animate ? o.helper || 'proxy' : null, helper: o.helper || o.ghost || o.animate ? o.helper || 'proxy' : null,
knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles
}); });
//Default Theme //Default Theme
var aBorder = '1px solid #DEDEDE'; var aBorder = '1px solid #DEDEDE';
o.defaultTheme = { o.defaultTheme = {
'ui-resizable': { display: 'block' }, 'ui-resizable': { display: 'block' },
'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' }, 'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },
@ -45,7 +45,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder }, 'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder },
'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder } 'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder }
}; };
o.knobTheme = { o.knobTheme = {
'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' }, 'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' },
'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' }, 'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' },
@ -57,17 +57,17 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' }, 'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' },
'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' } 'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' }
}; };
o._nodeName = this.element[0].nodeName; o._nodeName = this.element[0].nodeName;
//Wrap the element if it cannot hold child nodes //Wrap the element if it cannot hold child nodes
if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) { if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) {
var el = this.element; var el = this.element;
//Opera fixing relative position //Opera fixing relative position
if (/relative/.test(el.css('position')) && $.browser.opera) if (/relative/.test(el.css('position')) && $.browser.opera)
el.css({ position: 'relative', top: 'auto', left: 'auto' }); el.css({ position: 'relative', top: 'auto', left: 'auto' });
//Create a wrapper element and set the wrapper to the new current internal element //Create a wrapper element and set the wrapper to the new current internal element
el.wrap( el.wrap(
$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( { $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( {
@ -78,40 +78,40 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
left: el.css('left') left: el.css('left')
}) })
); );
var oel = this.element; this.element = this.element.parent(); var oel = this.element; this.element = this.element.parent();
// store instance on wrapper // store instance on wrapper
this.element.data('resizable', this); this.element.data('resizable', this);
//Move margins to the wrapper //Move margins to the wrapper
this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"), this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),
marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom") marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")
}); });
oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
//Prevent Safari textarea resize //Prevent Safari textarea resize
if ($.browser.safari && o.preventDefault) oel.css('resize', 'none'); if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');
o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' }); o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });
// avoid IE jump // avoid IE jump
this.element.css({ margin: oel.css('margin') }); this.element.css({ margin: oel.css('margin') });
// fix handlers offset // fix handlers offset
this._proportionallyResize(); this._proportionallyResize();
} }
if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }; if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' };
if(o.handles.constructor == String) { if(o.handles.constructor == String) {
o.zIndex = o.zIndex || 1000; o.zIndex = o.zIndex || 1000;
if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw'; if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';
var n = o.handles.split(","); o.handles = {}; var n = o.handles.split(","); o.handles = {};
// insertions are applied when don't have theme loaded // insertions are applied when don't have theme loaded
var insertionsDefault = { var insertionsDefault = {
handle: 'position: absolute; display: none; overflow:hidden;', handle: 'position: absolute; display: none; overflow:hidden;',
@ -124,18 +124,18 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
ne: 'top: 0pt; right: 0px;', ne: 'top: 0pt; right: 0px;',
nw: 'top: 0pt; left: 0px;' nw: 'top: 0pt; left: 0px;'
}; };
for(var i = 0; i < n.length; i++) { for(var i = 0; i < n.length; i++) {
var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'),
allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {}); allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});
// increase zIndex of sw, se, ne, nw axis // increase zIndex of sw, se, ne, nw axis
var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {}; var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {};
var defCss = (loadDefault ? insertionsDefault[handle] : ''), var defCss = (loadDefault ? insertionsDefault[handle] : ''),
axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex ); axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex );
o.handles[handle] = '.ui-resizable-'+handle; o.handles[handle] = '.ui-resizable-'+handle;
this.element.append( this.element.append(
//Theme detection, if not loaded, load o.defaultTheme //Theme detection, if not loaded, load o.defaultTheme
axis.css( loadDefault ? allDefTheme : {} ) axis.css( loadDefault ? allDefTheme : {} )
@ -143,50 +143,50 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
.css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles) .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles)
); );
} }
if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} ); if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );
} }
this._renderAxis = function(target) { this._renderAxis = function(target) {
target = target || this.element; target = target || this.element;
for(var i in o.handles) { for(var i in o.handles) {
if(o.handles[i].constructor == String) if(o.handles[i].constructor == String)
o.handles[i] = $(o.handles[i], this.element).show(); o.handles[i] = $(o.handles[i], this.element).show();
if (o.transparent) if (o.transparent)
o.handles[i].css({opacity:0}); o.handles[i].css({opacity:0});
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
if (this.element.is('.ui-wrapper') && if (this.element.is('.ui-wrapper') &&
o._nodeName.match(/textarea|input|select|button/i)) { o._nodeName.match(/textarea|input|select|button/i)) {
var axis = $(o.handles[i], this.element), padWrapper = 0; var axis = $(o.handles[i], this.element), padWrapper = 0;
//Checking the correct pad and border //Checking the correct pad and border
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
//The padding type i have to apply... //The padding type i have to apply...
var padPos = [ 'padding', var padPos = [ 'padding',
/ne|nw|n/.test(i) ? 'Top' : /ne|nw|n/.test(i) ? 'Top' :
/se|sw|s/.test(i) ? 'Bottom' : /se|sw|s/.test(i) ? 'Bottom' :
/^e$/.test(i) ? 'Right' : 'Left' ].join(""); /^e$/.test(i) ? 'Right' : 'Left' ].join("");
if (!o.transparent) if (!o.transparent)
target.css(padPos, padWrapper); target.css(padPos, padWrapper);
this._proportionallyResize(); this._proportionallyResize();
} }
if(!$(o.handles[i]).length) continue; if(!$(o.handles[i]).length) continue;
} }
}; };
this._renderAxis(this.element); this._renderAxis(this.element);
o._handles = $('.ui-resizable-handle', self.element); o._handles = $('.ui-resizable-handle', self.element);
if (o.disableSelection) if (o.disableSelection)
o._handles.disableSelection(); o._handles.disableSelection();
//Matching axis name //Matching axis name
o._handles.mouseover(function() { o._handles.mouseover(function() {
if (!o.resizing) { if (!o.resizing) {
@ -196,7 +196,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
self.axis = o.axis = axis && axis[1] ? axis[1] : 'se'; self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';
} }
}); });
//If we want to auto hide the elements //If we want to auto hide the elements
if (o.autoHide) { if (o.autoHide) {
o._handles.hide(); o._handles.hide();
@ -211,7 +211,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
} }
}); });
} }
this._mouseInit(); this._mouseInit();
}, },
plugins: {}, plugins: {},
@ -233,16 +233,16 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
}, },
destroy: function() { destroy: function() {
var el = this.element, wrapped = el.children(".ui-resizable").get(0); var el = this.element, wrapped = el.children(".ui-resizable").get(0);
this._mouseDestroy(); this._mouseDestroy();
var _destroy = function(exp) { var _destroy = function(exp) {
$(exp).removeClass("ui-resizable ui-resizable-disabled") $(exp).removeClass("ui-resizable ui-resizable-disabled")
.removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
}; };
_destroy(el); _destroy(el);
if (el.is('.ui-wrapper') && wrapped) { if (el.is('.ui-wrapper') && wrapped) {
el.parent().append( el.parent().append(
$(wrapped).css({ $(wrapped).css({
@ -253,55 +253,55 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
left: el.css('left') left: el.css('left')
}) })
).end().remove(); ).end().remove();
_destroy(wrapped); _destroy(wrapped);
} }
}, },
_mouseCapture: function(event) { _mouseCapture: function(event) {
if(this.options.disabled) return false; if(this.options.disabled) return false;
var handle = false; var handle = false;
for(var i in this.options.handles) { for(var i in this.options.handles) {
if($(this.options.handles[i])[0] == event.target) handle = true; if($(this.options.handles[i])[0] == event.target) handle = true;
} }
if (!handle) return false; if (!handle) return false;
return true; return true;
}, },
_mouseStart: function(event) { _mouseStart: function(event) {
var o = this.options, iniPos = this.element.position(), el = this.element, var o = this.options, iniPos = this.element.position(), el = this.element,
num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7; num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;
o.resizing = true; o.resizing = true;
o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
// bugfix #1749 // bugfix #1749
if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
// sOffset decides if document scrollOffset will be added to the top/left of the resizable element // sOffset decides if document scrollOffset will be added to the top/left of the resizable element
var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position')); var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));
var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0; var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;
el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) }); el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });
} }
//Opera fixing relative position //Opera fixing relative position
if ($.browser.opera && (/relative/).test(el.css('position'))) if ($.browser.opera && (/relative/).test(el.css('position')))
el.css({ position: 'relative', top: 'auto', left: 'auto' }); el.css({ position: 'relative', top: 'auto', left: 'auto' });
this._renderProxy(); this._renderProxy();
var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
if (o.containment) { if (o.containment) {
curleft += $(o.containment).scrollLeft()||0; curleft += $(o.containment).scrollLeft()||0;
curtop += $(o.containment).scrollTop()||0; curtop += $(o.containment).scrollTop()||0;
} }
//Store needed variables //Store needed variables
this.offset = this.helper.offset(); this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop }; this.position = { left: curleft, top: curtop };
@ -310,79 +310,79 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
this.originalPosition = { left: curleft, top: curtop }; this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
this.originalMousePosition = { left: event.pageX, top: event.pageY }; this.originalMousePosition = { left: event.pageX, top: event.pageY };
//Aspect Ratio //Aspect Ratio
o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1); o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1);
if (o.preserveCursor) if (o.preserveCursor)
$('body').css('cursor', this.axis + '-resize'); $('body').css('cursor', this.axis + '-resize');
this._propagate("start", event); this._propagate("start", event);
return true; return true;
}, },
_mouseDrag: function(event) { _mouseDrag: function(event) {
//Increase performance, avoid regex //Increase performance, avoid regex
var el = this.helper, o = this.options, props = {}, var el = this.helper, o = this.options, props = {},
self = this, smp = this.originalMousePosition, a = this.axis; self = this, smp = this.originalMousePosition, a = this.axis;
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
var trigger = this._change[a]; var trigger = this._change[a];
if (!trigger) return false; if (!trigger) return false;
// Calculate the attrs that will be change // Calculate the attrs that will be change
var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
if (o._aspectRatio || event.shiftKey) if (o._aspectRatio || event.shiftKey)
data = this._updateRatio(data, event); data = this._updateRatio(data, event);
data = this._respectSize(data, event); data = this._respectSize(data, event);
// plugins callbacks need to be called first // plugins callbacks need to be called first
this._propagate("resize", event); this._propagate("resize", event);
el.css({ el.css({
top: this.position.top + "px", left: this.position.left + "px", top: this.position.top + "px", left: this.position.left + "px",
width: this.size.width + "px", height: this.size.height + "px" width: this.size.width + "px", height: this.size.height + "px"
}); });
if (!o.helper && o.proportionallyResize) if (!o.helper && o.proportionallyResize)
this._proportionallyResize(); this._proportionallyResize();
this._updateCache(data); this._updateCache(data);
// calling the user callback at the end // calling the user callback at the end
this.element.triggerHandler("resize", [event, this.ui()], this.options["resize"]); this.element.triggerHandler("resize", [event, this.ui()], this.options["resize"]);
return false; return false;
}, },
_mouseStop: function(event) { _mouseStop: function(event) {
this.options.resizing = false; this.options.resizing = false;
var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this; var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;
if(o.helper) { if(o.helper) {
var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName),
soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
soffsetw = ista ? 0 : self.sizeDiff.width; soffsetw = ista ? 0 : self.sizeDiff.width;
var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
if (!o.animate) if (!o.animate)
this.element.css($.extend(s, { top: top, left: left })); this.element.css($.extend(s, { top: top, left: left }));
if (o.helper && !o.animate) this._proportionallyResize(); if (o.helper && !o.animate) this._proportionallyResize();
} }
if (o.preserveCursor) if (o.preserveCursor)
$('body').css('cursor', 'auto'); $('body').css('cursor', 'auto');
this._propagate("stop", event); this._propagate("stop", event);
if (o.helper) this.helper.remove(); if (o.helper) this.helper.remove();
return false; return false;
}, },
_updateCache: function(data) { _updateCache: function(data) {
@ -394,12 +394,12 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
if (data.width) this.size.width = data.width; if (data.width) this.size.width = data.width;
}, },
_updateRatio: function(data, event) { _updateRatio: function(data, event) {
var o = this.options, cpos = this.position, csize = this.size, a = this.axis; var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
if (data.height) data.width = (csize.height * o.aspectRatio); if (data.height) data.width = (csize.height * o.aspectRatio);
else if (data.width) data.height = (csize.width / o.aspectRatio); else if (data.width) data.height = (csize.width / o.aspectRatio);
if (a == 'sw') { if (a == 'sw') {
data.left = cpos.left + (csize.width - data.width); data.left = cpos.left + (csize.width - data.width);
data.top = null; data.top = null;
@ -408,44 +408,44 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
data.top = cpos.top + (csize.height - data.height); data.top = cpos.top + (csize.height - data.height);
data.left = cpos.left + (csize.width - data.width); data.left = cpos.left + (csize.width - data.width);
} }
return data; return data;
}, },
_respectSize: function(data, event) { _respectSize: function(data, event) {
var el = this.helper, o = this.options, pRatio = o._aspectRatio || event.shiftKey, a = this.axis, var el = this.helper, o = this.options, pRatio = o._aspectRatio || event.shiftKey, a = this.axis,
ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height, ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height,
isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height; isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height;
if (isminw) data.width = o.minWidth; if (isminw) data.width = o.minWidth;
if (isminh) data.height = o.minHeight; if (isminh) data.height = o.minHeight;
if (ismaxw) data.width = o.maxWidth; if (ismaxw) data.width = o.maxWidth;
if (ismaxh) data.height = o.maxHeight; if (ismaxh) data.height = o.maxHeight;
var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
if (isminw && cw) data.left = dw - o.minWidth; if (isminw && cw) data.left = dw - o.minWidth;
if (ismaxw && cw) data.left = dw - o.maxWidth; if (ismaxw && cw) data.left = dw - o.maxWidth;
if (isminh && ch) data.top = dh - o.minHeight; if (isminh && ch) data.top = dh - o.minHeight;
if (ismaxh && ch) data.top = dh - o.maxHeight; if (ismaxh && ch) data.top = dh - o.maxHeight;
// fixing jump error on top/left - bug #2330 // fixing jump error on top/left - bug #2330
var isNotwh = !data.width && !data.height; var isNotwh = !data.width && !data.height;
if (isNotwh && !data.left && data.top) data.top = null; if (isNotwh && !data.left && data.top) data.top = null;
else if (isNotwh && !data.top && data.left) data.left = null; else if (isNotwh && !data.top && data.left) data.left = null;
return data; return data;
}, },
_proportionallyResize: function() { _proportionallyResize: function() {
var o = this.options; var o = this.options;
if (!o.proportionallyResize) return; if (!o.proportionallyResize) return;
var prel = o.proportionallyResize, el = this.helper || this.element; var prel = o.proportionallyResize, el = this.helper || this.element;
if (!o.borderDif) { if (!o.borderDif) {
var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
o.borderDif = $.map(b, function(v, i) { o.borderDif = $.map(b, function(v, i) {
var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
return border + padding; return border + padding;
@ -459,14 +459,14 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
_renderProxy: function() { _renderProxy: function() {
var el = this.element, o = this.options; var el = this.element, o = this.options;
this.elementOffset = el.offset(); this.elementOffset = el.offset();
if(o.helper) { if(o.helper) {
this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
// fix ie6 offset // fix ie6 offset
var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
pxyoffset = ( ie6 ? 2 : -1 ); pxyoffset = ( ie6 ? 2 : -1 );
this.helper.addClass(o.helper).css({ this.helper.addClass(o.helper).css({
width: el.outerWidth() + pxyoffset, width: el.outerWidth() + pxyoffset,
height: el.outerHeight() + pxyoffset, height: el.outerHeight() + pxyoffset,
@ -475,12 +475,12 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
top: this.elementOffset.top - ie6offset +'px', top: this.elementOffset.top - ie6offset +'px',
zIndex: ++o.zIndex zIndex: ++o.zIndex
}); });
this.helper.appendTo("body"); this.helper.appendTo("body");
if (o.disableSelection) if (o.disableSelection)
$.ui.disableSelection(this.helper.get(0)); $.ui.disableSelection(this.helper.get(0));
} else { } else {
this.helper = el; this.helper = el;
} }
@ -548,95 +548,95 @@ $.extend($.ui.resizable, {
*/ */
$.ui.plugin.add("resizable", "containment", { $.ui.plugin.add("resizable", "containment", {
start: function(event, ui) { start: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"), el = self.element; var o = ui.options, self = $(this).data("resizable"), el = self.element;
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
if (!ce) return; if (!ce) return;
self.containerElement = $(ce); self.containerElement = $(ce);
if (/document/.test(oc) || oc == document) { if (/document/.test(oc) || oc == document) {
self.containerOffset = { left: 0, top: 0 }; self.containerOffset = { left: 0, top: 0 };
self.containerPosition = { left: 0, top: 0 }; self.containerPosition = { left: 0, top: 0 };
self.parentData = { self.parentData = {
element: $(document), left: 0, top: 0, element: $(document), left: 0, top: 0,
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
}; };
} }
// i'm a node, so compute top, left, right, bottom // i'm a node, so compute top, left, right, bottom
else{ else{
self.containerOffset = $(ce).offset(); self.containerOffset = $(ce).offset();
self.containerPosition = $(ce).position(); self.containerPosition = $(ce).position();
self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() }; self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() };
var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
self.parentData = { self.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height element: ce, left: co.left, top: co.top, width: width, height: height
}; };
} }
}, },
resize: function(event, ui) { resize: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"), var o = ui.options, self = $(this).data("resizable"),
ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
if (ce[0] != document && (/static/).test(ce.css('position'))) if (ce[0] != document && (/static/).test(ce.css('position')))
cop = self.containerPosition; cop = self.containerPosition;
if (cp.left < (o.helper ? co.left : cop.left)) { if (cp.left < (o.helper ? co.left : cop.left)) {
self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left)); self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left));
if (pRatio) self.size.height = self.size.width / o.aspectRatio; if (pRatio) self.size.height = self.size.width / o.aspectRatio;
self.position.left = o.helper ? co.left : cop.left; self.position.left = o.helper ? co.left : cop.left;
} }
if (cp.top < (o.helper ? co.top : 0)) { if (cp.top < (o.helper ? co.top : 0)) {
self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top); self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top);
if (pRatio) self.size.width = self.size.height * o.aspectRatio; if (pRatio) self.size.width = self.size.height * o.aspectRatio;
self.position.top = o.helper ? co.top : 0; self.position.top = o.helper ? co.top : 0;
} }
var woset = (o.helper ? self.offset.left - co.left : (self.position.left - cop.left)) + self.sizeDiff.width, var woset = (o.helper ? self.offset.left - co.left : (self.position.left - cop.left)) + self.sizeDiff.width,
hoset = (o.helper ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height; hoset = (o.helper ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height;
if (woset + self.size.width >= self.parentData.width) { if (woset + self.size.width >= self.parentData.width) {
self.size.width = self.parentData.width - woset; self.size.width = self.parentData.width - woset;
if (pRatio) self.size.height = self.size.width / o.aspectRatio; if (pRatio) self.size.height = self.size.width / o.aspectRatio;
} }
if (hoset + self.size.height >= self.parentData.height) { if (hoset + self.size.height >= self.parentData.height) {
self.size.height = self.parentData.height - hoset; self.size.height = self.parentData.height - hoset;
if (pRatio) self.size.width = self.size.height * o.aspectRatio; if (pRatio) self.size.width = self.size.height * o.aspectRatio;
} }
}, },
stop: function(event, ui){ stop: function(event, ui){
var o = ui.options, self = $(this).data("resizable"), cp = self.position, var o = ui.options, self = $(this).data("resizable"), cp = self.position,
co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
var helper = $(self.helper), ho = helper.offset(), w = helper.innerWidth(), h = helper.innerHeight(); var helper = $(self.helper), ho = helper.offset(), w = helper.innerWidth(), h = helper.innerHeight();
if (o.helper && !o.animate && (/relative/).test(ce.css('position'))) if (o.helper && !o.animate && (/relative/).test(ce.css('position')))
$(this).css({ left: (ho.left - co.left), top: (ho.top - co.top), width: w, height: h }); $(this).css({ left: (ho.left - co.left), top: (ho.top - co.top), width: w, height: h });
if (o.helper && !o.animate && (/static/).test(ce.css('position'))) if (o.helper && !o.animate && (/static/).test(ce.css('position')))
$(this).css({ left: cop.left + (ho.left - co.left), top: cop.top + (ho.top - co.top), width: w, height: h }); $(this).css({ left: cop.left + (ho.left - co.left), top: cop.top + (ho.top - co.top), width: w, height: h });
} }
}); });
$.ui.plugin.add("resizable", "grid", { $.ui.plugin.add("resizable", "grid", {
resize: function(event, ui) { resize: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
if (/^(se|s|e)$/.test(a)) { if (/^(se|s|e)$/.test(a)) {
self.size.width = os.width + ox; self.size.width = os.width + ox;
self.size.height = os.height + oy; self.size.height = os.height + oy;
@ -658,84 +658,84 @@ $.ui.plugin.add("resizable", "grid", {
self.position.left = op.left - ox; self.position.left = op.left - ox;
} }
} }
}); });
$.ui.plugin.add("resizable", "animate", { $.ui.plugin.add("resizable", "animate", {
stop: function(event, ui) { stop: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"); var o = ui.options, self = $(this).data("resizable");
var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName),
soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
soffsetw = ista ? 0 : self.sizeDiff.width; soffsetw = ista ? 0 : self.sizeDiff.width;
var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
self.element.animate( self.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), { $.extend(style, top && left ? { top: top, left: left } : {}), {
duration: o.animateDuration, duration: o.animateDuration,
easing: o.animateEasing, easing: o.animateEasing,
step: function() { step: function() {
var data = { var data = {
width: parseInt(self.element.css('width'), 10), width: parseInt(self.element.css('width'), 10),
height: parseInt(self.element.css('height'), 10), height: parseInt(self.element.css('height'), 10),
top: parseInt(self.element.css('top'), 10), top: parseInt(self.element.css('top'), 10),
left: parseInt(self.element.css('left'), 10) left: parseInt(self.element.css('left'), 10)
}; };
if (pr) pr.css({ width: data.width, height: data.height }); if (pr) pr.css({ width: data.width, height: data.height });
// propagating resize, and updating values for each animation step // propagating resize, and updating values for each animation step
self._updateCache(data); self._updateCache(data);
self._propagate("animate", event); self._propagate("animate", event);
} }
} }
); );
} }
}); });
$.ui.plugin.add("resizable", "ghost", { $.ui.plugin.add("resizable", "ghost", {
start: function(event, ui) { start: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size; var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size;
if (!pr) self.ghost = self.element.clone(); if (!pr) self.ghost = self.element.clone();
else self.ghost = pr.clone(); else self.ghost = pr.clone();
self.ghost.css( self.ghost.css(
{ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 } { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }
) )
.addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : ''); .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : '');
self.ghost.appendTo(self.helper); self.ghost.appendTo(self.helper);
}, },
resize: function(event, ui){ resize: function(event, ui){
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
}, },
stop: function(event, ui){ stop: function(event, ui){
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
} }
}); });
$.ui.plugin.add("resizable", "alsoResize", { $.ui.plugin.add("resizable", "alsoResize", {
start: function(event, ui) { start: function(event, ui) {
var o = ui.options, self = $(this).data("resizable"), var o = ui.options, self = $(this).data("resizable"),
_store = function(exp) { _store = function(exp) {
$(exp).each(function() { $(exp).each(function() {
$(this).data("resizable-alsoresize", { $(this).data("resizable-alsoresize", {
@ -744,7 +744,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
}); });
}); });
}; };
if (typeof(o.alsoResize) == 'object') { if (typeof(o.alsoResize) == 'object') {
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); }
@ -752,19 +752,19 @@ $.ui.plugin.add("resizable", "alsoResize", {
_store(o.alsoResize); _store(o.alsoResize);
} }
}, },
resize: function(event, ui){ resize: function(event, ui){
var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition; var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition;
var delta = { var delta = {
height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
}, },
_alsoResize = function(exp, c) { _alsoResize = function(exp, c) {
$(exp).each(function() { $(exp).each(function() {
var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
$.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {
var sum = (start[prop]||0) + (delta[prop]||0); var sum = (start[prop]||0) + (delta[prop]||0);
if (sum && sum >= 0) if (sum && sum >= 0)
@ -773,14 +773,14 @@ $.ui.plugin.add("resizable", "alsoResize", {
$(this).css(style); $(this).css(style);
}); });
}; };
if (typeof(o.alsoResize) == 'object') { if (typeof(o.alsoResize) == 'object') {
$.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
}else{ }else{
_alsoResize(o.alsoResize); _alsoResize(o.alsoResize);
} }
}, },
stop: function(event, ui){ stop: function(event, ui){
$(this).removeData("resizable-alsoresize-start"); $(this).removeData("resizable-alsoresize-start");
} }

View File

@ -15,11 +15,11 @@
$.widget("ui.selectable", $.extend({}, $.ui.mouse, { $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
_init: function() { _init: function() {
var self = this; var self = this;
this.element.addClass("ui-selectable"); this.element.addClass("ui-selectable");
this.dragged = false; this.dragged = false;
// cache selectee children based on filter // cache selectee children based on filter
var selectees; var selectees;
this.refresh = function() { this.refresh = function() {
@ -42,11 +42,11 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
}); });
}; };
this.refresh(); this.refresh();
this.selectees = selectees.addClass("ui-selectee"); this.selectees = selectees.addClass("ui-selectee");
this._mouseInit(); this._mouseInit();
this.helper = $(document.createElement('div')) this.helper = $(document.createElement('div'))
.css({border:'1px dotted black'}) .css({border:'1px dotted black'})
.addClass("ui-selectable-helper"); .addClass("ui-selectable-helper");
@ -67,22 +67,22 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
}, },
_mouseStart: function(event) { _mouseStart: function(event) {
var self = this; var self = this;
this.opos = [event.pageX, event.pageY]; this.opos = [event.pageX, event.pageY];
if (this.options.disabled) if (this.options.disabled)
return; return;
var options = this.options; var options = this.options;
this.selectees = $(options.filter, this.element[0]); this.selectees = $(options.filter, this.element[0]);
// selectable START callback // selectable START callback
this.element.triggerHandler("selectablestart", [event, { this.element.triggerHandler("selectablestart", [event, {
"selectable": this.element[0], "selectable": this.element[0],
"options": options "options": options
}], options.start); }], options.start);
$('body').append(this.helper); $('body').append(this.helper);
// position helper (lasso) // position helper (lasso)
this.helper.css({ this.helper.css({
@ -93,11 +93,11 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
"width": 0, "width": 0,
"height": 0 "height": 0
}); });
if (options.autoRefresh) { if (options.autoRefresh) {
this.refresh(); this.refresh();
} }
this.selectees.filter('.ui-selected').each(function() { this.selectees.filter('.ui-selected').each(function() {
var selectee = $.data(this, "selectable-item"); var selectee = $.data(this, "selectable-item");
selectee.startselected = true; selectee.startselected = true;
@ -114,7 +114,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
}], options.unselecting); }], options.unselecting);
} }
}); });
var isSelectee = false; var isSelectee = false;
$(event.target).parents().andSelf().each(function() { $(event.target).parents().andSelf().each(function() {
if($.data(this, "selectable-item")) isSelectee = true; if($.data(this, "selectable-item")) isSelectee = true;
@ -124,17 +124,17 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
_mouseDrag: function(event) { _mouseDrag: function(event) {
var self = this; var self = this;
this.dragged = true; this.dragged = true;
if (this.options.disabled) if (this.options.disabled)
return; return;
var options = this.options; var options = this.options;
var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY; var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; } if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
if (y1 > y2) { var tmp = y2; y2 = y1; y1 = 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.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
this.selectees.each(function() { this.selectees.each(function() {
var selectee = $.data(this, "selectable-item"); var selectee = $.data(this, "selectable-item");
//prevent helper from being selected if appendTo: selectable //prevent helper from being selected if appendTo: selectable
@ -146,7 +146,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
} else if (options.tolerance == 'fit') { } else if (options.tolerance == 'fit') {
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
} }
if (hit) { if (hit) {
// SELECT // SELECT
if (selectee.selected) { if (selectee.selected) {
@ -207,16 +207,16 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
} }
} }
}); });
return false; return false;
}, },
_mouseStop: function(event) { _mouseStop: function(event) {
var self = this; var self = this;
this.dragged = false; this.dragged = false;
var options = this.options; var options = this.options;
$('.ui-unselecting', this.element[0]).each(function() { $('.ui-unselecting', this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item"); var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass('ui-unselecting'); selectee.$element.removeClass('ui-unselecting');
@ -244,9 +244,9 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
selectable: self.element[0], selectable: self.element[0],
options: this.options options: this.options
}], this.options.stop); }], this.options.stop);
this.helper.remove(); this.helper.remove();
return false; return false;
} }
})); }));

View File

@ -36,12 +36,12 @@ $.widget("ui.slider", {
this.element.triggerHandler(n == "slide" ? n : "slide"+n, [event, this.ui()], this.options[n]); this.element.triggerHandler(n == "slide" ? n : "slide"+n, [event, this.ui()], this.options[n]);
}, },
destroy: function() { destroy: function() {
this.element this.element
.removeClass("ui-slider ui-slider-disabled") .removeClass("ui-slider ui-slider-disabled")
.removeData("slider") .removeData("slider")
.unbind(".slider"); .unbind(".slider");
if(this.handle && this.handle.length) { if(this.handle && this.handle.length) {
this.handle this.handle
.unwrap("a"); .unwrap("a");
@ -50,28 +50,28 @@ $.widget("ui.slider", {
mouse && mouse._mouseDestroy(); mouse && mouse._mouseDestroy();
}); });
} }
this.generated && this.generated.remove(); this.generated && this.generated.remove();
}, },
_setData: function(key, value) { _setData: function(key, value) {
$.widget.prototype._setData.apply(this, arguments); $.widget.prototype._setData.apply(this, arguments);
if (/min|max|steps/.test(key)) { if (/min|max|steps/.test(key)) {
this._initBoundaries(); this._initBoundaries();
} }
if(key == "range") { if(key == "range") {
value ? this.handle.length == 2 && this._createRange() : this._removeRange(); value ? this.handle.length == 2 && this._createRange() : this._removeRange();
} }
}, },
_init: function() { _init: function() {
var self = this; var self = this;
this.element.addClass("ui-slider"); this.element.addClass("ui-slider");
this._initBoundaries(); this._initBoundaries();
// Initialize mouse and key events for interaction // Initialize mouse and key events for interaction
this.handle = $(this.options.handle, this.element); this.handle = $(this.options.handle, this.element);
if (!this.handle.length) { if (!this.handle.length) {
@ -82,20 +82,20 @@ $.widget("ui.slider", {
return handle[0]; return handle[0];
}); });
} }
var handleclass = function(el) { var handleclass = function(el) {
this.element = $(el); this.element = $(el);
this.element.data("mouse", this); this.element.data("mouse", this);
this.options = self.options; this.options = self.options;
this.element.bind("mousedown", function() { this.element.bind("mousedown", function() {
if(self.currentHandle) this.blur(self.currentHandle); if(self.currentHandle) this.blur(self.currentHandle);
self._focus(this, true); self._focus(this, true);
}); });
this._mouseInit(); this._mouseInit();
}; };
$.extend(handleclass.prototype, $.ui.mouse, { $.extend(handleclass.prototype, $.ui.mouse, {
_mouseStart: function(event) { return self._start.call(self, event, this.element[0]); }, _mouseStart: function(event) { return self._start.call(self, event, this.element[0]); },
_mouseStop: function(event) { return self._stop.call(self, event, this.element[0]); }, _mouseStop: function(event) { return self._stop.call(self, event, this.element[0]); },
@ -103,7 +103,7 @@ $.widget("ui.slider", {
_mouseCapture: function() { return true; }, _mouseCapture: function() { return true; },
trigger: function(event) { this._mouseDown(event); } trigger: function(event) { this._mouseDown(event); }
}); });
$(this.handle) $(this.handle)
.each(function() { .each(function() {
new handleclass(this); new handleclass(this);
@ -115,29 +115,29 @@ $.widget("ui.slider", {
.bind('blur', function(event) { self._blur(this.firstChild); }) .bind('blur', function(event) { self._blur(this.firstChild); })
.bind('keydown', function(event) { if(!self.options.noKeyboard) return self._keydown(event.keyCode, this.firstChild); }) .bind('keydown', function(event) { if(!self.options.noKeyboard) return self._keydown(event.keyCode, this.firstChild); })
; ;
// Bind the click to the slider itself // Bind the click to the slider itself
this.element.bind('mousedown.slider', function(event) { this.element.bind('mousedown.slider', function(event) {
self._click.apply(self, [event]); self._click.apply(self, [event]);
self.currentHandle.data("mouse").trigger(event); self.currentHandle.data("mouse").trigger(event);
self.firstValue = self.firstValue + 1; //This is for always triggering the change event self.firstValue = self.firstValue + 1; //This is for always triggering the change event
}); });
// Move the first handle to the startValue // Move the first handle to the startValue
$.each(this.options.handles || [], function(index, handle) { $.each(this.options.handles || [], function(index, handle) {
self.moveTo(handle.start, index, true); self.moveTo(handle.start, index, true);
}); });
if (!isNaN(this.options.startValue)) if (!isNaN(this.options.startValue))
this.moveTo(this.options.startValue, 0, true); 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 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(); if(this.handle.length == 2 && this.options.range) this._createRange();
}, },
_initBoundaries: function() { _initBoundaries: function() {
var element = this.element[0], o = this.options; var element = this.element[0], o = this.options;
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
$.extend(o, { $.extend(o, {
axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'), 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 }), 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 }),
@ -154,7 +154,7 @@ $.widget("ui.slider", {
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) 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)
}; };
}, },
_keydown: function(keyCode, handle) { _keydown: function(keyCode, handle) {
if (this.options.disabled) if (this.options.disabled)
return; return;
@ -193,9 +193,9 @@ $.widget("ui.slider", {
// - The user didn't click a handle // - The user didn't click a handle
// - The Slider is not disabled // - The Slider is not disabled
// - There is a current, or previous selected handle (otherwise we wouldn't know which one to move) // - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
var pointer = [event.pageX, event.pageY]; var pointer = [event.pageX, event.pageY];
var clickedHandle = false; var clickedHandle = false;
this.handle.each(function() { this.handle.each(function() {
if(this == event.target) if(this == event.target)
@ -203,20 +203,20 @@ $.widget("ui.slider", {
}); });
if (clickedHandle || this.options.disabled || !(this.currentHandle || this.previousHandle)) if (clickedHandle || this.options.disabled || !(this.currentHandle || this.previousHandle))
return; return;
// If a previous handle was focussed, focus it again // If a previous handle was focussed, focus it again
if (!this.currentHandle && this.previousHandle) if (!this.currentHandle && this.previousHandle)
this._focus(this.previousHandle, true); this._focus(this.previousHandle, true);
// propagate only for distance > 0, otherwise propagation is done my drag // propagate only for distance > 0, otherwise propagation is done my drag
this.offset = this.element.offset(); this.offset = this.element.offset();
this.moveTo({ this.moveTo({
y: this._convertValue(event.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"), y: this._convertValue(event.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),
x: this._convertValue(event.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x") x: this._convertValue(event.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")
}, null, !this.options.distance); }, null, !this.options.distance);
}, },
_createRange: function() { _createRange: function() {
if(this.rangeElement) return; if(this.rangeElement) return;
this.rangeElement = $('<div></div>') this.rangeElement = $('<div></div>')
@ -238,7 +238,7 @@ $.widget("ui.slider", {
_getRange: function() { _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; 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() { _handleIndex: function() {
return this.handle.index(this.currentHandle[0]); return this.handle.index(this.currentHandle[0]);
}, },
@ -247,7 +247,7 @@ $.widget("ui.slider", {
if(!axis) axis = this.options.axis == "vertical" ? "y" : "x"; if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";
var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle); var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);
if(curHandle.data("mouse").sliderValue) { if(curHandle.data("mouse").sliderValue) {
return parseInt(curHandle.data("mouse").sliderValue[axis],10); return parseInt(curHandle.data("mouse").sliderValue[axis],10);
} else { } else {
@ -258,7 +258,7 @@ $.widget("ui.slider", {
_convertValue: function(value,axis) { _convertValue: function(value,axis) {
return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))) * this.options.realMax[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) { _translateValue: function(value,axis) {
return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis)); return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis));
}, },
@ -297,28 +297,28 @@ $.widget("ui.slider", {
}, },
_start: function(event, handle) { _start: function(event, handle) {
var o = this.options; var o = this.options;
if(o.disabled) return false; if(o.disabled) return false;
// Prepare the outer size // Prepare the outer size
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
// This is a especially ugly fix for strange blur events happening on mousemove events // This is a especially ugly fix for strange blur events happening on mousemove events
if (!this.currentHandle) if (!this.currentHandle)
this._focus(this.previousHandle, true); this._focus(this.previousHandle, true);
this.offset = this.element.offset(); this.offset = this.element.offset();
this.handleOffset = this.currentHandle.offset(); this.handleOffset = this.currentHandle.offset();
this.clickOffset = { top: event.pageY - this.handleOffset.top, left: event.pageX - this.handleOffset.left }; this.clickOffset = { top: event.pageY - this.handleOffset.top, left: event.pageX - this.handleOffset.left };
this.firstValue = this.value(); this.firstValue = this.value();
this._propagate('start', event); this._propagate('start', event);
this._drag(event, handle); this._drag(event, handle);
return true; return true;
}, },
_stop: function(event) { _stop: function(event) {
this._propagate('stop', event); this._propagate('stop', event);
@ -329,14 +329,14 @@ $.widget("ui.slider", {
return false; return false;
}, },
_drag: function(event, handle) { _drag: function(event, handle) {
var o = this.options; var o = this.options;
var position = { top: event.pageY - this.offset.top - this.clickOffset.top, left: event.pageX - this.offset.left - this.clickOffset.left}; var position = { top: event.pageY - this.offset.top - this.clickOffset.top, left: event.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 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.left = this._translateLimits(position.left, "x");
position.top = this._translateLimits(position.top, "y"); position.top = this._translateLimits(position.top, "y");
if (o.stepping.x) { if (o.stepping.x) {
var value = this._convertValue(position.left, "x"); var value = this._convertValue(position.left, "x");
value = Math.round(value / o.stepping.x) * o.stepping.x; value = Math.round(value / o.stepping.x) * o.stepping.x;
@ -347,49 +347,49 @@ $.widget("ui.slider", {
value = Math.round(value / o.stepping.y) * o.stepping.y; value = Math.round(value / o.stepping.y) * o.stepping.y;
position.top = this._translateValue(value, "y"); position.top = this._translateValue(value, "y");
} }
position.left = this._translateRange(position.left, "x"); position.left = this._translateRange(position.left, "x");
position.top = this._translateRange(position.top, "y"); position.top = this._translateRange(position.top, "y");
if(o.axis != "vertical") this.currentHandle.css({ left: position.left }); if(o.axis != "vertical") this.currentHandle.css({ left: position.left });
if(o.axis != "horizontal") this.currentHandle.css({ top: position.top }); if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });
//Store the slider's value //Store the slider's value
this.currentHandle.data("mouse").sliderValue = { this.currentHandle.data("mouse").sliderValue = {
x: Math.round(this._convertValue(position.left, "x")) || 0, x: Math.round(this._convertValue(position.left, "x")) || 0,
y: Math.round(this._convertValue(position.top, "y")) || 0 y: Math.round(this._convertValue(position.top, "y")) || 0
}; };
if (this.rangeElement) if (this.rangeElement)
this._updateRange(); this._updateRange();
this._propagate('slide', event); this._propagate('slide', event);
return false; return false;
}, },
moveTo: function(value, handle, noPropagation) { moveTo: function(value, handle, noPropagation) {
var o = this.options; var o = this.options;
// Prepare the outer size // Prepare the outer size
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; 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 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) if (handle == undefined && !this.currentHandle && this.handle.length != 1)
return false; return false;
//If only one handle is available, use it //If only one handle is available, use it
if (handle == undefined && !this.currentHandle) if (handle == undefined && !this.currentHandle)
handle = 0; handle = 0;
if (handle != undefined) if (handle != undefined)
this.currentHandle = this.previousHandle = $(this.handle[handle] || handle); this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
if(value.x !== undefined && value.y !== undefined) { if(value.x !== undefined && value.y !== undefined) {
var x = value.x, y = value.y; var x = value.x, y = value.y;
} else { } else {
var x = value, y = value; var x = value, y = value;
} }
if(x !== undefined && x.constructor != Number) { if(x !== undefined && x.constructor != Number) {
var me = /^\-\=/.test(x), pe = /^\+\=/.test(x); var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
if(me || pe) { if(me || pe) {
@ -398,7 +398,7 @@ $.widget("ui.slider", {
x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10); x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
} }
} }
if(y !== undefined && y.constructor != Number) { if(y !== undefined && y.constructor != Number) {
var me = /^\-\=/.test(y), pe = /^\+\=/.test(y); var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
if(me || pe) { if(me || pe) {
@ -407,7 +407,7 @@ $.widget("ui.slider", {
y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10); y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
} }
} }
if(o.axis != "vertical" && x !== undefined) { if(o.axis != "vertical" && x !== undefined) {
if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x; if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;
x = this._translateValue(x, "x"); x = this._translateValue(x, "x");
@ -416,7 +416,7 @@ $.widget("ui.slider", {
o.animate ? this.currentHandle.stop().animate({ left: x }, (Math.abs(parseInt(this.currentHandle.css("left")) - x)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ left: x }); o.animate ? this.currentHandle.stop().animate({ left: x }, (Math.abs(parseInt(this.currentHandle.css("left")) - x)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ left: x });
} }
if(o.axis != "horizontal" && y !== undefined) { if(o.axis != "horizontal" && y !== undefined) {
if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y; if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;
y = this._translateValue(y, "y"); y = this._translateValue(y, "y");
@ -424,16 +424,16 @@ $.widget("ui.slider", {
y = this._translateRange(y, "y"); y = this._translateRange(y, "y");
o.animate ? this.currentHandle.stop().animate({ top: y }, (Math.abs(parseInt(this.currentHandle.css("top")) - y)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ top: y }); o.animate ? this.currentHandle.stop().animate({ top: y }, (Math.abs(parseInt(this.currentHandle.css("top")) - y)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ top: y });
} }
if (this.rangeElement) if (this.rangeElement)
this._updateRange(); this._updateRange();
//Store the slider's value //Store the slider's value
this.currentHandle.data("mouse").sliderValue = { this.currentHandle.data("mouse").sliderValue = {
x: Math.round(this._convertValue(x, "x")) || 0, x: Math.round(this._convertValue(x, "x")) || 0,
y: Math.round(this._convertValue(y, "y")) || 0 y: Math.round(this._convertValue(y, "y")) || 0
}; };
if (!noPropagation) { if (!noPropagation) {
this._propagate('start', null); this._propagate('start', null);
this._propagate("slide", null); this._propagate("slide", null);

View File

@ -15,7 +15,7 @@
$.widget('ui.spinner', { $.widget('ui.spinner', {
_init: function() { _init: function() {
this._trigger('init', null, this.ui(null)); this._trigger('init', null, this.ui(null));
// perform data bind on generic objects // perform data bind on generic objects
if (typeof this.options.items[0] == 'object' && !this.element.is('input')) { if (typeof this.options.items[0] == 'object' && !this.element.is('input')) {
var data = this.options.items; var data = this.options.items;
@ -23,22 +23,22 @@ $.widget('ui.spinner', {
this._addItem(data[i]); this._addItem(data[i]);
} }
} }
// check for decimals in steppinng and set _decimals as internal // check for decimals in steppinng and set _decimals as internal
this._decimals = parseInt(this.options.decimals, 10); this._decimals = parseInt(this.options.decimals, 10);
if (this.options.stepping.toString().indexOf('.') != -1 && this._decimals == 0) { if (this.options.stepping.toString().indexOf('.') != -1 && this._decimals == 0) {
var s = this.options.stepping.toString(); var s = this.options.stepping.toString();
this._decimals = s.slice(s.indexOf('.')+1, s.length).length; this._decimals = s.slice(s.indexOf('.')+1, s.length).length;
} }
//Initialize needed constants //Initialize needed constants
var self = this; var self = this;
this.element this.element
.addClass('ui-spinner-box') .addClass('ui-spinner-box')
.attr('autocomplete', 'off'); // switch off autocomplete in opera .attr('autocomplete', 'off'); // switch off autocomplete in opera
this._setValue( isNaN(this._getValue()) ? this.options.start : this._getValue() ); this._setValue( isNaN(this._getValue()) ? this.options.start : this._getValue() );
this.element this.element
.wrap('<div>') .wrap('<div>')
.parent() .parent()
@ -137,7 +137,7 @@ $.widget('ui.spinner', {
self._propagate('change', event); self._propagate('change', event);
}) })
.end(); .end();
// Give the spinner casing a unique id only if one exists in original input // Give the spinner casing a unique id only if one exists in original input
// - this should aid targetted customisations if a page contains multiple instances // - this should aid targetted customisations if a page contains multiple instances
this.element.attr('id', function(){ this.element.attr('id', function(){
@ -145,7 +145,7 @@ $.widget('ui.spinner', {
$(this).parent().attr('id', this.id+'-ui-spinner'); $(this).parent().attr('id', this.id+'-ui-spinner');
} }
}); });
// DataList: Set contraints for object length and step size. // DataList: Set contraints for object length and step size.
// Manipulate height of spinner. // Manipulate height of spinner.
this._items = this.element.children().length; this._items = this.element.children().length;
@ -166,7 +166,7 @@ $.widget('ui.spinner', {
this.options.min = 0; this.options.min = 0;
this.options.max = this._items-1; this.options.max = this._items-1;
} }
this.element this.element
.bind('keydown.spinner', function(event) { .bind('keydown.spinner', function(event) {
if (!self.counter) { if (!self.counter) {
@ -181,14 +181,14 @@ $.widget('ui.spinner', {
.bind('blur.spinner', function(event) { .bind('blur.spinner', function(event) {
self._cleanUp(); self._cleanUp();
}); });
if ($.fn.mousewheel) { if ($.fn.mousewheel) {
this.element.mousewheel(function(event, delta) { this.element.mousewheel(function(event, delta) {
self._mousewheel(event, delta); self._mousewheel(event, delta);
}); });
} }
}, },
_constrain: function() { _constrain: function() {
if (this.options.min != undefined && this._getValue() < this.options.min) { if (this.options.min != undefined && this._getValue() < this.options.min) {
this._setValue(this.options.min); this._setValue(this.options.min);
@ -205,7 +205,7 @@ $.widget('ui.spinner', {
if (this.disabled) { if (this.disabled) {
return; return;
} }
if (isNaN(this._getValue())) { if (isNaN(this._getValue())) {
this._setValue(this.options.start); this._setValue(this.options.start);
} }
@ -250,7 +250,7 @@ $.widget('ui.spinner', {
}, },
_keydown: function(event) { _keydown: function(event) {
var KEYS = $.keyCode; var KEYS = $.keyCode;
if (event.keyCode == KEYS.UP) { if (event.keyCode == KEYS.UP) {
this._up(event); this._up(event);
} }
@ -314,10 +314,10 @@ $.widget('ui.spinner', {
wrapper = 'li'; wrapper = 'li';
} }
var html = obj; // string or object set it to html first var html = obj; // string or object set it to html first
if (typeof obj == 'object') { if (typeof obj == 'object') {
var format = (fmt !== undefined ? fmt : this.options.format); var format = (fmt !== undefined ? fmt : this.options.format);
html = format.replace(/%(\(([^)]+)\))?/g, html = format.replace(/%(\(([^)]+)\))?/g,
(function(data){ (function(data){
return function(match, a, lbl) { return function(match, a, lbl) {
@ -335,7 +335,7 @@ $.widget('ui.spinner', {
this.element.append('<'+ wrapper +' class="ui-spinner-dyn">'+ html + '</'+ wrapper +'>'); this.element.append('<'+ wrapper +' class="ui-spinner-dyn">'+ html + '</'+ wrapper +'>');
} }
}, },
plugins: {}, plugins: {},
ui: function(event) { ui: function(event) {
return { return {

View File

@ -48,13 +48,13 @@ $.widget("ui.tabs", {
return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); return $.cookie.apply(null, [cookie].concat($.makeArray(arguments)));
}, },
_tabify: function(init) { _tabify: function(init) {
this.$lis = $('li:has(a[href])', this.element); this.$lis = $('li:has(a[href])', this.element);
this.$tabs = this.$lis.map(function() { return $('a', this)[0]; }); this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
this.$panels = $([]); this.$panels = $([]);
var self = this, o = this.options; var self = this, o = this.options;
this.$tabs.each(function(i, a) { this.$tabs.each(function(i, a) {
// inline tab // inline tab
if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
@ -77,14 +77,14 @@ $.widget("ui.tabs", {
else else
o.disabled.push(i + 1); o.disabled.push(i + 1);
}); });
// initialization from scratch // initialization from scratch
if (init) { if (init) {
// attach necessary classes for styling if not present // attach necessary classes for styling if not present
this.element.addClass(o.navClass); this.element.addClass(o.navClass);
this.$panels.addClass(o.panelClass); this.$panels.addClass(o.panelClass);
// Selected tab // Selected tab
// use "selected" option or try to retrieve: // use "selected" option or try to retrieve:
// 1. from fragment identifier in url // 1. from fragment identifier in url
@ -107,7 +107,7 @@ $.widget("ui.tabs", {
o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] ); o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );
} }
o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default
// Take disabling tabs via class attribute from HTML // Take disabling tabs via class attribute from HTML
// into account and update option properly. // into account and update option properly.
// A selected tab cannot become disabled. // A selected tab cannot become disabled.
@ -117,7 +117,7 @@ $.widget("ui.tabs", {
)).sort(); )).sort();
if ($.inArray(o.selected, o.disabled) != -1) if ($.inArray(o.selected, o.disabled) != -1)
o.disabled.splice($.inArray(o.selected, o.disabled), 1); o.disabled.splice($.inArray(o.selected, o.disabled), 1);
// highlight selected tab // highlight selected tab
this.$panels.addClass(o.hideClass); this.$panels.addClass(o.hideClass);
this.$lis.removeClass(o.selectedClass); this.$lis.removeClass(o.selectedClass);
@ -126,41 +126,41 @@ $.widget("ui.tabs", {
var classes = [o.selectedClass]; var classes = [o.selectedClass];
if (o.deselectable) classes.push(o.deselectableClass); if (o.deselectable) classes.push(o.deselectableClass);
this.$lis.eq(o.selected).addClass(classes.join(' ')); this.$lis.eq(o.selected).addClass(classes.join(' '));
// seems to be expected behavior that the show callback is fired // seems to be expected behavior that the show callback is fired
var onShow = function() { var onShow = function() {
self._trigger('show', null, self._trigger('show', null,
self.ui(self.$tabs[o.selected], self.$panels[o.selected])); self.ui(self.$tabs[o.selected], self.$panels[o.selected]));
}; };
// load if remote tab // load if remote tab
if ($.data(this.$tabs[o.selected], 'load.tabs')) if ($.data(this.$tabs[o.selected], 'load.tabs'))
this.load(o.selected, onShow); this.load(o.selected, onShow);
// just trigger show event // just trigger show event
else onShow(); else onShow();
} }
// clean up to avoid memory leaks in certain versions of IE 6 // clean up to avoid memory leaks in certain versions of IE 6
$(window).bind('unload', function() { $(window).bind('unload', function() {
self.$tabs.unbind('.tabs'); self.$tabs.unbind('.tabs');
self.$lis = self.$tabs = self.$panels = null; self.$lis = self.$tabs = self.$panels = null;
}); });
} }
// update selected after add/remove // update selected after add/remove
else else
o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] ); o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] );
// set or update cookie after init and add/remove respectively // set or update cookie after init and add/remove respectively
if (o.cookie) this._cookie(o.selected, o.cookie); if (o.cookie) this._cookie(o.selected, o.cookie);
// disable tabs // disable tabs
for (var i = 0, li; li = this.$lis[i]; i++) for (var i = 0, li; li = this.$lis[i]; i++)
$(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass); $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);
// reset cache if switching from cached to not cached // reset cache if switching from cached to not cached
if (o.cache === false) this.$tabs.removeData('cache.tabs'); if (o.cache === false) this.$tabs.removeData('cache.tabs');
// set up animations // set up animations
var hideFx, showFx; var hideFx, showFx;
if (o.fx) { if (o.fx) {
@ -170,7 +170,7 @@ $.widget("ui.tabs", {
} }
else hideFx = showFx = o.fx; else hideFx = showFx = o.fx;
} }
// Reset certain styles left over from animation // Reset certain styles left over from animation
// and prevent IE's ClearType bug... // and prevent IE's ClearType bug...
function resetStyle($el, fx) { function resetStyle($el, fx) {
@ -191,7 +191,7 @@ $.widget("ui.tabs", {
$show.removeClass(o.hideClass); $show.removeClass(o.hideClass);
self._trigger('show', null, self.ui(clicked, $show[0])); self._trigger('show', null, self.ui(clicked, $show[0]));
}; };
// Hide a tab, $show is optional... // Hide a tab, $show is optional...
var hideTab = hideFx ? var hideTab = hideFx ?
function(clicked, $hide, $show) { function(clicked, $hide, $show) {
@ -205,7 +205,7 @@ $.widget("ui.tabs", {
$hide.addClass(o.hideClass); $hide.addClass(o.hideClass);
if ($show) showTab(clicked, $show); if ($show) showTab(clicked, $show);
}; };
// Switch a tab... // Switch a tab...
function switchTab(clicked, $li, $hide, $show) { function switchTab(clicked, $li, $hide, $show) {
var classes = [o.selectedClass]; var classes = [o.selectedClass];
@ -213,15 +213,15 @@ $.widget("ui.tabs", {
$li.addClass(classes.join(' ')).siblings().removeClass(classes.join(' ')); $li.addClass(classes.join(' ')).siblings().removeClass(classes.join(' '));
hideTab(clicked, $hide, $show); hideTab(clicked, $hide, $show);
} }
// attach tab event handler, unbind to avoid duplicates from former tabifying... // attach tab event handler, unbind to avoid duplicates from former tabifying...
this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function() { this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function() {
//var trueClick = event.clientX; // add to history only if true click occured, not a triggered click //var trueClick = event.clientX; // add to history only if true click occured, not a triggered click
var $li = $(this).parents('li:eq(0)'), var $li = $(this).parents('li:eq(0)'),
$hide = self.$panels.filter(':visible'), $hide = self.$panels.filter(':visible'),
$show = $(self._sanitizeSelector(this.hash)); $show = $(self._sanitizeSelector(this.hash));
// If tab is already selected and not deselectable or tab disabled or // If tab is already selected and not deselectable or tab disabled or
// or is already loading or click callback returns false stop here. // or is already loading or click callback returns false stop here.
// Check if click handler returns false last so that it is not executed // Check if click handler returns false last so that it is not executed
@ -234,9 +234,9 @@ $.widget("ui.tabs", {
this.blur(); this.blur();
return false; return false;
} }
o.selected = self.$tabs.index(this); o.selected = self.$tabs.index(this);
// if tab may be closed // if tab may be closed
if (o.deselectable) { if (o.deselectable) {
if ($li.hasClass(o.selectedClass)) { if ($li.hasClass(o.selectedClass)) {
@ -257,12 +257,12 @@ $.widget("ui.tabs", {
return false; return false;
} }
} }
if (o.cookie) self._cookie(o.selected, o.cookie); if (o.cookie) self._cookie(o.selected, o.cookie);
// stop possibly running animations // stop possibly running animations
self.$panels.stop(); self.$panels.stop();
// show new tab // show new tab
if ($show.length) { if ($show.length) {
var a = this; var a = this;
@ -277,31 +277,31 @@ $.widget("ui.tabs", {
); );
} else } else
throw 'jQuery UI Tabs: Mismatching fragment identifier.'; throw 'jQuery UI Tabs: Mismatching fragment identifier.';
// Prevent IE from keeping other link focussed when using the back button // Prevent IE from keeping other link focussed when using the back button
// and remove dotted border from clicked link. This is controlled via CSS // and remove dotted border from clicked link. This is controlled via CSS
// in modern browsers; blur() removes focus from address bar in Firefox // in modern browsers; blur() removes focus from address bar in Firefox
// which can become a usability and annoying problem with tabs('rotate'). // which can become a usability and annoying problem with tabs('rotate').
if ($.browser.msie) this.blur(); if ($.browser.msie) this.blur();
return false; return false;
}); });
// disable click if event is configured to something else // disable click if event is configured to something else
if (o.event != 'click') this.$tabs.bind('click.tabs', function(){return false;}); if (o.event != 'click') this.$tabs.bind('click.tabs', function(){return false;});
}, },
add: function(url, label, index) { add: function(url, label, index) {
if (index == undefined) if (index == undefined)
index = this.$tabs.length; // append by default index = this.$tabs.length; // append by default
var o = this.options; var o = this.options;
var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)); var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
$li.data('destroy.tabs', true); $li.data('destroy.tabs', true);
var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] ); var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] );
// try to find an existing element before creating a new one // try to find an existing element before creating a new one
var $panel = $('#' + id); var $panel = $('#' + id);
if (!$panel.length) { if (!$panel.length) {
@ -317,12 +317,12 @@ $.widget("ui.tabs", {
$li.insertBefore(this.$lis[index]); $li.insertBefore(this.$lis[index]);
$panel.insertBefore(this.$panels[index]); $panel.insertBefore(this.$panels[index]);
} }
o.disabled = $.map(o.disabled, o.disabled = $.map(o.disabled,
function(n, i) { return n >= index ? ++n : n }); function(n, i) { return n >= index ? ++n : n });
this._tabify(); this._tabify();
if (this.$tabs.length == 1) { if (this.$tabs.length == 1) {
$li.addClass(o.selectedClass); $li.addClass(o.selectedClass);
$panel.removeClass(o.hideClass); $panel.removeClass(o.hideClass);
@ -330,24 +330,24 @@ $.widget("ui.tabs", {
if (href) if (href)
this.load(index, href); this.load(index, href);
} }
// callback // callback
this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index])); this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index]));
}, },
remove: function(index) { remove: function(index) {
var o = this.options, $li = this.$lis.eq(index).remove(), var o = this.options, $li = this.$lis.eq(index).remove(),
$panel = this.$panels.eq(index).remove(); $panel = this.$panels.eq(index).remove();
// If selected tab was removed focus tab to the right or // If selected tab was removed focus tab to the right or
// in case the last tab was removed the tab to the left. // in case the last tab was removed the tab to the left.
if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1) if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)
this.select(index + (index + 1 < this.$tabs.length ? 1 : -1)); this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));
o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }), o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),
function(n, i) { return n >= index ? --n : n }); function(n, i) { return n >= index ? --n : n });
this._tabify(); this._tabify();
// callback // callback
this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0])); this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0]));
}, },
@ -355,7 +355,7 @@ $.widget("ui.tabs", {
var o = this.options; var o = this.options;
if ($.inArray(index, o.disabled) == -1) if ($.inArray(index, o.disabled) == -1)
return; return;
var $li = this.$lis.eq(index).removeClass(o.disabledClass); var $li = this.$lis.eq(index).removeClass(o.disabledClass);
if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2... if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
$li.css('display', 'inline-block'); $li.css('display', 'inline-block');
@ -363,9 +363,9 @@ $.widget("ui.tabs", {
$li.css('display', 'block'); $li.css('display', 'block');
}, 0); }, 0);
} }
o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });
// callback // callback
this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index])); this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index]));
}, },
@ -373,10 +373,10 @@ $.widget("ui.tabs", {
var self = this, o = this.options; var self = this, o = this.options;
if (index != o.selected) { // cannot disable already selected tab if (index != o.selected) { // cannot disable already selected tab
this.$lis.eq(index).addClass(o.disabledClass); this.$lis.eq(index).addClass(o.disabledClass);
o.disabled.push(index); o.disabled.push(index);
o.disabled.sort(); o.disabled.sort();
// callback // callback
this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index])); this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index]));
} }
@ -388,20 +388,20 @@ $.widget("ui.tabs", {
this.$tabs.eq(index).trigger(this.options.event + '.tabs'); this.$tabs.eq(index).trigger(this.options.event + '.tabs');
}, },
load: function(index, callback) { // callback is for internal usage only load: function(index, callback) { // callback is for internal usage only
var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0], var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],
bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs'); bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');
callback = callback || function() {}; callback = callback || function() {};
// no remote or from cache - just finish with callback // no remote or from cache - just finish with callback
if (!url || !bypassCache && $.data(a, 'cache.tabs')) { if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
callback(); callback();
return; return;
} }
// load remote from here on // load remote from here on
var inner = function(parent) { var inner = function(parent) {
var $parent = $(parent), $inner = $parent.find('*:last'); var $parent = $(parent), $inner = $parent.find('*:last');
return $inner.length && $inner.is(':not(img)') && $inner || $parent; return $inner.length && $inner.is(':not(img)') && $inner || $parent;
@ -414,29 +414,29 @@ $.widget("ui.tabs", {
}); });
self.xhr = null; self.xhr = null;
}; };
if (o.spinner) { if (o.spinner) {
var label = inner(a).html(); var label = inner(a).html();
inner(a).wrapInner('<em></em>') inner(a).wrapInner('<em></em>')
.find('em').data('label.tabs', label).html(o.spinner); .find('em').data('label.tabs', label).html(o.spinner);
} }
var ajaxOptions = $.extend({}, o.ajaxOptions, { var ajaxOptions = $.extend({}, o.ajaxOptions, {
url: url, url: url,
success: function(r, s) { success: function(r, s) {
$(self._sanitizeSelector(a.hash)).html(r); $(self._sanitizeSelector(a.hash)).html(r);
cleanup(); cleanup();
if (o.cache) if (o.cache)
$.data(a, 'cache.tabs', true); // if loaded once do not load them again $.data(a, 'cache.tabs', true); // if loaded once do not load them again
// callbacks // callbacks
self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index])); self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index]));
try { try {
o.ajaxOptions.success(r, s); o.ajaxOptions.success(r, s);
} }
catch (event) {} catch (event) {}
// This callback is required because the switch has to take // This callback is required because the switch has to take
// place after loading has completed. Call last in order to // place after loading has completed. Call last in order to
// fire load before show callback... // fire load before show callback...
@ -519,24 +519,24 @@ $.extend($.ui.tabs, {
$.extend($.ui.tabs.prototype, { $.extend($.ui.tabs.prototype, {
rotation: null, rotation: null,
rotate: function(ms, continuing) { rotate: function(ms, continuing) {
continuing = continuing || false; continuing = continuing || false;
var self = this, t = this.options.selected; var self = this, t = this.options.selected;
function start() { function start() {
self.rotation = setInterval(function() { self.rotation = setInterval(function() {
t = ++t < self.$tabs.length ? t : 0; t = ++t < self.$tabs.length ? t : 0;
self.select(t); self.select(t);
}, ms); }, ms);
} }
function stop(event) { function stop(event) {
if (!event || event.clientX) { // only in case of a true click if (!event || event.clientX) { // only in case of a true click
clearInterval(self.rotation); clearInterval(self.rotation);
} }
} }
// start interval // start interval
if (ms) { if (ms) {
start(); start();