示例#1
0
 public HCheckEdit(string dataName, bool value, HTone frameStyle, HTone markStyle, params HStyle[] pseudoClasses) :
   base("HCheckEdit", dataName)
 {
   this.value = value;
   this.frameStyle = frameStyle;
   this.markStyle = markStyle;
   this.pseudoClasses = pseudoClasses;
 }
示例#2
0
    public static HCheckEdit CheckEdit(string dataName, bool value, params HStyle[] pseudoStyles)
    {
      HTone frameStyle = new HTone().Display("inline-block").Width("10px").Height("10px")
        .Border("1px", "solid", "#9a9ca0", "2px").CssAttribute("margin-top", "1px")
        .Background("#fefefe");

      HTone markStyle = new HTone().FontFamily("sept").FontSize("16px").Content(@"\2714")
        .CssAttribute("line-height", "10px").MarginLeft(-2);

      return new HCheckEdit(dataName, value, frameStyle, markStyle, pseudoStyles);
    }
示例#3
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      string checkClassName = string.Format("{0}_check", Name);
      string frameClassName = string.Format("{0}_frame", Name);

      HTone innerStyle = new HTone().Display("none");
      HtmlHlp.AddClassToCss(css, checkClassName, innerStyle.CssExtensions);

      HtmlHlp.AddClassToCss(css, frameClassName, frameStyle.CssExtensions);

      HtmlHlp.AddExtensionsToCss(css,
        markStyle.CssExtensions,
        ".{0} input[type=checkbox]:checked ~ .{1}::before ",
        cssClassName, frameClassName
      );

      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
        defaults.Display("inline-block");
        defaults.OnClick(string.Format(
          "e.preventDefault(); $('.{0}').is(':checked') ? $('.{0}').prop('checked', false) : $('.{0}').prop('checked', true);",
          checkClassName)
        );
      }

      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);
      foreach (HStyle pseudo in pseudoClasses)
        HtmlHlp.AddStyleToCss(css, cssClassName, pseudo);

      List<object> checkElements = new List<object>();
      checkElements.Add(h.@class(checkClassName));
      checkElements.Add(h.type("checkbox"));
      checkElements.Add(h.data("name", Name));
      checkElements.Add(h.data("id", checkClassName));
      if (value)
        checkElements.Add(h.@checked());

      return h.Div(HtmlHlp.ContentForHElement(this, cssClassName,
        h.Input(checkElements.ToArray()),
        h.Div(h.@class(frameClassName))
      ));
    }
示例#4
0
 public static HRowStyle Hover(this HRowStyle gridStyle, HTone rowHoverStyle)
 {
   gridStyle.WithExtension("rowHoverStyle", rowHoverStyle);
   return gridStyle;
 }
示例#5
0
 public static HRowStyle Even(this HRowStyle gridStyle, HTone rowEvenStyle)
 {
   gridStyle.WithExtension("rowEvenStyle", rowEvenStyle);
   return gridStyle;
 }
示例#6
0
 public static HDropStyle AnyItem(this HDropStyle dropStyle, HTone anyItemStyle)
 {
   dropStyle.WithExtension("anyItemStyle", anyItemStyle);
   return dropStyle;
 }
示例#7
0
 public static HDropStyle SelectedItem(this HDropStyle dropStyle, HTone selectedItemStyle)
 {
   dropStyle.WithExtension("selectedItemStyle", selectedItemStyle);
   return dropStyle;
 }
示例#8
0
 public static HDropStyle RootWhenDropped(this HDropStyle dropStyle, HTone rootWhenDroppedStyle)
 {
   dropStyle.WithExtension("rootWhenDroppedStyle", rootWhenDroppedStyle);
   return dropStyle;
 }
示例#9
0
 public static HDropStyle DropList(this HDropStyle dropStyle, HTone dropListStyle)
 {
   dropStyle.WithExtension("dropListStyle", dropListStyle);
   return dropStyle;
 }
