Permalink
Browse files

Remove trailing whitespace

  • Loading branch information...
1 parent ca711d9 commit 8a960f75c409473b3de49e1203b062d054c193b5 @sindresorhus sindresorhus committed Jan 31, 2012
Showing with 187 additions and 187 deletions.
  1. +14 −14 demo/async.html
  2. +4 −4 demo/demo.js
  3. +13 −13 demo/edit.html
  4. +7 −7 demo/images.html
  5. +16 −16 demo/index.html
  6. +1 −1 demo/large.html
  7. +4 −4 demo/prerendered.html
  8. +3 −3 demo/screen.css
  9. +13 −13 demo/simple.html
  10. +27 −27 demo/sortable.html
  11. +1 −1 demo/source.php
  12. +1 −1 demo/source.phps
  13. +16 −16 jquery.treeview.css
  14. +1 −1 jquery.treeview.edit.js
  15. +21 −21 jquery.treeview.js
  16. +45 −45 jquery.treeview.sortable.js
View
28 demo/async.html
@@ -4,23 +4,23 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery async treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="../red-treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
<script src="../jquery.treeview.edit.js" type="text/javascript"></script>
<script src="../jquery.treeview.async.js" type="text/javascript"></script>
-
+
<script type="text/javascript">
function initTrees() {
$("#black").treeview({
url: "source.php"
})
-
+
$("#mixed").treeview({
url: "source.php",
// add some additional, dynamic data and request with POST
@@ -43,25 +43,25 @@
});
});
</script>
-
+
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<ul>
<li><a href=".">Main Demo</a></li>
<li><a href="source.phps">Server component used</a></li>
</ul>
-
+
<h4>Lazy-loading tree</h4>
-
+
<ul id="black">
</ul>
-
+
<h4>Mixed pre and lazy-loading</h4>
-
+
<ul id="mixed">
<li><span>Item 1</span>
<ul>
@@ -83,9 +83,9 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
<span>Item 3</span>
</li>
</ul>
-
+
<button id="refresh">Refresh both Trees</button>
-
+
</div>
-
+
</body></html>
View
8 demo/demo.js
@@ -1,15 +1,15 @@
$(document).ready(function(){
-
+
// first example
$("#browser").treeview();
-
+
// second example
$("#navigation").treeview({
persist: "location",
collapsed: true,
unique: true
});
-
+
// third example
$("#red").treeview({
animated: "fast",
@@ -20,7 +20,7 @@ $(document).ready(function(){
window.console && console.log("%o was toggled", this);
}
});
-
+
// fourth example
$("#black, #gray").treeview({
control: "#treecontrol",
View
26 demo/edit.html
@@ -4,21 +4,21 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
<script src="../jquery.treeview.edit.js" type="text/javascript"></script>
-
+
<script type="text/javascript">
$(function() {
$("#browser").treeview();
$("#add").click(function() {
- var branches = $("<li><span class='folder'>New Sublist</span><ul>" +
- "<li><span class='file'>Item1</span></li>" +
+ var branches = $("<li><span class='folder'>New Sublist</span><ul>" +
+ "<li><span class='file'>Item1</span></li>" +
"<li><span class='file'>Item2</span></li></ul></li>").appendTo("#browser");
$("#browser").treeview({
add: branches
@@ -37,21 +37,21 @@
}
});
})
-
+
</script>
-
+
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<a href=".">Main Demo</a>
<h4>Sample 1 - default, right-click to remove items</h4>
-
+
<button id="add">Add!</button>
-
+
<ul id="browser" class="filetree">
<li><span class="folder">Folder 1</span>
<ul>
@@ -76,7 +76,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</li>
<li><span class="file">File 4</span></li>
</ul>
-
+
</div>
-
+
</body></html>
View
14 demo/images.html
@@ -4,24 +4,24 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="../red-treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
-
+
<script type="text/javascript">
$(function() {
$("#browser").treeview();
});
</script>
-
+
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
@@ -50,7 +50,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</li>
<li><img src="../images/file.gif" /></li>
</ul>
-
+
</div>
-
+
</body></html>
View
32 demo/index.html
@@ -4,24 +4,24 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js"></script>
-
+
<script type="text/javascript" src="demo.js"></script>
-
+
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<a href="demo.js">Pagecode</a>
-
+
<h3>Other demos</h3>
<ul>
<li><a href="large.html">Large Tree Demo</a></li>
@@ -30,7 +30,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
<li><a href="edit.html">Editable Tree Demo</a></li>
<li><a href="simple.html">Simple Tree Demo, famfamfam theme (no lines)</a></li>
</ul>
-
+
<h4>Sample 1 - default</h4>
<ul id="browser" class="filetree">
<li><span class="folder">Folder 1</span>
@@ -56,9 +56,9 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</li>
<li><span class="file">File 4</span></li>
</ul>
-
+
<h4>Sample 2 - Navigation</h4>
-
+
<ul id="navigation">
<li><a href="?1">Item 1</a>
<ul>
@@ -153,7 +153,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</ul>
</li>
</ul>
-
+
<h4>Sample 3 - fast animations, all branches collapsed at first, red theme, cookie-based persistance</h4>
<ul id="red" class="treeview-red">
<li><span>Item 1</span>
@@ -236,7 +236,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
<li><span>Item 3.0.1.0</span></li>
<li><span>Item 3.0.1.1</span></li>
</ul>
-
+
</li>
<li><span>Item 3.0.2</span>
<ul>
@@ -250,7 +250,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</ul>
</li>
</ul>
-
+
<h4>Sample 4 - two trees with one tree control, black and gray theme, cookie-based persistance</h4>
<div id="treecontrol">
<a title="Collapse the entire tree below" href="#"><img src="../images/minus.gif" /> Collapse All</a>
@@ -331,8 +331,8 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</ul>
</li>
<li>Item 3</li>
- </ul>
-
+ </ul>
+
</div>
-
+
</body></html>
View
2 demo/large.html
@@ -21,7 +21,7 @@
persist: "location"
});
})
-
+
</script>
</head>
View
8 demo/prerendered.html
@@ -6,11 +6,11 @@
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
-
+
<script type="text/javascript">
$(function() {
$("#tree").treeview({
@@ -21,15 +21,15 @@
persist: "location"
});
})
-
+
</script>
</head>
<body>
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<a href=".">Main Demo</a>
<div id="sidetree">
View
6 demo/screen.css
@@ -1,7 +1,7 @@
html, body {height:100%; margin: 0; padding: 0; }
html>body {
- font-size: 16px;
+ font-size: 16px;
font-size: 68.75%;
} /* Reset Base Font Size */
@@ -19,6 +19,6 @@ h1 { font-size: large }
background: url(bg.gif) repeat-x; text-align: center }
#banner a { color: white; }
-#main { padding: 1em; }
-
+#main { padding: 1em; }
+
a img { border: none; }
View
26 demo/simple.html
@@ -4,26 +4,26 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="../red-treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
-
+
<script type="text/javascript">
$(document).ready(function(){
$("#browser").treeview({
toggle: function() {
console.log("%s was toggled.", $(this).find(">span").text());
}
});
-
+
$("#add").click(function() {
- var branches = $("<li><span class='folder'>New Sublist</span><ul>" +
- "<li><span class='file'>Item1</span></li>" +
+ var branches = $("<li><span class='folder'>New Sublist</span><ul>" +
+ "<li><span class='file'>Item1</span></li>" +
"<li><span class='file'>Item2</span></li></ul></li>").appendTo("#browser");
$("#browser").treeview({
add: branches
@@ -33,12 +33,12 @@
</script>
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<a href=".">Main Demo</a>
-
+
<ul id="browser" class="filetree treeview-famfamfam">
<li><span class="folder">Folder 1</span>
<ul>
@@ -72,11 +72,11 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
</ul>
</li>
</ul>
-
+
<button id="add">Add!</button>
-
+
<p>+/- Icons from <a href="http://www.famfamfam.com/lab/icons/">famfamfam</a></p>
-
+
</div>
-
+
</body></html>
View
54 demo/sortable.html
@@ -4,20 +4,20 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>jQuery treeview</title>
-
+
<link rel="stylesheet" href="../jquery.treeview.css" />
<link rel="stylesheet" href="screen.css" />
-
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
<script src="../jquery.treeview.edit.js" type="text/javascript"></script>
-
+
<script src="../../../ui/ui.core.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../ui/ui.droppable.js" type="text/javascript" charset="utf-8"></script>
<script src="../jquery.treeview.sortable.js" type="text/javascript"></script>
-
+
<style type="text/css" media="screen">
.drop {
background-color: #eee !important;
@@ -26,23 +26,23 @@
.bar {
border-bottom: 1px dotted blue;
}
-
+
.float {
float: left;
border: 1px solid #aaa;
margin: 10px;
padding: 10px;
}
-
+
div.treeview-helper {
border: 1px solid #aaa;
background: #fff;
padding: 5px;
padding-left: 25px;
}
-
+
</style>
-
+
<script type="text/javascript">
(function($) {
var CLASSES = $.treeview.classes;
@@ -62,15 +62,15 @@
}
});
};
-
+
})(jQuery);
-
-
-
-
+
+
+
+
$.fn.sortableTreeview = function(o) {
this.each(function() {
-
+
$(this).treeview().sortableTree({
connectWith: o.connectWith,
items: 'li',
@@ -98,7 +98,7 @@
ui.instance.element.treeview({add: ui.item});
}
});
-
+
$(".folder", this).droppable({
accept: "li",
hoverClass: "drop",
@@ -113,30 +113,30 @@
ui.helper.css("outline", "2px solid red");
}
});
-
- });
+
+ });
};
-
-
+
+
$(function() {
$("#browser, #browser2").sortableTreeview({ connectWith: ["#browser", "#browser2"] });
-
+
})
-
+
</script>
-
+
</head>
<body>
-
+
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery Treeview Plugin</a> Demo</h1>
<div id="main">
-
+
<a href=".">Main Demo</a>
<h4>Sample 1 - default, right-click to remove items</h4>
-
+
<div class="float">
<ul id="browser" class="filetree">
<li><span class="folder">Folder 1</span>
@@ -208,7 +208,7 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-tree
<li><span class="file">File 4</span></li>
</ul>
</div>
-
+
</div>
-
+
</body></html>
View
2 demo/source.php
@@ -83,6 +83,6 @@
{
"text": "4. Questions and answers"
}
-
+
]
<?php endif; ?>
View
2 demo/source.phps
@@ -83,6 +83,6 @@ if ($_REQUEST['root'] == "source"):
{
"text": "4. Questions and answers"
}
-
+
]
<?php endif; ?>
View
32 jquery.treeview.css
@@ -1,12 +1,12 @@
-.treeview, .treeview ul {
+.treeview, .treeview ul {
padding: 0;
margin: 0;
- list-style: none;
-}
-
-.treeview ul {
- background-color: white;
- margin-top: 4px;
+ list-style: none;
+}
+
+.treeview ul {
+ background-color: white;
+ margin-top: 4px;
}
.treeview .hitarea {
@@ -20,10 +20,10 @@
/* fix for IE6 */
* html .hitarea {
display: inline;
- float:none;
+ float:none;
}
-.treeview li {
+.treeview li {
margin: 0;
padding: 3px 0pt 3px 16px;
}
@@ -42,23 +42,23 @@
.treeview .expandable-hitarea { background-position: -80px -3px; }
.treeview li.last { background-position: 0 -1766px }
-.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); }
-.treeview li.lastCollapsable { background-position: 0 -111px }
+.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); }
+.treeview li.lastCollapsable { background-position: 0 -111px }
.treeview li.lastExpandable { background-position: -32px -67px }
-.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
+.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
.treeview-red li { background-image: url(images/treeview-red-line.gif); }
-.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); }
+.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); }
.treeview-black li { background-image: url(images/treeview-black-line.gif); }
-.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); }
+.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); }
.treeview-gray li { background-image: url(images/treeview-gray-line.gif); }
-.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); }
+.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); }
.treeview-famfamfam li { background-image: url(images/treeview-famfamfam-line.gif); }
-.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); }
+.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); }
.treeview .placeholder {
background: url(images/ajax-loader.gif) 0 0 no-repeat;
View
2 jquery.treeview.edit.js
@@ -33,5 +33,5 @@
}
});
};
-
+
})(jQuery);
View
42 jquery.treeview.js
@@ -1,6 +1,6 @@
/*
* Treeview 1.5pre - jQuery plugin to hide and show branches of a tree
- *
+ *
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
* http://docs.jquery.com/Plugins/Treeview
*
@@ -50,7 +50,7 @@
} else {
this.hide();
if (callback)
- this.each(callback);
+ this.each(callback);
}
},
prepareBranches: function(settings) {
@@ -70,18 +70,18 @@
if ( this == event.target )
toggler.apply($(this).next());
}).add( $("a", this) ).hoverClass();
-
+
if (!settings.prerendered) {
// handle closed ones first
this.filter(":has(>ul:hidden)")
.addClass(CLASSES.expandable)
.replaceClass(CLASSES.last, CLASSES.lastExpandable);
-
+
// handle open ones
this.not(":has(>ul:hidden)")
.addClass(CLASSES.collapsable)
.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
-
+
// create hitarea if not present
var hitarea = this.find("div." + CLASSES.hitarea);
if (!hitarea.length)
@@ -94,23 +94,23 @@
$(this).addClass( classes );
})
}
-
+
// apply event to hitarea
this.find("div." + CLASSES.hitarea).click( toggler );
},
treeview: function(settings) {
-
+
settings = $.extend({
cookieId: "treeview"
}, settings);
-
+
if ( settings.toggle ) {
var callback = settings.toggle;
settings.toggle = function() {
return callback.apply($(this).parent()[0], arguments);
};
}
-
+
// factory for treecontroller
function treeController(tree, control) {
// factory for click handlers
@@ -130,9 +130,9 @@
// click on second to expand tree
$("a:eq(1)", control).click( handler(CLASSES.expandable) );
// click on third to toggle tree
- $("a:eq(2)", control).click( handler() );
+ $("a:eq(2)", control).click( handler() );
}
-
+
// handle toggle event
function toggler() {
$(this)
@@ -164,7 +164,7 @@
}
}
this.data("toggler", toggler);
-
+
function serialize() {
function binary(arg) {
return arg ? 1 : 0;
@@ -175,7 +175,7 @@
});
$.cookie(settings.cookieId, data.join(""), settings.cookieOptions );
}
-
+
function deserialize() {
var stored = $.cookie(settings.cookieId);
if ( stored ) {
@@ -185,13 +185,13 @@
});
}
}
-
+
// add treeview class to activate styles
this.addClass("treeview");
-
+
// prepare branches and find all tree items with child lists
var branches = this.find("li").prepareBranches(settings);
-
+
switch(settings.persist) {
case "cookie":
var toggleCallback = settings.toggle;
@@ -222,19 +222,19 @@
}
break;
}
-
+
branches.applyClasses(settings, toggler);
-
+
// if control option is set, create the treecontroller and show it
if ( settings.control ) {
treeController(this, settings.control);
$(settings.control).show();
}
-
+
return this;
}
});
-
+
// classes used by the plugin
// need to be styled via external stylesheet, see first example
$.treeview = {};
@@ -252,5 +252,5 @@
last: "last",
hitarea: "hitarea"
});
-
+
})(jQuery);
View
90 jquery.treeview.sortable.js
@@ -4,7 +4,7 @@
* Copyright (c) 2008 Paul Bakaus
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
- *
+ *
* http://docs.jquery.com/UI/Sortables
*
* Depends:
@@ -28,17 +28,17 @@
var self = this, o = this.options;
this.containerCache = {};
this.element.addClass("ui-sortableTree");
-
+
//Get the items
this.refresh();
-
+
//Let's determine the parent's offset
if(!(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative');
this.offset = this.element.offset();
-
+
//Initialize mouse events for interaction
this.mouseInit();
-
+
//Prepare cursorAt
if(o.cursorAt && o.cursorAt.constructor == Array)
o.cursorAt = { left: o.cursorAt[0], top: o.cursorAt[1] };
@@ -55,24 +55,24 @@
element: this.element,
item: (inst || this)["currentItem"],
sender: inst ? inst.element : null
- };
+ };
},
propagate: function(n,e,inst) {
$.ui.plugin.call(this, n, [e, this.ui(inst)]);
this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
},
serialize: function(o) {
-
+
var items = $(this.options.items, this.element).not('.ui-sortableTree-helper'); //Only the items of the sortable itself
var str = []; o = o || {};
-
+
items.each(function() {
var res = ($(this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
if(res) str.push((o.key || res[1])+'[]='+(o.key ? res[1] : res[2]));
});
-
+
return str.join('&');
-
+
},
toArray: function(attr) {
var items = $(this.options.items, this.element).not('.ui-sortableTree-helper'); //Only the items of the sortable itself
@@ -91,19 +91,19 @@
},
/* Be careful with the following core functions */
intersectsWith: function(item) {
-
+
var x1 = this.position.absolute.left - 10, x2 = x1 + 10,
y1 = this.position.absolute.top - 10, y2 = y1 + 10;
- var l = item.left, r = l + item.width,
+ var l = item.left, r = l + item.width,
t = item.top, b = t + item.height;
-
+
return ( l < x1 + (this.helperProportions.width / 2) // Right Half
&& x2 - (this.helperProportions.width / 2) < r // Left Half
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
-
+
},
- intersectsWithEdge: function(item) {
+ intersectsWithEdge: function(item) {
var y1 = this.position.absolute.top - 10, y2 = y1 + 10;
var t = item.top, b = t + item.height;
@@ -114,21 +114,21 @@
if(y2 > t && y1 < t) return 1; //Crosses top edge
if(y1 < b && y2 > b) return 2; //Crosses bottom edge
-
+
return false;
-
+
},
refresh: function() {
this.refreshItems();
this.refreshPositions();
},
refreshItems: function() {
-
+
this.items = [];
this.containers = [this];
var items = this.items;
var queries = [$(this.options.items, this.element)];
-
+
if(this.options.connectWith) {
for (var i = this.options.connectWith.length - 1; i >= 0; i--){
var cur = $(this.options.connectWith[i]);
@@ -174,19 +174,19 @@
.removeData("sortableTree")
.unbind(".sortableTree");
this.mouseDestroy();
-
+
for ( var i = this.items.length - 1; i >= 0; i-- )
this.items[i].item.removeData("sortableTree-item");
-
+
},
contactContainers: function(e) {
for (var i = this.containers.length - 1; i >= 0; i--){
if(this.intersectsWith(this.containers[i].containerCache)) {
if(!this.containers[i].containerCache.over) {
-
+
if(this.currentContainer != this.containers[i]) {
-
+
//When entering a new container, we will find the item with the least distance and append our item near it
var dist = 10000; var itemWithLeastDistance = null; var base = this.position.absolute.top;
for (var j = this.items.length - 1; j >= 0; j--) {
@@ -196,14 +196,14 @@
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
}
}
-
+
itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element);
this.propagate("change", e); //Call plugins and callbacks
this.containers[i].propagate("change", e, this); //Call plugins and callbacks
this.currentContainer = this.containers[i];
}
-
+
this.containers[i].propagate("over", e, this);
this.containers[i].containerCache.over = 1;
}
@@ -213,31 +213,31 @@
this.containers[i].containerCache.over = 0;
}
}
-
- };
+
+ };
},
mouseStart: function(e,el) {
if(this.options.disabled || this.options.type == 'static') return false;
//Find out if the clicked node (or one of its parents) is a actual item in this.items
- var currentItem = null, nodes = $(e.target).parents().each(function() {
+ var currentItem = null, nodes = $(e.target).parents().each(function() {
if($.data(this, 'sortableTree-item')) {
currentItem = $(this);
return false;
}
});
if($.data(e.target, 'sortableTree-item')) currentItem = $(e.target);
-
- if(!currentItem) return false;
+
+ if(!currentItem) return false;
if(this.options.handle) {
var validHandle = false;
$(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; });
if(!validHandle) return false;
}
-
+
this.currentItem = currentItem;
-
+
var o = this.options;
this.currentContainer = this;
this.refresh();
@@ -246,7 +246,7 @@
this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : this.currentItem.clone();
if(!this.helper.parents('body').length) this.helper.appendTo("body"); //Add the helper to the DOM if that didn't happen already
this.helper.css({ position: 'absolute', clear: 'both' }).addClass('ui-sortableTree-helper'); //Position it absolutely and add a helper class
-
+
//Prepare variables for position generation
$.extend(this, {
offsetParent: this.helper.offsetParent(),
@@ -269,14 +269,14 @@
for (var i = this.containers.length - 1; i >= 0; i--) {
this.containers[i].propagate("activate", e, this);
} //Post 'activate' events to possible containers
-
+
//Prepare possible droppables
if($.ui.ddmanager) $.ui.ddmanager.current = this;
if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
this.dragging = true;
return true;
-
+
},
mouseStop: function(e) {
@@ -286,7 +286,7 @@
//If we are using droppables, inform the manager about the drop
var dropped = ($.ui.ddmanager && !this.options.dropBehaviour) ? $.ui.ddmanager.drop(this, e) : false;
if(!dropped && this.newPositionAt) this.newPositionAt[this.direction == 'down' ? 'before' : 'after'](this.currentItem); //Append to element to its new position
-
+
if(this.position.dom != this.currentItem.prev()[0]) this.propagate("update", e); //Trigger update callback if the DOM position has changed
if(!this.element[0].contains(this.currentItem[0])) { //Node was moved out of the current element
this.propagate("remove", e);
@@ -297,7 +297,7 @@
}
};
};
-
+
//Post events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
this.containers[i].propagate("deactivate", e, this);
@@ -306,13 +306,13 @@
this.containers[i].containerCache.over = 0;
}
}
-
+
this.dragging = false;
if(this.cancelHelperRemoval) return false;
this.helper.remove();
return false;
-
+
},
mouseDrag: function(e) {
@@ -332,26 +332,26 @@
if(this.newPositionAt) this.options.sortIndication.remove.call(this.currentItem, this.newPositionAt);
} else {
for (var i = this.items.length - 1; i >= 0; i--) {
-
+
if(this.currentItem[0].contains(this.items[i].item[0])) continue;
-
+
var intersection = this.intersectsWithEdge(this.items[i]);
if(!intersection) continue;
-
+
this.direction = intersection == 1 ? "down" : "up";
this.rearrange(e, this.items[i]);
this.propagate("change", e); //Call plugins and callbacks
break;
}
}
-
+
//Post events to containers
this.contactContainers(e);
this.propagate("sort", e); //Call plugins and callbacks
this.helper.css({ left: this.position.current.left+'px', top: this.position.current.top+'px' }); // Stick the helper to the cursor
return false;
-
+
},
rearrange: function(e, i, a) {
if(i) {
@@ -363,7 +363,7 @@
}
}
}));
-
+
$.extend($.ui.sortableTree, {
defaults: {
items: '> *',

0 comments on commit 8a960f7

Please sign in to comment.