- next = idx < parentContents.length - 1 ? parentContents[idx+1] : null;
- if(next) {
- $(next).data('orig-before', toAdd);
- } else {
- elParent.data('orig-append', toAdd);
- }
+ prev = idx > 0 ? parentContents[idx-1] : null,
+ next = idx < parentContents.length - 1 ? parentContents[idx+1] : null,
+ target, key;
+
+ if(where === 'above') {
+ target = prev ? $(prev) : elParent;
+ key = prev ? 'orig-after' : 'orig-begin';
+ } else if(where === 'below') {
+ target = next ? $(next) : elParent;
+ key = next ? 'orig-before' : 'orig-end';
+ } else { throw new Object;}
+
+ target.data(key, toAdd);