• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript modal.Modal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中wed/gui/modal.Modal的典型用法代码示例。如果您正苦于以下问题:TypeScript Modal类的具体用法?TypeScript Modal怎么用?TypeScript Modal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Modal类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe("Modal", () => {
  let wedroot: HTMLElement;
  let modal: Modal;

  function clearWedRoot(): void {
    // tslint:disable-next-line:no-inner-html
    wedroot.innerHTML = "";
  }

  before(() => {
    wedroot = makeWedRoot(document);
    document.body.appendChild(wedroot);
  });

  after(() => {
    document.body.removeChild(wedroot);
  });

  beforeEach(() => {
    modal = new Modal();
  });

  describe("setTitle", () => {
    it("sets the title", () => {
      let $title = modal.getTopLevel().find(".modal-header>h3");
      assert.equal($title.text(), "Untitled", "initial title");
      modal.setTitle($("<b>foo</b>"));
      $title = modal.getTopLevel().find(".modal-header>h3");
      assert.equal($title[0].innerHTML, "<b>foo</b>", "new title");
    });
  });

  describe("setBody", () => {
    it("sets the body", () => {
      const body = modal.getTopLevel().find(".modal-body")[0];
      assert.equal(body.innerHTML.trim(), "<p>No body.</p>", "initial body");
      modal.setBody($("<p>A body.</p>"));
      assert.equal(body.innerHTML, "<p>A body.</p>", "new body");
    });
  });

  describe("setFooter", () => {
    it("sets the footer", () => {
      const footer = modal.getTopLevel().find(".modal-footer")[0];
      assert.equal(footer.innerHTML.trim(), "", "initial footer");
      modal.setFooter($("<p>A footer.</p>"));
      assert.equal(footer.innerHTML, "<p>A footer.</p>", "new footer");
    });
  });

  describe("addButton", () => {
    it("adds a button", () => {
      const footer = modal.getTopLevel().find(".modal-footer")[0];
      assert.equal(footer.innerHTML.trim(), "", "initial footer");
      const $button = modal.addButton("test");
      assert.isTrue($button.closest(footer).length > 0,
                    "button is present in footer");
      assert.equal($button.text(), "test");
      assert.isFalse($button.hasClass("btn-primary"));
    });

    it("adds a primary button", () => {
      const footer = modal.getTopLevel().find(".modal-footer")[0];
      assert.equal(footer.innerHTML.trim(), "", "initial footer");
      const $button = modal.addButton("test", true);
      assert.isTrue($button.closest(footer).length > 0,
                    "button is present in footer");
      assert.equal($button.text(), "test");
      assert.isTrue($button.hasClass("btn-primary"));
    });
  });

  describe("getPrimary", () => {
    it("returns an empty set if there is no primary", () => {
      assert.equal(modal.getPrimary()[0], undefined);
    });

    it("returns the primary", () => {
      const $button = modal.addButton("test", true);
      assert.equal(modal.getPrimary()[0], $button[0]);
    });
  });

  function makeAddXYTest(first: string, second: string): void {
    describe(`add${first}${second}`, () => {
      it(`adds ${first} and ${second} button, ${first} is primary`, () => {
        const footer = modal.getTopLevel().find(".modal-footer")[0];
        assert.equal(footer.innerHTML.trim(), "", "initial footer");
        // tslint:disable-next-line:no-any
        const buttons = (modal as any)[`add${first}${second}`].call(modal);
        assert.isTrue(buttons[0].closest(footer).length > 0,
                      "button 0 is present in footer");
        assert.isTrue(buttons[1].closest(footer).length > 0,
                      "button 1 is present in footer");

        assert.equal(buttons[0].text(), first, "button 0 name");
        assert.equal(buttons[1].text(), second, "button 1 name");

        assert.isTrue(buttons[0].hasClass("btn-primary"),
                      "button 0 is primary");
//.........这里部分代码省略.........
开发者ID:lddubeau,项目名称:wed,代码行数:101,代码来源:modal-test.ts


示例2: it

 it("sets the title", () => {
   let $title = modal.getTopLevel().find(".modal-header>h3");
   assert.equal($title.text(), "Untitled", "initial title");
   modal.setTitle($("<b>foo</b>"));
   $title = modal.getTopLevel().find(".modal-header>h3");
   assert.equal($title[0].innerHTML, "<b>foo</b>", "new title");
 });
开发者ID:lddubeau,项目名称:wed,代码行数:7,代码来源:modal-test.ts


示例3: click

    it("cleans event handlers properly", (done) => {
      function click(): void {
        modal.getPrimary().click();
      }
      window.setTimeout(click, 1);

      let first = 0;
      modal.modal(() => {
        first++;
      });

      window.setTimeout(click, 1);
      let second = 0;
      modal.modal(() => {
        second++;
        assert.equal(first, 1, "first handler count");
        assert.equal(second, 1, "second handler count");
        done();
      });
    });
开发者ID:lddubeau,项目名称:wed,代码行数:20,代码来源:modal-test.ts



注:本文中的wed/gui/modal.Modal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript toolbar.Toolbar类代码示例发布时间:2022-05-25
下一篇:
TypeScript gui-selector.GUISelector类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap