bugfix du bugfix…
[Plinn.git] / skins / content / folder_factories.pt
index 1171473..c5ec309 100644 (file)
@@ -1,49 +1,69 @@
-<html xmlns="http://www.w3.org/1999/xhtml"
-    metal:use-macro="here/main_template/macros/master">
-  <head>        
+<html metal:use-macro="here/main_template/macros/master">
+  <head>
     <meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
     <title>folder_factories</title>
     <link href="zpt_stylesheet.css" rel="stylesheet" media="screen"/>
     <link href="../content/plinn_style.css" rel="stylesheet" media="screen"/>
   </head>
-
   <body>
-
-    <div metal:fill-slot="main" i18n:domain="cmf_default">
+    <div metal:fill-slot="main" i18n:domain="plinn">
       <div tal:condition="python: not(here.portal_membership.checkPermission('Access contents information', here))">
-        <span tal:define="dummy here/unauthRedirect"></span>
+        <span tal:define="dummy here/unauthRedirect"/>
       </div>
-      <form action="." method="post" tal:attributes="action string:${here/absolute_url}/add_content">
-      <table cellspacing="0" tal:define="ucn here/getUntitledContentName" class="FolderFactories">
-        <tr>
-          <th><br /></th>
-          <th i18n:translate="">Type</th>
+      <form tal:attributes="action string:${here/absolute_url}/add_content" method="post" id="factories_form">
+        <table cellspacing="0" tal:define="ucn here/getUntitledContentName" class="FolderFactories">
+          <tr>
+            <th><br/></th>
+            <th i18n:translate="">Type</th>
             <th i18n:translate="">Name</th>
-            <th><br /></th>
+            <th><br/></th>
           </tr>
-        <div tal:repeat="item here/allowedContentTypes" tal:omit-tag="">
-          <tr tal:define="icon python:here.restrictedTraverse(item.getIcon())">
-            <td class="ListName">
-              <img tal:attributes="src icon/absolute_url ; alt item/Title ; height icon/height ; width icon/width" i18n:attributes="alt"/>
-            </td>
-            <td tal:content="item/Title" i18n:translate="" class="ListName">Content name</td>
+          <div tal:repeat="item here/allowedContentTypes" tal:omit-tag="">
+            <tr tal:define="icon python:here.restrictedTraverse(item.getIcon())">
+              <td class="ListName">
+                <img tal:attributes="src icon/absolute_url ; alt item/Title ; height icon/height ; width icon/width" i18n:attributes="alt"/>
+              </td>
+              <td tal:content="item/Title" i18n:translate="" class="ListName">Content name</td>
               <td tal:condition="python:not item.listActionInfos('object/create', check_visibility=0)">
-                <input type="text" name="id" size="24" tal:attributes="name string:${item/id}.id:record; value ucn" />
+                <input type="text" name="id" size="24" tal:attributes="name string:${item/id}.id:record; value ucn"/>
               </td>
               <td tal:condition="python:item.listActionInfos('object/create', check_visibility=0)">
                 <input type="hidden" value="1" tal:attributes="name string:${item/id}.create_form:record"/>
               </td>
               <td>
-                <input type="submit" value="Add" tal:attributes="name string:${item/id}.type:record" i18n:attributes="value" />
+                <input type="submit" value="Add" tal:attributes="name string:${item/id}.type:record" i18n:attributes="value"/>
               </td>
             </tr>
-          <tr>
+            <tr>
               <td colspan="4" class="spacing"></td>
             </tr>
-        </div>
-      </table>
+          </div>
+        </table>
       </form>
+      <script type="text/javascript" charset="utf-8">
+        (function(){
+          var fform = document.getElementById('factories_form');
+          var fm = new FormManager(fform);
+          var submitButton;
+          fm.onBeforeSubmit = function(self, evt) {
+            if (submitButton)
+              self.submitButton = submitButton;
+          };
+          var id2type = /(^[^\.]+)\.id:record$/;
+          function trackFocus(evt) {
+            var input = getTargetedObject(evt);
+            var matches = id2type.exec(input.name);
+            if (matches && matches.length == 2)
+              submitButton = fform.elements[matches[1] + '.type:record'];
+          }
+          var e;
+          for (var i = 0 ; i < fform.elements.length ; i++) {
+            e = fform.elements[i];
+            if (e.type==='text')
+              addListener(e, 'focus', trackFocus);
+          }
+        }());
+      </script>
     </div>
   </body>
-
-</html>
\ No newline at end of file
+</html>