PHP Classes

File: public/js/tinymce/src/plugins/media/src/main/js/core/Service.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/plugins/media/src/main/js/core/Service.js   Download  
File: public/js/tinymce/src/plugins/media/src/main/js/core/Service.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: GoLavaCMS
Publish content on Web pages with SEO support
Author: By
Last change:
Date: 6 years ago
Size: 1,766 bytes
 

Contents

Class file image Download
/** * Service.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ define( 'tinymce.plugins.media.core.Service', [ 'tinymce.core.util.Promise', 'tinymce.plugins.media.api.Settings', 'tinymce.plugins.media.core.DataToHtml' ], function (Promise, Settings, DataToHtml) { var cache = {}; var embedPromise = function (data, dataToHtml, handler) { return new Promise(function (res, rej) { var wrappedResolve = function (response) { if (response.html) { cache[data.source1] = response; } return res({ url: data.source1, html: response.html ? response.html : dataToHtml(data) }); }; if (cache[data.source1]) { wrappedResolve(cache[data.source1]); } else { handler({ url: data.source1 }, wrappedResolve, rej); } }); }; var defaultPromise = function (data, dataToHtml) { return new Promise(function (res) { res({ html: dataToHtml(data), url: data.source1 }); }); }; var loadedData = function (editor) { return function (data) { return DataToHtml.dataToHtml(editor, data); }; }; var getEmbedHtml = function (editor, data) { var embedHandler = Settings.getUrlResolver(editor); return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); }; var isCached = function (url) { return cache.hasOwnProperty(url); }; return { getEmbedHtml: getEmbedHtml, isCached: isCached }; } );