# HG changeset patch # User Anthony Ly # Date 1372149981 -7200 # Node ID 0af17a6cce424a5c6cd988a64f77cf5c48d35a9b # Parent d8f73c6dddf5e35cce28696fec78516050462699 nl2br on slideshow row description diff -r d8f73c6dddf5 -r 0af17a6cce42 integration/js/edition.js --- 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 = $('').html(newValue); $(this).replaceWith(span); @@ -1347,6 +1353,11 @@ /* Utilitys */ +function nl2br (str) { + var breakTag = '
'; + 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;