From 3159936d9649673b6fee0d660f6ea20712321315 Mon Sep 17 00:00:00 2001
From: "Mark M. Florida" <mflorida@gmail.com>
Date: Thu, 28 Apr 2016 15:51:30 -0500
Subject: [PATCH] Adding starter files for working with the XNAT.spawner
 methods, which are different than the spawn() $('p').spawn() and $.spawn()
 functions!

---
 src/main/webapp/page/spawn/content.jsp  | 32 ++++++++++++++++++
 src/main/webapp/page/spawn/index.jsp    | 11 ++++++
 src/main/webapp/scripts/xnat/spawner.js | 45 +++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 src/main/webapp/page/spawn/content.jsp
 create mode 100644 src/main/webapp/page/spawn/index.jsp
 create mode 100644 src/main/webapp/scripts/xnat/spawner.js

diff --git a/src/main/webapp/page/spawn/content.jsp b/src/main/webapp/page/spawn/content.jsp
new file mode 100644
index 00000000..2daf703a
--- /dev/null
+++ b/src/main/webapp/page/spawn/content.jsp
@@ -0,0 +1,32 @@
+<%@ page session="true" contentType="text/html" pageEncoding="UTF-8" language="java" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="pg" tagdir="/WEB-INF/tags/page" %>
+<%--<%@ taglib prefix="sp" tagdir="/WEB-INF/tags/spawner" %>--%>
+
+<c:if test="${empty hasInit}">
+    <pg:init>
+        <c:if test="${empty hasVars}">
+            <pg:jsvars/>
+        </c:if>
+    </pg:init>
+</c:if>
+
+<c:set var="MSG">
+    Playground clossed.
+</c:set>
+
+<pg:restricted msg="${MSG}">
+
+    <c:set var="_siteRoot" value="${sessionScope.siteRoot}"/>
+
+    <!-- playground for XNAT.spawner methods -->
+
+    <div id="spawn-container"></div>
+
+    <script src="${_siteRoot}/scripts/xnat/spawner.js"></script>
+
+    <script>
+
+    </script>
+
+</pg:restricted>
\ No newline at end of file
diff --git a/src/main/webapp/page/spawn/index.jsp b/src/main/webapp/page/spawn/index.jsp
new file mode 100644
index 00000000..5659c18f
--- /dev/null
+++ b/src/main/webapp/page/spawn/index.jsp
@@ -0,0 +1,11 @@
+<%@ page session="true" contentType="text/html" pageEncoding="UTF-8" language="java" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="pg" tagdir="/WEB-INF/tags/page" %>
+
+<pg:wrapper>
+    <pg:xnat>
+
+        <jsp:include page="content.jsp"/>
+
+    </pg:xnat>
+</pg:wrapper>
diff --git a/src/main/webapp/scripts/xnat/spawner.js b/src/main/webapp/scripts/xnat/spawner.js
new file mode 100644
index 00000000..49249c0f
--- /dev/null
+++ b/src/main/webapp/scripts/xnat/spawner.js
@@ -0,0 +1,45 @@
+/*!
+ * Spawn UI elements using the Spawner service
+ */
+
+var XNAT = getObject(XNAT);
+
+(function(factory){
+    if (typeof define === 'function' && define.amd) {
+        define(factory);
+    }
+    else if (typeof exports === 'object') {
+        module.exports = factory();
+    }
+    else {
+        return factory();
+    }
+}(function(){
+
+    var undefined,
+        spawner = getObject(XNAT.spawner||{});
+
+    function Spawner(obj){
+        extend(true, this, obj);
+        this.spawned = null;
+        this.children = {};
+    }
+
+    Spawner.p = Spawner.prototype;
+
+    Spawner.p.init = function(obj){
+
+    };
+
+    Spawner.p.render = function($container){
+        $$($container).append(this.spawned);
+        return this;
+    };
+
+    spawner.spawn = function(obj){
+        return new Spawner(obj);
+    };
+
+    return XNAT.spawner = spawner;
+
+}));
-- 
GitLab