From: zuber Date: Thu, 14 Jan 2010 13:19:00 +0000 (+0100) Subject: Ustawianie focusu na textarea po kliknięciu "Edytuj" w widoku HTML. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/35ca9353f12d0c6b65da2ac05675791d38793ab1 Ustawianie focusu na textarea po kliknięciu "Edytuj" w widoku HTML. --- diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index 2c78efa4..d64cd6ea 100755 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -453,7 +453,7 @@ z-index: 0; font-size: 10pt; - background-color: ivory; +/* background-color: ivory;*/ } /*/ diff --git a/platforma/static/js/main.js b/platforma/static/js/main.js index e5566a84..ed22f590 100644 --- a/platforma/static/js/main.js +++ b/platforma/static/js/main.js @@ -274,14 +274,15 @@ function reverseTransform(editor) { } +// ============= +// = HTML View = +// ============= function html(element) { var element = $(element); function selectTheme(themeId) { var selection = window.getSelection(); - - // remove current selection selection.removeAllRanges(); var range = document.createRange(); @@ -295,6 +296,7 @@ function html(element) { } }; + function openForEdit($origin) { // if(this.currentOpen && this.currentOpen != $origin) { @@ -314,10 +316,6 @@ function html(element) { var w = $box.outerWidth(); var h = $box.innerHeight(); - console.log("Edit origin:", $origin, " box:", $box); - console.log("offsetParent:", $box[0].offsetParent); - console.log("Dimensions: ", x, y, w , h); - // start edition on this node var $overlay = $('
'); var serializer = new XMLSerializer(); @@ -325,7 +323,12 @@ function html(element) { html2xml({ xml: serializer.serializeToString($box.get(0)), success: function(text) { - $('textarea', $overlay).focus().val($.trim(text)); + $('textarea', $overlay).val($.trim(text)); + + setTimeout(function() { + console.log('focus!'); + $('textarea', $overlay).focus(); + }, 100); $('textarea', $overlay).one('blur', function(event) { xml2html({ @@ -346,7 +349,7 @@ function html(element) { } }); - h = Math.max(h - 20, 2*parseInt($box.css('line-height'))); + // h = Math.max(h, 2*parseInt($box.css('line-height'))); console.log(h); @@ -363,8 +366,8 @@ function html(element) { } $('.edit-button').live('click', function(event) { + event.preventDefault(); openForEdit($(this).parent()); - return false; }); var button = $('');