示例#10
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      string rootCssName = string.Format("{0}_root", cssClassName);
      string dropListCssName = string.Format("{0}_list", cssClassName);

      this.CssAttribute("position", "relative");
      this.CssAttribute("display", "inline-block");
      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);

      HTone dropListStyle = dropStyle.GetExtended<HTone>("dropListStyle") ?? new HTone();
      dropListStyle.CssAttribute("position", "absolute");
      dropListStyle.Display("none");
      HtmlHlp.AddClassToCss(css, dropListCssName, dropListStyle.CssExtensions);

      HTone hoverDropListStyle = new HTone().Display("inline-block");
      HtmlHlp.AddExtensionsToCss(css, hoverDropListStyle.CssExtensions,
        ".{0}:hover .{1}", cssClassName, dropListCssName);

      HTone rootWhenDropped = dropStyle.GetExtended<HTone>("rootWhenDroppedStyle");
      if (rootWhenDropped != null)
      {
        HtmlHlp.AddExtensionsToCss(css, rootWhenDropped.CssExtensions,
          ".{0}:hover", rootCssName);
      }

      string anyItemCssName = string.Format("{0}_any_item", cssClassName);
      HTone anyItemStyle = dropStyle.GetExtended<HTone>("anyItemStyle");
      if (anyItemStyle != null)
        HtmlHlp.AddClassToCss(css, anyItemCssName, anyItemStyle.CssExtensions);

      HTone selectedItemStyle = dropStyle.GetExtended<HTone>("selectedItemStyle");
      if (selectedItemStyle != null)
        HtmlHlp.AddExtensionsToCss(css, selectedItemStyle.CssExtensions, ".{0}:hover", anyItemCssName);

      string separatorCssName = string.Format("{0}_separator", cssClassName);
      HTone separatorStyle = dropStyle.GetExtended<HTone>("separatorStyle");
      if (separatorStyle != null)
        HtmlHlp.AddClassToCss(css, separatorCssName, separatorStyle.CssExtensions);

      List<object> content = new List<object>(listControls.Length + 1);
      content.Add(h.@class(dropListCssName));
      int index = 0;
      foreach (IHtmlControl child in listControls)
      {
        index++;
        ((IEditExtension)child).Display("block");
        ((IEditExtension)child).ExtraClassNames(child is HSeparator ? separatorCssName : anyItemCssName);
        content.Add(child.ToHtml(string.Format("{0}_{1}", cssClassName, index), css));
      }

      return h.Div(h.@class(cssClassName),
        rootControl.ToHtml(rootCssName, css),
        h.Div(content.ToArray())
      );


      //string blockCssName = string.Format("{0}_block", cssClassName);
      //string rootCssName = string.Format("{0}_root", cssClassName);

      //HtmlHlp.AddClassToCss(css, blockCssName,
      //  new CssExtensionAttribute[] { 
      //    new CssExtensionAttribute("position", "relative"),
      //    new CssExtensionAttribute("display", "inline-block")
      //  }
      //);

      //HStyle blockFocusStyle = new HStyle(string.Format(".{0}:focus", blockCssName)).
      //  CssAttribute("outline", "none").Background(Color.LightPink);
      //HtmlHlp.AddStyleToCss(css, "", blockFocusStyle);

      //this.CssAttribute("position", "absolute");
      //this.Display("none");

      //HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);

      //HStyle dropStyle = new HStyle(string.Format(".{0}:{1} .{2}",
      //  blockCssName, dropByHover ? "hover" : "focus", cssClassName))
      //  .Display("inline-block");
      //  //.CssAttribute("outline", "none");
      //HtmlHlp.AddStyleToCss(css, "", dropStyle);

      //List<object> content = new List<object>(listControls.Length + 1);
      //content.Add(h.@class(cssClassName, css));
      //int index = 0;
      //foreach (IHtmlControl child in listControls)
      //{
      //  index++;
      //  ((IEditExtension)child).Display("block");
      //  content.Add(child.ToHtml(string.Format("{0}_{1}", cssClassName, index), css));
      //}

      //return h.Div(h.@class(blockCssName), new HAttribute("tabindex", "1"),
      //  rootControl.ToHtml(rootCssName, css),
      //  h.Div(content.ToArray())
      //);
    }