From cb8ff428cd0b523137a8093763c1bfaa99499dbf Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Mon, 18 Nov 2013 12:04:26 +0100 Subject: [PATCH] Remove terrible hack for setting the dc:creator field's text in an annotation; now that we have first-class access to member data, we can set this value directly within OpAddAnnotation. --- webodf/lib/gui/AnnotationViewManager.js | 23 ----------------------- webodf/lib/gui/SessionView.js | 1 - webodf/lib/ops/OpAddAnnotation.js | 3 +-- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/webodf/lib/gui/AnnotationViewManager.js b/webodf/lib/gui/AnnotationViewManager.js index 769cf8cb..8d6b3ef9 100644 --- a/webodf/lib/gui/AnnotationViewManager.js +++ b/webodf/lib/gui/AnnotationViewManager.js @@ -220,29 +220,6 @@ gui.AnnotationViewManager = function AnnotationViewManager(odfCanvas, odfFragmen connectorAngular.style.MozTransform = 'rotate(' + connectorAngle + 'rad)'; connectorAngular.style.WebkitTransform = 'rotate(' + connectorAngle + 'rad)'; connectorAngular.style.msTransform = 'rotate(' + connectorAngle + 'rad)'; - - // Bad hack: Since we do not have a straightforward way to access member data here, we will read the computed style - // of dc:creator[editinfo|memberid]:before, always applied by SessionView, because that contains the creator name - // as the content, when an annotation is created by OpAddAnnotation. - if (creatorNode) { - creatorName = window.getComputedStyle(/**@type{!Element}*/(creatorNode), ':before').content; - // The default `content: ` value for :before and :after pseudo-elements - // in webkit is '' and `none` in gecko. - if (creatorName && creatorName !== 'none') { - // Strip possible opening and closing quotes -/*jslint regexp: true*/ // jslint complains otherwise about "Insecure '.'" - if (/^["'].*["']$/.test(creatorName)) { - creatorName = creatorName.substring(1, creatorName.length - 1); - } -/*jslint regexp: false*/ - if (creatorNode.firstChild) { - creatorNode.firstChild.nodeValue = creatorName; - } else { - creatorNode.appendChild(doc.createTextNode(creatorName)); - } - } - } - } /** diff --git a/webodf/lib/gui/SessionView.js b/webodf/lib/gui/SessionView.js index 8a48bbd6..04d3f134 100644 --- a/webodf/lib/gui/SessionView.js +++ b/webodf/lib/gui/SessionView.js @@ -163,7 +163,6 @@ gui.SessionView = (function () { setStyle('div.editInfoMarker', '{ background-color: ' + color + '; }', ''); setStyle('span.editInfoColor', '{ background-color: ' + color + '; }', ''); setStyle('span.editInfoAuthor', '{ content: "' + name + '"; }', ':before'); - setStyle('dc|creator', '{ content: "' + name + '"; display: none;}', ':before'); setStyle('dc|creator', '{ background-color: ' + color + '; }', ''); setStyle('div.selectionOverlay', '{ background-color: ' + color + ';}', ''); } diff --git a/webodf/lib/ops/OpAddAnnotation.js b/webodf/lib/ops/OpAddAnnotation.js index d22a1ebf..aa10f385 100644 --- a/webodf/lib/ops/OpAddAnnotation.js +++ b/webodf/lib/ops/OpAddAnnotation.js @@ -72,10 +72,9 @@ ops.OpAddAnnotation = function OpAddAnnotation() { annotationNode = doc.createElementNS(odf.Namespaces.officens, 'office:annotation'); annotationNode.setAttributeNS(odf.Namespaces.officens, 'office:name', name); - // Only set the memberid attribute on dc:creator. Let the annotation manager actually set the name - // for now creatorNode = doc.createElementNS(odf.Namespaces.dcns, 'dc:creator'); creatorNode.setAttributeNS('urn:webodf:names:editinfo', 'editinfo:memberid', memberid); + creatorNode.textContent = odtDocument.getMember(memberid).getProperties().fullName; // Date.toISOString return the current Dublin Core representation dateNode = doc.createElementNS(odf.Namespaces.dcns, 'dc:date');