You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by tv...@apache.org on 2012/02/20 12:39:19 UTC

svn commit: r1291213 - in /openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee: Application.js view/ApplicationJndiPanel.js

Author: tveronezi
Date: Mon Feb 20 11:39:18 2012
New Revision: 1291213

URL: http://svn.apache.org/viewvc?rev=1291213&view=rev
Log:
https://issues.apache.org/jira/browse/TOMEE-130

Creating a carousel to show jndi details.

Modified:
    openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/Application.js
    openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/view/ApplicationJndiPanel.js

Modified: openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/Application.js
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/Application.js?rev=1291213&r1=1291212&r2=1291213&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/Application.js (original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/Application.js Mon Feb 20 11:39:18 2012
@@ -60,5 +60,15 @@ TOMEE.utils = {
             return {};
         }
         return obj;
+    },
+
+    stringFormat: function() {
+        var s = arguments[0];
+        for (var i = 0; i < arguments.length - 1; i++) {
+            var reg = new RegExp("\\{" + i + "\\}", "gm");
+            s = s.replace(reg, arguments[i + 1]);
+        }
+
+        return s;
     }
 };
\ No newline at end of file

Modified: openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/view/ApplicationJndiPanel.js
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/view/ApplicationJndiPanel.js?rev=1291213&r1=1291212&r2=1291213&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/view/ApplicationJndiPanel.js (original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/staging/js/tomee/view/ApplicationJndiPanel.js Mon Feb 20 11:39:18 2012
@@ -23,26 +23,26 @@ TOMEE.ApplicationJndiPanel = function (c
     var model = cfg.jndiModel;
 
     var elements = (function () {
+        var carouselUid = TOMEE.Sequence.next('CAROUSEL');
         var tbodyUid = TOMEE.Sequence.next();
         var tpl = [
             '<div class="well">',
 
-            '<div id="myCarousel" class="carousel slide">',
-            '    <div class="carousel-inner">',
+            '<div class="carousel slide">',
+            '    <div id="' + carouselUid + '" class="carousel-inner">',
             '        <div class="item active">',
-            '<div style="overflow:auto; height: 300px">',
-            '<table class="table table-striped table-bordered table-condensed">',
-            '    <tbody id="' + tbodyUid + '"/>',
-            '</table>',
-            '</div>',
-
-            '            <br/><br/><br/><br/><br/><br/>',
-            '            <div class="carousel-caption">',
-            '                <h4>' + TOMEE.ApplicationI18N.get('app.home.menu.tools.jndi.browser') + '</h4>',
-            '                <p>' + TOMEE.ApplicationI18N.get('app.home.menu.tools.jndi.browser.info') + '</p>',
-            '            </div>',
+            '          <div style="overflow:auto; height: 300px">',
+            '          <table class="table table-striped table-bordered table-condensed">',
+            '              <tbody id="' + tbodyUid + '"/>',
+            '          </table>',
+            '          </div>',
+
+            '          <br/><br/><br/><br/><br/><br/>',
+            '          <div class="carousel-caption">',
+            '              <h4>' + TOMEE.ApplicationI18N.get('app.home.menu.tools.jndi.browser') + '</h4>',
+            '              <p>' + TOMEE.ApplicationI18N.get('app.home.menu.tools.jndi.browser.info') + '</p>',
+            '          </div>',
             '        </div>',
-
             '    </div>',
             '</div>',
             '</div>'
@@ -51,24 +51,77 @@ TOMEE.ApplicationJndiPanel = function (c
         //create the element
         var all = $(tpl.join(''));
         var tbody = all.find("#" + tbodyUid);
+        var carousel = all.find("#" + carouselUid);
         return {
             all: all,
-            tbody: tbody
+            tbody: tbody,
+            carousel: carousel
         };
     })();
 
-    /**
-     *
-     * @param bean
-     */
+    var addCarouselItem = function (carouselParams) {
+        var captionTpl = [
+            '          <br/><br/><br/><br/><br/><br/>',
+            '          <div class="carousel-caption">',
+            '              <h4>{0}</h4>',
+            '              <p>{1}</p>',
+            '          </div>',
+        ].join('');
+
+        var tpl = [
+            '        <div class="item">',
+            '          <div style="overflow:auto; height: 300px">',
+            '{0}',
+            '          </div>',
+            '{1}',
+            '        </div>'
+        ].join('');
+
+        var result = '';
+        if (carouselParams.caption) {
+            var caption = TOMEE.utils.stringFormat(captionTpl,
+                carouselParams.caption.title,
+                carouselParams.caption.message
+            );
+            result = TOMEE.utils.stringFormat(tpl, carouselParams.bodyTpl, caption);
+
+        } else {
+            result = TOMEE.utils.stringFormat(tpl, carouselParams.bodyTpl, '');
+        }
+
+        elements.carousel.append($(result));
+        elements.carousel.carousel('next');
+    };
+
+    var showBeanPanel = function (bean) {
+        addCarouselItem({
+            caption: {
+                title: 'Details',
+                message: 'Here comes the detail'
+            },
+            bodyTpl: 'Test!!!'
+        });
+    };
+
     var addRow = function (bean) {
+        var aUid = TOMEE.Sequence.next("JNDI-A");
+        var iUid = TOMEE.Sequence.next("JNDI-I");
         var row = [
             '        <tr>',
-            '            <td><a href="#">' + bean.name + '</a></td>',
-            '            <td><i class="icon-chevron-right"></i></td>',
+            '            <td><a id="' + aUid + '" href="#">' + bean.name + '</a></td>',
+            '            <td><i id="' + iUid + '" class="icon-chevron-right"></i></td>',
             '        </tr>'
         ].join('');
         elements.tbody.append($(row));
+        var a = elements.tbody.find("#" + aUid);
+        a.on('click', function () {
+            showBeanPanel(bean);
+        });
+
+        var i = elements.tbody.find("#" + iUid);
+        i.on('click', function () {
+            showBeanPanel(bean);
+        });
     };
 
     var loadData = function () {