当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Factory.get函数代码示例

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


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

示例1: createDragHelper

    function createDragHelper(handle) {
      let startRect;
      const DragHelper = Factory.get('DragHelper');

      return new DragHelper(id, {
        document: containerElm.ownerDocument,
        handle: id + '-' + handle.name,

        start () {
          startRect = currentRect;
        },

        drag (e) {
          moveRect(handle, startRect, e.deltaX, e.deltaY);
        }
      });
    }
开发者ID:abstask,项目名称:tinymce,代码行数:17,代码来源:CropRect.ts

示例2: function

  return function (evt) {
    const Throbber = Factory.get('Throbber');
    const rootControl = evt.control.rootControl;
    const throbber = new Throbber(rootControl.getEl());
    const file = evt.control.value();
    const blobUri = URL.createObjectURL(file);

    const uploader = Uploader({
      url: Settings.getUploadUrl(editor),
      basePath: Settings.getUploadBasePath(editor),
      credentials: Settings.getUploadCredentials(editor),
      handler: Settings.getUploadHandler(editor)
    });

    const finalize = function () {
      throbber.hide();
      URL.revokeObjectURL(blobUri);
    };

    throbber.show();

    return Utils.blobToDataUri(file).then(function (dataUrl) {
      const blobInfo = editor.editorUpload.blobCache.create({
        blob: file,
        blobUri,
        name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null, // strip extension
        base64: dataUrl.split(',')[1]
      });
      return uploader.upload(blobInfo).then(function (url) {
        const src = rootControl.find('#src');
        src.value(url);
        rootControl.find('tabpanel')[0].activateTab(0); // switch to General tab
        src.fire('change'); // this will invoke onSrcChange (and any other handlers, if any).
        finalize();
        return url;
      });
    }).catch(function (err) {
      editor.windowManager.alert(err);
      finalize();
    });
  };
开发者ID:abstask,项目名称:tinymce,代码行数:41,代码来源:UploadTab.ts

示例3: function

 const teardown = function () {
   I18n.rtl = false;
   I18n.setCode('en');
   Factory.get('Control').rtl = false;
 };
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:EditorRtlTest.ts

示例4: function

const create = function (settings) {
  const Control = Factory.get('Control');
  const ImagePanel = Control.extend({
    Defaults: {
      classes: 'imagepanel'
    },

    selection (rect) {
      if (arguments.length) {
        this.state.set('rect', rect);
        return this;
      }

      return this.state.get('rect');
    },

    imageSize () {
      const viewRect = this.state.get('viewRect');

      return {
        w: viewRect.w,
        h: viewRect.h
      };
    },

    toggleCropRect (state) {
      this.state.set('cropEnabled', state);
    },

    imageSrc (url) {
      const self = this, img = new Image();

      img.src = url;

      LoadImage.loadImage(img).then(function () {
        let rect, $img;
        const lastRect = self.state.get('viewRect');

        $img = self.$el.find('img');
        if ($img[0]) {
          $img.replaceWith(img);
        } else {
          const bg = document.createElement('div');
          bg.className = 'mce-imagepanel-bg';
          self.getEl().appendChild(bg);
          self.getEl().appendChild(img);
        }

        rect = { x: 0, y: 0, w: img.naturalWidth, h: img.naturalHeight };
        self.state.set('viewRect', rect);
        self.state.set('rect', Rect.inflate(rect, -20, -20));

        if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) {
          self.zoomFit();
        }

        self.repaintImage();
        self.fire('load');
      });
    },

    zoom (value) {
      if (arguments.length) {
        this.state.set('zoom', value);
        return this;
      }

      return this.state.get('zoom');
    },

    postRender () {
      this.imageSrc(this.settings.imageSrc);
      return this._super();
    },

    zoomFit () {
      const self = this;
      let $img, pw, ph, w, h, zoom, padding;

      padding = 10;
      $img = self.$el.find('img');
      pw = self.getEl().clientWidth;
      ph = self.getEl().clientHeight;
      w = $img[0].naturalWidth;
      h = $img[0].naturalHeight;
      zoom = Math.min((pw - padding) / w, (ph - padding) / h);

      if (zoom >= 1) {
        zoom = 1;
      }

      self.zoom(zoom);
    },

    repaintImage () {
      let x, y, w, h, pw, ph, $img, $bg, zoom, rect, elm;

      elm = this.getEl();
      zoom = this.zoom();
      rect = this.state.get('rect');
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:ImagePanel.ts


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