Skip to content

Commit

Permalink
update to 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rniemeyer committed Sep 10, 2014
1 parent af3c42c commit 4e5567c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "knockout-sortable",
"version": "0.8.8",
"version": "0.9.0",
"main": "./build/knockout-sortable.min.js",
"ignore": [
"examples",
Expand Down
32 changes: 25 additions & 7 deletions build/knockout-sortable.js
@@ -1,4 +1,4 @@
// knockout-sortable 0.8.8 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
// knockout-sortable 0.9.0 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
;(function(factory) {
if (typeof define === "function" && define.amd) {
// AMD anonymous module
Expand Down Expand Up @@ -78,6 +78,29 @@
return index;
};

//remove problematic leading/trailing whitespace from templates
var stripTemplateWhitespace = function(element, name) {
var templateSource,
templateElement;

//process named templates
if (name) {
templateElement = document.getElementById(name);
if (templateElement) {
templateSource = new ko.templateSources.domElement(templateElement);
templateSource.text($.trim(templateSource.text()));
}
}
else {
//remove leading/trailing non-elements from anonymous templates
$(element).contents().each(function() {
if (this && this.nodeType !== 1) {
element.removeChild(this);
}
});
}
};

//connect items with observableArrays
ko.bindingHandlers.sortable = {
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
Expand All @@ -87,12 +110,7 @@
sortable = {},
startActual, updateActual;

//remove leading/trailing non-elements from anonymous templates
$element.contents().each(function() {
if (this && this.nodeType !== 1) {
element.removeChild(this);
}
});
stripTemplateWhitespace(element, templateOptions.name);

//build a new object that has the global options with overrides from the binding
$.extend(true, sortable, ko.bindingHandlers.sortable);
Expand Down
4 changes: 2 additions & 2 deletions build/knockout-sortable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "knockout-sortable",
"version": "0.8.8",
"version": "0.9.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "0.x.x",
Expand Down

0 comments on commit 4e5567c

Please sign in to comment.