vue-sortable2
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "vue-sortable2", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "vue-sortable", | ||
@@ -10,3 +10,5 @@ "main": "vue-sortable.js", | ||
}, | ||
"author": "NangeGao", | ||
"author": { | ||
"name": "NangeGao" | ||
}, | ||
"license": "MIT", | ||
@@ -26,3 +28,8 @@ "dependencies": { | ||
"sortable" | ||
] | ||
], | ||
"gitHead": "def4d15c39c98771866ceed946806fa189f396f7", | ||
"readme": "ERROR: No README data found!", | ||
"_id": "vue-sortable2@0.0.2", | ||
"_shasum": "9856f5c9f4d0d1be98923bab202453396e8a9261", | ||
"_from": "vue-sortable2@0.0.2" | ||
} |
@@ -16,30 +16,40 @@ ;(function () { | ||
vSortable.install = function (Vue) { | ||
Vue.directive('sortable', function (data) { | ||
var options = { | ||
onUpdate (evt) { | ||
var sort = []; //每个位置上存放的item的index | ||
data.forEach((item, index) => { | ||
sort[item.select_sort-1] = index; | ||
}); | ||
var operateItem = sort.splice(evt.oldIndex, 1); | ||
sort.splice(evt.newIndex, 0, operateItem[0]); | ||
for(var i=0,len=sort.length; i<len; i++) { | ||
data[sort[i]].select_sort = i+1; | ||
} | ||
} | ||
}; | ||
Vue.directive('sortable', { | ||
bind (el, binding, vnode) { | ||
var sortable = new Sortable(this.el, options) | ||
console.log(el); | ||
console.log(binding); | ||
console.log(vnode); | ||
//return; | ||
if (this.arg && !this.vm.sortable) { | ||
this.vm.sortable = {} | ||
} | ||
var data = binding.value; | ||
var options = { | ||
onUpdate (evt) { | ||
var sort = []; //每个位置上存放的item的index | ||
data.forEach((item, index) => { | ||
sort[item.select_sort-1] = index; | ||
}); | ||
var operateItem = sort.splice(evt.oldIndex, 1); | ||
sort.splice(evt.newIndex, 0, operateItem[0]); | ||
for(var i=0,len=sort.length; i<len; i++) { | ||
data[sort[i]].select_sort = i+1; | ||
} | ||
} | ||
}; | ||
// Throw an error if the given ID is not unique | ||
if (this.arg && this.vm.sortable[this.arg]) { | ||
console.warn('[vue-sortable] cannot set already defined sortable id: \'' + this.arg + '\'') | ||
} else if( this.arg ) { | ||
this.vm.sortable[this.arg] = sortable | ||
} | ||
}) | ||
var sortable = new Sortable(el, options) | ||
if (this.arg && !this.vm.sortable) { | ||
this.vm.sortable = {} | ||
} | ||
// Throw an error if the given ID is not unique | ||
if (this.arg && this.vm.sortable[this.arg]) { | ||
console.warn('[vue-sortable] cannot set already defined sortable id: \'' + this.arg + '\'') | ||
} else if( this.arg ) { | ||
this.vm.sortable[this.arg] = sortable | ||
} | ||
} | ||
}); | ||
} | ||
@@ -46,0 +56,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
2854
4
55
1
2