Changeset 24941
- Timestamp:
- 2012-01-12T11:03:59+13:00 (12 years ago)
- Location:
- gs3-extensions/html-to-expeditee/trunk/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm
r24939 r24941 28 28 use strict; 29 29 30 use CssStyleToExpAttr; 31 30 32 sub new 31 33 { … … 77 79 78 80 # load up some defaults for font information 79 my $ font_family = "s"; # t80 my $ font_face = "r";81 my $ font_size = "14";81 my $exp_font_family = "s"; # t 82 my $exp_font_face = "r"; 83 my $exp_font_size = "14"; 82 84 83 85 # if (defined $css_attr->{'font-family'}) { … … 85 87 # } 86 88 87 # if (defined $css_attr->{'font-size'}) { 88 # $font_size = convert_font_size($css_attr->{'font-size'}); 89 # } 89 if (defined $css_attr->{'font-size'}) { 90 my $css_font_size = $css_attr->{'font-size'}; 91 $exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size); 92 } 90 93 91 94 # if (defined $css_attr->{'font-face'}) { 92 95 # $font = conver_font_face($css_attr->{'font-face'}); 93 96 # } 97 98 # $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size; 94 99 95 100 return $exp_attr; … … 169 174 $self->setPointDefaultAttributes($attr); 170 175 171 $attr->{'d'} = " 50 100 50"; # green color for rect lines172 $attr->{'h'} = " 2.0"; # line thickness176 $attr->{'d'} = "80 80 80"; # green color for rect lines 177 $attr->{'h'} = "1.0"; # line thickness 173 178 } 174 179 … … 193 198 { 194 199 my $self = shift @_; 195 my ($x, $y, $text, $attr) = @_; 196 197 # fudge factor for now (based on default font size used) 198 $y += 16; # y-value of text item in Expeditee is it's base line 199 $x += 4; 200 my ($x, $y, $text, $w, $attr) = @_; 200 201 201 202 my %attr_copy = %$attr; # make a private copy of 'attr' … … 207 208 $attr_copy{'P'} = "$x $y"; 208 209 $attr_copy{'T'} = $text; 210 $attr_copy{'w'} = "-$w" if (defined $w); 209 211 210 212 return $self->_addItem("T",\%attr_copy); … … 442 444 $self->addRect($xl,$yt,$xr,$yb,$attr); 443 445 446 if (defined $html_node->{'img'}) { 447 448 my $img_url = $html_node->{'img'}; 449 $img_url =~ s/^http:\/\/www\.nzdl\.org\/greenstone3-showcase\///; 450 if ($img_url =~ m/^interfaces\//) { 451 $img_url = "images/$img_url"; 452 } 453 elsif ($img_url =~ m/^sites\//) { 454 $img_url =~ s/^sites\/(.*?)\//images\//; 455 } 456 457 my $x = $xl; 458 my $y = $yt; 459 460 my $attr = {}; 461 462 my $img_text = "\@i: $img_url"; 463 464 $self->addText($x,$y,$img_text,undef,$attr); 465 } 466 444 467 } 445 468 elsif ($type eq "text") { 446 469 my $text = $html_node->{'text'}; 447 470 448 my $x = $html_node->{'x'}; 449 my $y = $html_node->{'y'}; 471 my $x = $html_node->{'xl'}; 472 my $y = $html_node->{'yt'}; 473 my $w = $html_node->{'xr'} - $x +1; 450 474 451 475 my $attr = convertStyleToAttr($html_node->{'style'}); 452 476 453 $self->addText($x,$y,$text,$attr); 477 # fudge factor for now (based on default font size used) 478 $y += 16; # y-value of text item in Expeditee is it's base line 479 $x += 4; 480 481 $self->addText($x,$y,$text,$w,$attr); 454 482 } 455 483 else { -
gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js
r24939 r24941 52 52 } 53 53 54 function getStyle(node,styleProp) 55 { 54 function hyphenToInitialCapReplacer(str, p1, offset, s) 55 { 56 return p1.toUpperCase(); 57 } 58 59 function getStyle(node,style_prop) 60 { 61 var prop_val; 56 62 if (node.currentStyle) { 57 var y = node.currentStyle[styleProp]; 63 /* IE */ 64 style_prop = strCssRule.replace(/\-(\w)/g, hyphenToInitialCapReplacer); 65 prop_val = node.currentStyle[style_prop]; 58 66 } 59 67 else if (window.getComputedStyle) { 60 var y = document.defaultView.getComputedStyle(node,null).getPropertyValue(styleProp); 61 } 62 return y; 68 /* Firefox */ 69 var computed_style = document.defaultView.getComputedStyle(node,null) 70 prop_val = computed_style.getPropertyValue(style_prop); 71 } 72 else { 73 /* try for inline value */ 74 prop_val = el.style[style_prop]; 75 } 76 77 return prop_val; 78 63 79 } 64 80 … … 110 126 jsonNode.text = node.nodeValue; 111 127 112 jsonNode.x = pxl; 113 jsonNode.y = pyt; 128 jsonNode.xl = pxl; 129 jsonNode.yt = pyt; 130 jsonNode.xr = pxr; 131 jsonNode.yb = pyb; 114 132 115 133 } … … 119 137 /* need to handle: img, a, li */ 120 138 /* need to dig out: text size, l/r/justified, font-face, type, colour */ 139 140 if (getStyle(node,"visibility").match("hidden") 141 || getStyle(node,"display").match("none")) { 142 143 return null; 144 } 121 145 122 146 var elemName = node.nodeName.toLowerCase(); … … 137 161 jsonNode.rect = rect; 138 162 163 if (elemName.match("img")) { 164 jsonNode.img = node.src; 165 } 139 166 140 167 var style = {}; 141 168 142 style["font-family"] = getStyle(node,"font-family"); 169 style["font-family"] = getStyle(node,"font-family"); 170 style["font-size"] = getStyle(node,"font-size"); 143 171 style["background-color"] = getStyle(node,"background-color"); 144 172 173 // console.log("font size = " + style["font-size"]); 174 145 175 jsonNode.style = style 146 176
Note:
See TracChangeset
for help on using the changeset viewer.