integration/js/edition.js
changeset 164 0af17a6cce42
parent 136 ac4dc3d6400b
--- a/integration/js/edition.js	Fri Jun 21 10:31:54 2013 +0200
+++ b/integration/js/edition.js	Tue Jun 25 10:46:21 2013 +0200
@@ -239,6 +239,7 @@
     });
 
 
+
 /*  Chapter */
 
     //edit
@@ -857,10 +858,12 @@
         var tplDiapo = getTemplate('#tpl-slideshow-row');
         dataView.limitLength = function(){
             return function(text, render) {
-                if(render(text).length > lengthStringDiapo){
-                    return render(text).substr(0,lengthStringDiapo) + '...';
+          
+                var renderText = nl2br(render(text));
+                if(renderText.length > lengthStringDiapo){
+                    return renderText.substr(0,lengthStringDiapo) + '...';
                 }else{
-                    return render(text);
+                    return renderText;
                 }
             }
         }
@@ -879,10 +882,12 @@
             html = currentAnnotation.content.images[index][name];
         input.val(html);
         $(this).find('span').replaceWith(input);
-        input.focus().keypress(function(e){
-            code = (e.keyCode ? e.keyCode : e.which);
-            if (code == 13) $(this).blur();
-        });
+        if(name == 'title'){
+            input.focus().keypress(function(e){
+                code = (e.keyCode ? e.keyCode : e.which);
+                if (code == 13) $(this).blur();
+            });
+        }
     });
 
     $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){
@@ -893,6 +898,7 @@
         if(newValue.length>lengthStringDiapo){
             newValue = newValue.substr(0,lengthStringDiapo) + '...';
         }
+        newValue = nl2br(newValue, true)
         var span = $('<span>').html(newValue);
         $(this).replaceWith(span);
         
@@ -1347,6 +1353,11 @@
 
 /* Utilitys */
 
+function nl2br (str) {   
+    var breakTag = '<br />';    
+    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
+}
+    
 Array.prototype.move = function (old_index, new_index) {
     if (new_index >= this.length) {
         var k = new_index - this.length;