From 35ca9353f12d0c6b65da2ac05675791d38793ab1 Mon Sep 17 00:00:00 2001 From: zuber Date: Thu, 14 Jan 2010 14:19:00 +0100 Subject: [PATCH 1/1] =?utf8?q?Ustawianie=20focusu=20na=20textarea=20po=20k?= =?utf8?q?likni=C4=99ciu=20"Edytuj"=20w=20widoku=20HTML.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- platforma/static/css/html.css | 2 +- platforma/static/js/main.js | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) 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 = $(''); -- 2.20.1