From 78e82e5ab6e4a8a5b7e8a75a3ee9eff2aefcd738 Mon Sep 17 00:00:00 2001
From: Gabriel Monnerat <gabriel@tiolive.com>
Date: Tue, 22 Mar 2011 15:32:44 +0000
Subject: [PATCH] Add the abbreviated title when the title have longer than 30
 characters. This is need to not break the ung content layout

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44510 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_web_ung_theme/ung_js/ung.js.xml      | 22 ++++++++++++++-----
 bt5/erp5_web_ung_theme/bt/revision            |  2 +-
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung.js.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung.js.xml
index 9581f9afb0..963e5f579f 100644
--- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung.js.xml
+++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung.js.xml
@@ -188,6 +188,17 @@ function reloadLoginPage(event){\n
   }\n
 }\n
 \n
+function displayDocumentTitle(title){\n
+  var document_title = title;\n
+  document_title == null ? document_title = getObjectPropertyValue("getTitle"): null;\n
+  if (document_title.length > 30){\n
+    $("a[name=\'document_title\']").html(document_title.substring(0,30) + "...");\n
+  }\n
+  else{\n
+    $("a[name=\'document_title\']").html(document_title);\n
+  };\n
+}\n
+\n
 $().ready(function(){\n
   $("p.clear").remove();\n
   if ($("a#login").html() != null){\n
@@ -222,7 +233,7 @@ $().ready(function(){\n
         break;\n
     }\n
   }\n
-  $("a[name=\'document_title\']").html(getObjectPropertyValue("getTitle"));\n
+  displayDocumentTitle(null);\n
   $("input#upload").click(function(event){\n
     event.preventDefault();\n
     $("#upload_document").dialog("open");\n
@@ -340,7 +351,7 @@ $().ready(function(){\n
         var new_version = $("input#version.version").attr("value");\n
         var new_int_index = $("input#sort_index.sort_index").attr("value");\n
         var new_subject_list = $("textarea#keyword_list").attr("value").replace(/\\n+/g, ",");\n
-        $("a[name=\'document_title\']").html(new_title);\n
+        displayDocumentTitle(new_title);\n
         setObjectPropertyValue("setTitle", new_title, "value");\n
         setObjectPropertyValue("setReference", new_reference, "value");\n
         setObjectPropertyValue("setShortTitle", new_short_title, "value");\n
@@ -467,10 +478,11 @@ $().ready(function(){\n
     .click(function(){\n
       $("div#more_property").hide();\n
       $("p#hide_properties").hide();\n
-      if ($("input#name.title").attr("value") != getObjectPropertyValue("getTitle")) {\n
-        $(this).html(getObjectPropertyValue("getTitle"));\n
+      var document_title = getObjectPropertyValue("getTitle");\n
+      if ($("input#name.title").attr("value") != document_title) {\n
+        displayDocumentTitle();\n
       }\n
-      $("input#name.title").attr("value", getObjectPropertyValue("getTitle"));\n
+      $("input#name.title").attr("value", document_title);\n
       $("input#short_title.short_title").attr("value", getObjectPropertyValue("getShortTitle"));\n
       $("input#reference.reference").attr("value", getObjectPropertyValue("getReference"));\n
       $("input#version.version").attr("value", getObjectPropertyValue("getVersion"));\n
diff --git a/bt5/erp5_web_ung_theme/bt/revision b/bt5/erp5_web_ung_theme/bt/revision
index 4d85316228..e0da8ae09a 100644
--- a/bt5/erp5_web_ung_theme/bt/revision
+++ b/bt5/erp5_web_ung_theme/bt/revision
@@ -1 +1 @@
-308
\ No newline at end of file
+309
\ No newline at end of file
-- 
2.30.9