From: Lukasz Rekucki Date: Fri, 30 Oct 2009 12:13:35 +0000 (+0100) Subject: Poprawiony render przypisow. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/a916b4d2655ae35f58120ec601b71af8d8e63ea0?ds=inline Poprawiony render przypisow. Poprawione przelaczanie przypisow. --- diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index fd5af3b3..c975778d 100755 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -270,11 +270,6 @@ background-color: #dfdfdf; } -.htmlview .annotation-inline-box[x-focused] > .annotation { - background-color: #860000; - color: #dfdfdf; -} - *.htmlview *.annotation-inline-box { position: static; } @@ -303,11 +298,6 @@ text-decoration: none; z-index: 10; } - -.htmlview .annotation-inline-box[x-focused] > span[x-annotation-box], -.htmlview .annotation-inline-box:hover > span[x-annotation-box] { - display: block; - } /* @@ -337,16 +327,10 @@ counter-increment: secondary; } - - - - /* * EDITABLE ELEMENTS */ - - .htmlview *[x-editable] { padding-left: 3px; } @@ -427,6 +411,10 @@ opacity: 1; } +.htmlview *[x-annotation-box][x-editable] > .default-menu { + opacity: 1; +} + .htmlview *[x-editable][x-open] > .default-menu { visibility: hidden; } diff --git a/platforma/static/js/views/html.js b/platforma/static/js/views/html.js index 6481205c..d57640bc 100755 --- a/platforma/static/js/views/html.js +++ b/platforma/static/js/views/html.js @@ -121,11 +121,13 @@ var HTMLView = View.extend({ if($e.hasClass('annotation')) { - var $box = $e.parent(); - + if(this.currentOpen) return false; + + var $p = $e.parent(); if(this.currentFocused) { - if($box[0] == this.currentFocused[0]) { + console.log(this.currentFocused, $p); + if($p[0] == this.currentFocused[0]) { console.log('unfocus of current'); this.unfocusAnnotation(); return false; @@ -135,7 +137,7 @@ var HTMLView = View.extend({ this.unfocusAnnotation(); } - this.focusAnnotation($box); + this.focusAnnotation($p); return false; } @@ -155,22 +157,35 @@ var HTMLView = View.extend({ this.closeWithoutSave( this.editableFor($e) ); }, - unfocusAnnotation: function() { + unfocusAnnotation: function() + { if(!this.currentFocused) + { + console.log('Redundant unfocus'); return false; + } if(this.currentOpen && this.currentOpen.is("*[x-annotation-box]") && this.currentOpen.parent()[0] == this.currentFocused[0]) + { + console.log("Can't unfocus open box"); return false; - - this.currentFocused.removeAttr('x-focused'); + } + + var $box = $("*[x-annotation-box]", this.currentFocused); + $box.css({'display': 'none'}); + // this.currentFocused.removeAttr('x-focused'); + // this.currentFocused.hide(); this.currentFocused = null; }, focusAnnotation: function($e) { this.currentFocused = $e; - $e.attr('x-focused', 'focused'); + var $box = $("*[x-annotation-box]", $e); + $box.css({'display': 'block'}); + + // $e.attr('x-focused', 'focused'); }, closeWithSave: function($e) { @@ -193,8 +208,25 @@ var HTMLView = View.extend({ }, renderPart: function($e, html) { - $e.html(html); - $e.append( this.$menuTemplate.clone() ); + // exceptions aren't good, but I don't have a better idea right now + if($e.attr('x-annotation-box')) { + // replace the whole annotation + var $p = $e.parent(); + $p.html(html); + var $box = $('*[x-annotation-box]', $p); + $box.append( this.$menuTemplate.clone() ); + + if(this.currentFocused && $p[0] == this.currentFocused[0]) + { + this.currentFocused = $p; + $box.css({'display': 'block'}); + } + + return; + } + + $e.html(html); + $e.append( this.$menuTemplate.clone() ); }, editableFor: function($button) @@ -239,24 +271,29 @@ var HTMLView = View.extend({ this.model.getXMLPart($origin, function(path, data) { $('textarea', $overlay).val(data); - }); - - this.currentOpen = $origin; - $origin.attr('x-open', 'open'); + }); if($origin.is("*[x-annotation-box]")) { var $b = $origin.parent(); if(this.currentFocused) { - if($b[0] != this.currentFocused[0]) + // if some other is focused + if($b[0] != this.currentFocused[0]) { this.unfocusAnnotation(); + this.focusAnnotation($b); + } + // already focues + } + else { // nothing was focused + this.focusAnnotation($b); } - - this.focusAnnotation($origin); } - else { + else { // this item is not focusable if(this.currentFocused) this.unfocusAnnotation(); } + + this.currentOpen = $origin; + $origin.attr('x-open', 'open'); return false; }