@@ -558,12 +558,15 @@ class Main extends Model {
558558 return switch ( c .type ) {
559559 case TInt :
560560 switch (c .display ) {
561- case Percent : ' $v %' ;
561+ case Percent :
562+ ' <span> $v %</span> <div style="display: inline-block; position: relative; width: 40px; height: 8px; background-color: rgba(80, 158, 227, 0.2); border-radius: 3px;"><div style="position: absolute; top: 0px; bottom: 0px; background-color: rgb(80, 158, 227); width: $v %; left: 0px; border-radius: 3px;"></div></div>' ;
562563 default : ' $v ' ;
563564 }
564565 case TFloat :
565566 switch ( c .display ) {
566- case Percent : ' ${(Math .round (v * 10000 )/ 100 )}%' ;
567+ case Percent :
568+ var percent = (Math .round (v * 10000 )/ 100 );
569+ ' <span> ${percent }%</span> <div style="display: inline-block; position: relative; width: 40px; height: 8px; background-color: rgba(80, 158, 227, 0.2); border-radius: 3px;"><div style="position: absolute; top: 0px; bottom: 0px; background-color: rgb(80, 158, 227); width: $percent %; left: 0px; border-radius: 3px;"></div></div>' ;
567570 default : ' $v ' ;
568571 }
569572 case TId :
@@ -606,7 +609,7 @@ class Main extends Model {
606609 default :
607610 vals .push (valueHtml (c , Reflect .field (v , c .name ), ps , v ));
608611 }
609- var v = vals .length == 1 ? vals [0 ] : vals .join (" ," );
612+ var v = vals .length == 1 ? vals [0 ] : vals .join (" , " );
610613 if ( size > 200 ) {
611614 out .push (" ..." );
612615 break ;
@@ -662,11 +665,9 @@ class Main extends Model {
662665 var url = " file://" + path ;
663666 var ext = v .split (" ." ).pop ().toLowerCase ();
664667 var val = StringTools .htmlEscape (v );
665- var html = v == " " ? ' <span class="error">#MISSING</span>' : ' <span title=" $val "> $val </span>' ;
668+ var html = v == " " ? ' <span class="error">#MISSING</span>' : ' <span title=" $val " onmouseover="_.onFileOver( \' $ url \' )" onmouseleave="_.onFileLeave( \' $ url \' )" > $val </span>' ;
666669 if ( v != " " && ! quickExists (path ) )
667670 html = ' <span class="error">' + html + ' </span>' ;
668- // else if( ext == "png" || ext == "jpg" || ext == "jpeg" || ext == "gif" )
669- // html = '<span class="preview">$html<div class="previewContent"><div class="label"></div><img src="$url" onload="$(this).parent().find(\'.label\').text(this.width+\'x\'+this.height)"/></div></span>';
670671 if ( v != " " )
671672 html + = ' <i class="fa fa-external-link openfile" aria-hidden="true" onclick="_.openFile(\' $path \' )"></i>' ;
672673 html ;
@@ -686,6 +687,16 @@ class Main extends Model {
686687 }
687688 }
688689
690+ function onFileOver (_url : String ) {
691+ J (' .previewContent > img' ).replaceWith (' <img src=" $_url " onload="$(this).parent().find( \' .label \' ).text(this.naturalWidth+ \' x \' +this.naturalHeight)"/>' );
692+ J (' .imagePreview' ).show ();
693+ }
694+
695+ function onFileLeave (_url : String ) {
696+ J (' .imagePreview' ).hide ();
697+ J (' .previewContent > img' ).replaceWith (' <img />' );
698+ }
699+
689700 function popupLine ( sheet : Sheet , index : Int ) {
690701 var n = new Menu ();
691702 var nup = new MenuItem ( { label : " Move Up" } );
@@ -696,8 +707,16 @@ class Main extends Model {
696707 var nref = new MenuItem ( { label : " Show References" } );
697708 for ( m in [nup , ndown , nins , ndel , nsep , nref ] )
698709 n .append (m );
699- // var sepIndex = Lambda.indexOf(sheet.separators, index);
700- // nsep.checked = sepIndex >= 0;
710+
711+ var sepIndex = - 1 ;
712+ for (i in 0 ... sheet .separators .length ) {
713+ var s = sheet .separators [i ];
714+ if (s .index == index ) {
715+ sepIndex = i ;
716+ break ;
717+ }
718+ }
719+ nsep .checked = sepIndex >= 0 ;
701720 nins .click = function () {
702721 newLine (sheet , index );
703722 };
@@ -712,24 +731,14 @@ class Main extends Model {
712731 refresh ();
713732 save ();
714733 };
715- // nsep.click = function() {
716- // if( sepIndex >= 0 ) {
717- // sheet.separators.splice(sepIndex, 1);
718- // if( sheet.props.separatorTitles != null ) sheet.props.separatorTitles.splice(sepIndex, 1);
719- // } else {
720- // sepIndex = sheet.separators.length;
721- // for( i in 0...sheet.separators.length )
722- // if( sheet.separators[i] > index ) {
723- // sepIndex = i;
724- // break;
725- // }
726- // sheet.separators.insert(sepIndex, index);
727- // if( sheet.props.separatorTitles != null && sheet.props.separatorTitles.length > sepIndex )
728- // sheet.props.separatorTitles.insert(sepIndex, null);
729- // }
730- // refresh();
731- // save();
732- // };
734+ nsep .click = function () {
735+ if (sepIndex >= 0 ) { // remove
736+ sheet .separators .splice (sepIndex , 1 );
737+ } else
738+ sheet .separators .push ({index : index , id :Std .string (sepIndex ), title :" unnamed separator" });
739+ refresh ();
740+ save ();
741+ };
733742 nref .click = function () {
734743 showReferences (sheet , index );
735744 };
@@ -1915,38 +1924,34 @@ class Main extends Model {
19151924 content .append (cols );
19161925
19171926 var snext = 0 ;
1927+ var sepMap = new Map <Int , Separator >();
1928+ for (s in sheet .separators )
1929+ sepMap .set (s .index , s );
1930+
19181931 for ( i in 0 ... lines .length ) {
1919- // while( sheet.separators[snext] == i ) {
1920- // var sep = J("<tr>").addClass("separator").append('<td colspan="${colCount+1}">').appendTo(content);
1921- // var content = sep.find("td");
1922- // var title = if( sheet.props.separatorTitles != null ) sheet.props.separatorTitles[snext] else null;
1923- // if( title != null ) content.text(title);
1924- // var pos = snext;
1925- // sep.dblclick(function(e) {
1926- // content.empty();
1927- // J("<input>").appendTo(content).focus().val(title == null ? "" : title).blur(function(_) {
1928- // title = JTHIS.val();
1929- // JTHIS.remove();
1930- // content.text(title);
1931- // var titles = sheet.props.separatorTitles;
1932- // if( titles == null ) titles = [];
1933- // while( titles.length < pos )
1934- // titles.push(null);
1935- // titles[pos] = title == "" ? null : title;
1936- // while( titles[titles.length - 1] == null && titles.length > 0 )
1937- // titles.pop();
1938- // if( titles.length == 0 ) titles = null;
1939- // sheet.props.separatorTitles = titles;
1940- // save();
1941- // }).keypress(function(e) {
1942- // e.stopPropagation();
1943- // }).keydown(function(e) {
1944- // if( e.keyCode == 13 ) { JTHIS.blur(); e.preventDefault(); } else if( e.keyCode == 27 ) content.text(title);
1945- // e.stopPropagation();
1946- // });
1947- // });
1948- // snext++;
1949- // }
1932+ var curSep = sepMap .get (i );
1933+ if (curSep != null ) {
1934+ var sep = J (" <tr>" ).addClass (" separator" ).append (' <td colspan=" ${colCount + 1 }">' ).appendTo (content );
1935+ var content = sep .find (" td" );
1936+ var title = curSep .title ;
1937+ if ( title != null ) content .text (title );
1938+ var pos = snext ;
1939+ sep .dblclick (function (e ) {
1940+ content .empty ();
1941+ J (" <input>" ).appendTo (content ).focus ().val (title == null ? " " : title ).blur (function (_ ) {
1942+ title = JTHIS .val ();
1943+ JTHIS .remove ();
1944+ content .text (title );
1945+ curSep .title = title ;
1946+ save ();
1947+ }).keypress (function (e ) {
1948+ e .stopPropagation ();
1949+ }).keydown (function (e ) {
1950+ if ( e .keyCode == 13 ) { JTHIS .blur (); e .preventDefault (); } else if ( e .keyCode == 27 ) content .text (title );
1951+ e .stopPropagation ();
1952+ });
1953+ });
1954+ }
19501955 content .append (lines [i ]);
19511956 }
19521957
0 commit comments