Commit f777d39f authored by Thimo Kraemer's avatar Thimo Kraemer

Modified insertNodes to accept an arbitrary target selector

parent 15024258
/*
* KSS-RPC v0.17-beta
* KSS-RPC v0.18-beta
*
* Copyright (c) 2017, joonis new media
* Author: Thimo Kraemer <thimo.kraemer@joonis.de>
......@@ -61,7 +61,7 @@
******************************************************************************************/
var kss = {
version: '0.17-beta',
version: '0.18-beta',
_initialized: false,
_ruleSheets: {},
_eventBinders: {},
......@@ -1836,14 +1836,13 @@ kss.cssQuery = function(selector, context, dropContext) {
kss.insertNodes = function(nodes, toNode, position, copy) {
if (typeof toNode == 'string') {
toNode = toNode.split('#').pop();
var node = document.getElementById(toNode);
if (!node) {
kss.error('Element with id "#' + toNode
var found = kss.cssQuery(toNode);
if (!found.length) {
kss.error('Element with selector "' + toNode
+ '" not found to insert nodes');
return;
}
toNode = node;
toNode = found[0];
}
if (!kss.isArrayLike(nodes)) {
nodes = [nodes];
......@@ -2411,29 +2410,29 @@ kss.registerActionProvider({
},
// Actions to move content
moveNodeBefore: function(node, params) {
kss.insertNodesBefore(node, params.htmlId);
kss.insertNodesBefore(node, params.target);
},
moveNodeAfter: function(node, params) {
kss.insertNodesAfter(node, params.htmlId);
kss.insertNodesAfter(node, params.target);
},
moveNodeAsFirstChild: function(node, params) {
kss.prependNodes(node, params.htmlId);
kss.prependNodes(node, params.target);
},
moveNodeAsLastChild: function(node, params) {
kss.appendNodes(node, params.htmlId);
kss.appendNodes(node, params.target);
},
// Actions to copy content
copyNodeBefore: function(node, params) {
kss.insertNodesBefore(node, params.htmlId, true);
kss.insertNodesBefore(node, params.target, true);
},
copyNodeAfter: function(node, params) {
kss.insertNodesAfter(node, params.htmlId, true);
kss.insertNodesAfter(node, params.target, true);
},
copyNodeAsFirstChild: function(node, params) {
kss.prependNodes(node, params.htmlId, true);
kss.prependNodes(node, params.target, true);
},
copyNodeAsLastChild: function(node, params) {
kss.appendNodes(node, params.htmlId, true);
kss.appendNodes(node, params.target, true);
},
// Actions to set attributes
setNodeAttr: function(node, params) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment