當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DOM.hasClass方法代碼示例

本文整理匯總了TypeScript中tinymce/core/dom/DOMUtils.DOM.hasClass方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DOM.hasClass方法的具體用法?TypeScript DOM.hasClass怎麽用?TypeScript DOM.hasClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tinymce/core/dom/DOMUtils.DOM的用法示例。


在下文中一共展示了DOM.hasClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: get

  },

  get (id) {
    return document.getElementById(id);
  },

  addClass (elm, cls) {
    return DOMUtils.DOM.addClass(elm, cls);
  },

  removeClass (elm, cls) {
    return DOMUtils.DOM.removeClass(elm, cls);
  },

  hasClass (elm, cls) {
    return DOMUtils.DOM.hasClass(elm, cls);
  },

  toggleClass (elm, cls, state) {
    return DOMUtils.DOM.toggleClass(elm, cls, state);
  },

  css (elm, name, value?) {
    return DOMUtils.DOM.setStyle(elm, name, value);
  },

  getRuntimeStyle (elm, name) {
    return DOMUtils.DOM.getStyle(elm, name, true);
  },

  on (target, name, callback, scope?) {
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:31,代碼來源:DomUtils.ts

示例2: function

  suite.test('Fullscreen class on html and body tag', function (editor) {
    const bodyTag = document.body;
    const htmlTag = document.documentElement;
    let lastEventArgs;

    editor.on('FullscreenStateChanged', function (e) {
      lastEventArgs = e;
    });

    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(bodyTag, 'mce-fullscreen'),
      false,
      'Body tag should not have "mce-fullscreen" class before fullscreen command'
    );
    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(htmlTag, 'mce-fullscreen'),
      false,
      'Html tag should not have "mce-fullscreen" class before fullscreen command'
    );

    editor.execCommand('mceFullScreen');

    LegacyUnit.equal(editor.plugins.fullscreen.isFullscreen(), true, 'Should be true');
    LegacyUnit.equal(lastEventArgs.state, true, 'Should be true');

    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(bodyTag, 'mce-fullscreen'),
      true,
      'Body tag should have "mce-fullscreen" class after fullscreen command'
    );
    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(htmlTag, 'mce-fullscreen'),
      true,
      'Html tag should have "mce-fullscreen" class after fullscreen command'
    );

    editor.execCommand('mceLink', true);

    const windows = editor.windowManager.getWindows();
    const linkWindow = windows[0];

    LegacyUnit.equal(typeof linkWindow, 'object', 'Link window is an object');

    linkWindow.close();

    LegacyUnit.equal(windows.length, 0, 'No windows exist');

    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(bodyTag, 'mce-fullscreen'),
      true,
      'Body tag should still have "mce-fullscreen" class after window is closed'
    );
    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(htmlTag, 'mce-fullscreen'),
      true,
      'Html tag should still have "mce-fullscreen" class after window is closed'
    );

    editor.execCommand('mceFullScreen');

    LegacyUnit.equal(editor.plugins.fullscreen.isFullscreen(), false, 'Should be false');
    LegacyUnit.equal(lastEventArgs.state, false, 'Should be false');
    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(bodyTag, 'mce-fullscreen'),
      false,
      'Body tag should have "mce-fullscreen" class after fullscreen command'
    );
    LegacyUnit.equal(
      DOMUtils.DOM.hasClass(htmlTag, 'mce-fullscreen'),
      false,
      'Html tag should have "mce-fullscreen" class after fullscreen command'
    );
  });
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:73,代碼來源:FullScreenPluginTest.ts


注:本文中的tinymce/core/dom/DOMUtils.DOM.hasClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。