|
|
@ -1,55 +1,61 @@ |
|
|
|
|
|
|
|
/*global ko*/ |
|
|
|
|
|
|
|
|
|
|
|
(function (factory) { |
|
|
|
(function (factory) { |
|
|
|
"use strict"; |
|
|
|
"use strict"; |
|
|
|
//get ko ref via global or require
|
|
|
|
//get ko ref via global or require
|
|
|
|
var koRef; |
|
|
|
var koRef; |
|
|
|
if (typeof ko !== 'undefined') { |
|
|
|
if (typeof ko !== 'undefined') { |
|
|
|
//global ref already defined
|
|
|
|
//global ref already defined
|
|
|
|
koRef = ko; |
|
|
|
koRef = ko; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { |
|
|
|
else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { |
|
|
|
//commonjs / node.js
|
|
|
|
//commonjs / node.js
|
|
|
|
koRef = require('knockout'); |
|
|
|
koRef = require('knockout'); |
|
|
|
} |
|
|
|
} |
|
|
|
//get sortable ref via global or require
|
|
|
|
//get sortable ref via global or require
|
|
|
|
var sortableRef; |
|
|
|
var sortableRef; |
|
|
|
if (typeof Sortable !== 'undefined') { |
|
|
|
if (typeof Sortable !== 'undefined') { |
|
|
|
//global ref already defined
|
|
|
|
//global ref already defined
|
|
|
|
sortableRef = Sortable; |
|
|
|
sortableRef = Sortable; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { |
|
|
|
else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { |
|
|
|
//commonjs / node.js
|
|
|
|
//commonjs / node.js
|
|
|
|
sortableRef = require('sortablejs'); |
|
|
|
sortableRef = require('sortablejs'); |
|
|
|
} |
|
|
|
} |
|
|
|
//use references if we found them
|
|
|
|
//use references if we found them
|
|
|
|
if (koRef !== undefined && sortableRef !== undefined) { |
|
|
|
if (koRef !== undefined && sortableRef !== undefined) { |
|
|
|
factory(koRef, sortableRef); |
|
|
|
factory(koRef, sortableRef); |
|
|
|
} |
|
|
|
} |
|
|
|
//if both references aren't found yet, get via AMD if available
|
|
|
|
//if both references aren't found yet, get via AMD if available
|
|
|
|
else if (typeof define === 'function' && define.amd){ |
|
|
|
else if (typeof define === 'function' && define.amd) { |
|
|
|
//we may have a reference to only 1, or none
|
|
|
|
//we may have a reference to only 1, or none
|
|
|
|
if (koRef !== undefined && sortableRef === undefined) { |
|
|
|
if (koRef !== undefined && sortableRef === undefined) { |
|
|
|
define(['./Sortable'], function(amdSortableRef){ factory(koRef, amdSortableRef); }); |
|
|
|
define(['./Sortable'], function (amdSortableRef) { |
|
|
|
} |
|
|
|
factory(koRef, amdSortableRef); |
|
|
|
else if (koRef === undefined && sortableRef !== undefined) { |
|
|
|
}); |
|
|
|
define(['knockout'], function(amdKnockout){ factory(amdKnockout, sortableRef); }); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (koRef === undefined && sortableRef !== undefined) { |
|
|
|
else if (koRef === undefined && sortableRef === undefined) { |
|
|
|
define(['knockout'], function (amdKnockout) { |
|
|
|
define(['knockout', './Sortable'], factory); |
|
|
|
factory(amdKnockout, sortableRef); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
//no more routes to get references
|
|
|
|
else if (koRef === undefined && sortableRef === undefined) { |
|
|
|
else { |
|
|
|
define(['knockout', './Sortable'], factory); |
|
|
|
//report specific error
|
|
|
|
} |
|
|
|
if (koRef !== undefined && sortableRef === undefined) { |
|
|
|
} |
|
|
|
throw new Error('knockout-sortable could not get reference to Sortable'); |
|
|
|
//no more routes to get references
|
|
|
|
} |
|
|
|
else { |
|
|
|
else if (koRef === undefined && sortableRef !== undefined) { |
|
|
|
//report specific error
|
|
|
|
throw new Error('knockout-sortable could not get reference to Knockout'); |
|
|
|
if (koRef !== undefined && sortableRef === undefined) { |
|
|
|
} |
|
|
|
throw new Error('knockout-sortable could not get reference to Sortable'); |
|
|
|
else if (koRef === undefined && sortableRef === undefined) { |
|
|
|
} |
|
|
|
throw new Error('knockout-sortable could not get reference to Knockout or Sortable'); |
|
|
|
else if (koRef === undefined && sortableRef !== undefined) { |
|
|
|
} |
|
|
|
throw new Error('knockout-sortable could not get reference to Knockout'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (koRef === undefined && sortableRef === undefined) { |
|
|
|
|
|
|
|
throw new Error('knockout-sortable could not get reference to Knockout or Sortable'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
})(function (ko, Sortable) { |
|
|
|
})(function (ko, Sortable) { |
|
|
|
"use strict"; |
|
|
|
"use strict"; |
|
|
|
|
|
|
|
|
|
|
|