Commit 480025b3 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

GlobalLoaders.js берётся из Excel\model\DrawingObjects\

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47874 954022d7-b5bf-4e40-9824-e11837661b57
parent 6842ff91
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
"../Word/Drawing/Graphics.js", "../Word/Drawing/Graphics.js",
"../Word/Drawing/Metafile.js", "../Word/Drawing/Metafile.js",
"../Word/Drawing/AllFonts.js", "../Word/Drawing/AllFonts.js",
"../Word/Drawing/GlobalLoaders.js",
"../Common/FontsFreeType/FontExport.js", "../Common/FontsFreeType/FontExport.js",
"../Excel/offlinedocs/test-workbook9/Editor.js", "../Excel/offlinedocs/test-workbook9/Editor.js",
"../Excel/offlinedocs/empty-workbook.js", "../Excel/offlinedocs/empty-workbook.js",
...@@ -129,6 +128,7 @@ ...@@ -129,6 +128,7 @@
"../Excel/model/DrawingObjects/Graphics.js", "../Excel/model/DrawingObjects/Graphics.js",
"../Excel/model/DrawingObjects/Overlay.js", "../Excel/model/DrawingObjects/Overlay.js",
"../Excel/model/DrawingObjects/GlobalCounters.js", "../Excel/model/DrawingObjects/GlobalCounters.js",
"../Excel/model/DrawingObjects/GlobalLoaders.js",
"../Excel/model/DrawingObjects/DrawingDocument.js", "../Excel/model/DrawingObjects/DrawingDocument.js",
"../Word/apiCommon.js", "../Word/apiCommon.js",
"../Excel/.build/Log/apiCommonExport.js", "../Excel/.build/Log/apiCommonExport.js",
......
...@@ -3256,52 +3256,52 @@ function DrawingObjects() { ...@@ -3256,52 +3256,52 @@ function DrawingObjects() {
if ( !_image.Image ) { if ( !_image.Image ) {
worksheet.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.UplImageUrl, c_oAscError.Level.NoCritical); worksheet.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.UplImageUrl, c_oAscError.Level.NoCritical);
return;
}
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.worksheet = worksheet;
obj.from.col = isOption ? options.cell.col : worksheet.getSelectedColumnIndex();
obj.from.row = isOption ? options.cell.row : worksheet.getSelectedRowIndex();
var headerTop = worksheet.getCellTop(0, 0);
var headerLeft = worksheet.getCellLeft(0, 0);
// Проверяем начальные координаты при вставке
while ( !worksheet.cols[obj.from.col] ) {
worksheet.expandColsOnScroll(true);
} }
worksheet.expandColsOnScroll(true); // для colOff else {
var obj = _this.createDrawingObject();
while ( !worksheet.rows[obj.from.row] ) { obj.id = generateId();
worksheet.expandRowsOnScroll(true); obj.worksheet = worksheet;
obj.from.col = isOption ? options.cell.col : worksheet.getSelectedColumnIndex();
obj.from.row = isOption ? options.cell.row : worksheet.getSelectedRowIndex();
var headerTop = worksheet.getCellTop(0, 0);
var headerLeft = worksheet.getCellLeft(0, 0);
// Проверяем начальные координаты при вставке
while ( !worksheet.cols[obj.from.col] ) {
worksheet.expandColsOnScroll(true);
}
worksheet.expandColsOnScroll(true); // для colOff
while ( !worksheet.rows[obj.from.row] ) {
worksheet.expandRowsOnScroll(true);
}
worksheet.expandRowsOnScroll(true); // для rowOff
calculateObjectMetrics(obj, isOption ? options.width : _image.Image.width, isOption ? options.height : _image.Image.height);
var x = pxToMm(obj.getVisibleLeftOffset() + headerLeft);
var y = pxToMm(obj.getVisibleTopOffset() + headerTop);
var w = pxToMm(obj.getWidthFromTo());
var h = pxToMm(obj.getHeightFromTo());
// CImage
obj.graphicObject = new CImage(obj, _this);
obj.graphicObject.initDefault( x, y, w, h, _image.Image.src );
obj.graphicObject.select(_this.controller);
aObjects.push(obj);
worksheet.autoFilters.drawAutoF(worksheet);
worksheet.cellCommentator.drawCommentCells(false);
_this.showDrawingObjects(false);
// History.Create_NewPoint();
// History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Add, worksheet.model.getId(), null, obj);
_this.lockDrawingObject(obj.id, bPackage ? false : true, bPackage ? false : true);
} }
worksheet.expandRowsOnScroll(true); // для rowOff
calculateObjectMetrics(obj, isOption ? options.width : _image.Image.width, isOption ? options.height : _image.Image.height);
var x = pxToMm(obj.getVisibleLeftOffset() + headerLeft);
var y = pxToMm(obj.getVisibleTopOffset() + headerTop);
var w = pxToMm(obj.getWidthFromTo());
var h = pxToMm(obj.getHeightFromTo());
// CImage
obj.graphicObject = new CImage(obj, _this);
obj.graphicObject.initDefault( x, y, w, h, _image.Image.src );
obj.graphicObject.select(_this.controller);
aObjects.push(obj);
worksheet.autoFilters.drawAutoF(worksheet);
worksheet.cellCommentator.drawCommentCells(false);
_this.showDrawingObjects(false);
// History.Create_NewPoint();
// var copyObject = _this.cloneDrawingObject(obj);
// History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Add, worksheet.model.getId(), null, copyObject);
_this.lockDrawingObject(obj.id, bPackage ? false : true, bPackage ? false : true);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
} }
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Externals.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Externals.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Metafile.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Metafile.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/AllFonts.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/AllFonts.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/GlobalLoaders.js"></script> <!--<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/GlobalLoaders.js"></script>-->
<script type="text/javascript" src="../../../../OfficeWeb/Excel/utils/utils.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/utils/utils.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/ConditionalFormatting.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/model/ConditionalFormatting.js"></script>
...@@ -227,6 +227,7 @@ ...@@ -227,6 +227,7 @@
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/DrawingObjectsController.js"></script> <script src="../../../../OfficeWeb/Excel/model/DrawingObjects/DrawingObjectsController.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/DrawingDocument.js"></script> <script src="../../../../OfficeWeb/Excel/model/DrawingObjects/DrawingDocument.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/States.js"></script> <script src="../../../../OfficeWeb/Excel/model/DrawingObjects/States.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/GlobalLoaders.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/GroupShape.js"></script> <script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/GroupShape.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/Image.js"></script> <script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/Image.js"></script>
......
/** @define {boolean} */ /** @define {boolean} */
var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false; var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false;
(function(document){ (function(document) {
var ImageLoadStatus = { var ImageLoadStatus = {
Loading : 0, Loading : 0,
...@@ -174,8 +174,553 @@ var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false; ...@@ -174,8 +174,553 @@ var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false;
oImage.Image.src = oImage.src; oImage.Image.src = oImage.src;
} }
} }
// exports function CEmbeddedCutFontsLoader() {
this.Api = null;
this.font_infos = [];
this.font_files = [];
this.map_name_cutindex = null;
this.CurrentFindFileParse = -1;
this.Url = "";
this.bIsCutFontsUse = false;
var oThis = this;
this.load_cut_fonts = function()
{
var scriptElem = document.createElement('script');
if (scriptElem.readyState && false)
{
scriptElem.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded')
{
scriptElem.onreadystatechange = null;
setTimeout(oThis._callback_script_load, 0);
}
}
}
scriptElem.onload = scriptElem.onerror = oThis._callback_font_load;
scriptElem.setAttribute('src', this.Url);
scriptElem.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(scriptElem);
this.Api.asyncFontsDocumentStartLoaded();
}
this._callback_font_load = function()
{
if (undefined === embedded_fonts)
return;
oThis.CurrentFindFileParse = 0;
setTimeout(oThis.parse_font, 10);
},
this.parse_font = function()
{
var __font_data_idx = g_fonts_streams.length;
g_fonts_streams[__font_data_idx] = CreateFontData2(embedded_fonts[oThis.CurrentFindFileParse], undefined);
embedded_fonts[oThis.CurrentFindFileParse] = "";
oThis.font_files[oThis.CurrentFindFileParse].SetStreamIndex(__font_data_idx);
oThis.font_files[oThis.CurrentFindFileParse].Status = 0;
oThis.CurrentFindFileParse++;
if (oThis.CurrentFindFileParse >= oThis.font_files.length)
{
oThis.Api.asyncFontsDocumentEndLoaded();
return;
}
setTimeout(oThis.parse_font, 10);
}
this.init_cut_fonts = function(_fonts)
{
this.map_name_cutindex = {};
var _len = _fonts.length;
for (var i = 0; i < _len; i++)
{
var _font = _fonts[i];
var _info = this.map_name_cutindex[_font.Name];
if (_info === undefined)
{
_info = new CFontInfo(_font.Name, "", FONT_TYPE_ADDITIONAL_CUT, -1, -1, -1, -1, -1, -1, -1, -1);
this.map_name_cutindex[_font.Name] = _info;
}
switch (_font.Style)
{
case 0:
_info.indexR = _font.IndexCut;
_info.faceIndexR = 0;
break;
case 1:
_info.indexB = _font.IndexCut;
_info.faceIndexB = 0;
break;
case 2:
_info.indexI = _font.IndexCut;
_info.faceIndexI = 0;
break;
case 3:
_info.indexBI = _font.IndexCut;
_info.faceIndexBI = 0;
break;
default:
break;
}
this.font_files[i] = new CFontFileLoader("embedded_cut" + i);
}
}
}
function CGlobalFontLoader() {
// сначала хотел писать "вытеснение" из этого мапа.
// но тогда нужно хранить base64 строки. Это не круто. По памяти - даже
// выигрыш будет. Не особо то шрифты жмутся lzw или deflate
// поэтому лучше из памяти будем удалять base64 строки
this.fonts_streams = new Array();
// теперь вся информация о всех возможных шрифтах. Они во всех редакторах должны быть одни и те же
this.fontFilesPath = "";
this.fontFiles = window.g_font_files;
this.fontInfos = window.g_font_infos;
this.map_font_index = window.g_map_font_index;
// теперь вся информация о всех встроенных шрифтах. Они должны удаляться при подгрузке нового файла
this.embeddedFilesPath = "";
this.embeddedFontFiles = new Array();
this.embeddedFontInfos = new Array();
// динамическая подгрузка шрифтов
this.ThemeLoader = null;
this.Api = null;
this.fonts_loading = new Array();
this.fonts_loading_after_style = new Array();
this.bIsLoadDocumentFirst = false;
this.currentInfoLoaded = null;
// embedded_cut_fonts
this.embedded_cut_manager = new CEmbeddedCutFontsLoader();
this.put_Api = function(_api)
{
this.Api = _api;
this.embedded_cut_manager.Api = _api;
}
this.LoadEmbeddedFonts = function(url, _fonts)
{
this.embeddedFilesPath = url;
var _count = _fonts.length;
if (0 == _count)
return;
this.embeddedFontInfos = new Array(_count);
var map_files = {};
for (var i = 0; i < _count; i++)
map_files[_fonts[i].id] = _fonts[i].id;
var index = 0;
for (var i in map_files)
{
this.embeddedFontFiles[index] = new CFontFileLoader(map_files[i]);
this.embeddedFontFiles[index].CanUseOriginalFormat = false;
this.embeddedFontFiles[index].IsNeedAddJSToFontPath = false;
map_files[i] = index++;
}
for (var i = 0; i < _count; i++)
{
var lStyle = 0;//_fonts[i].Style;
if (0 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, map_files[_fonts[i].id], 0, -1, -1, -1, -1, -1, -1);
else if (2 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex, -1, -1, -1, -1);
else if (1 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex, -1, -1);
else
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, -1, -1, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex);
}
var _count_infos_ = this.fontInfos.length;
for (var i = 0; i < _count; i++)
{
this.map_font_index[_fonts[i].name] = i + _count_infos_;
this.fontInfos[i + _count_infos_] = this.embeddedFontInfos[i];
}
}
this.SetStandartFonts = function()
{
//В стандартных шрифтах закоментированы те шрифты, которые были добавлены на docs.teamlab.com
var standarts = [];
if(ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY)
{
standarts = ["Arial","Comic Sans MS","Courier New","Georgia","Impact","Lucida Sans Unicode","Tahoma","Times New Roman","Trebuchet MS","Verdana",
"Open Sans","Open Sans Condensed","Droid Sans","Droid Serif","Oswald","PT Sans","Lobster","Lobster Two","Ubuntu","Ubuntu Condensed",
"Arvo","Dancing Script","Pacifico","Cuprum"];
}
else
{
standarts = ["Agency FB","Arabic Transparent","Arial","Arial Black","Arial Narrow","Arvo","Book Antiqua",
"Baskerville Old Face","Bell MT","Bernard MT Condensed","Bodoni MT Black","Bodoni MT Condensed",
"Bradley Hand ITC","Britannic Bold","Broadway","Brush Script MT","Calibri","Calisto MT",
"Cambria","Candara","Castellar","Centaur","Century Schoolbook","Century Gothic",
"Colonna MT","Comic Sans MS","Consolas","Cooper Black","Corbel","Courier New","Cuprum","Curlz MT","Dancing Script",
"Droid Sans Mono","Droid Sans","Droid Serif",
"DejaVu Sans","DejaVu Sans Condensed","DejaVu Sans Light","DejaVu Sans Mono","DejaVu Serif","DejaVu Serif Condensed","Dotum","DotumChe",
"Elephant","Engravers MT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC",
"Felix Titling","Forte","Franklin Gothic Book","Franklin Gothic Demi","Franklin Gothic Demi Cond",
"Franklin Gothic Heavy","Franklin Gothic Medium","Franklin Gothic Medium Cond",
"Freestyle Script","French Script MT","Footlight MT Light","Garamond","Georgia",
"Gigi","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold",
"Gill Sans Ultra Bold Condensed","Gloucester MT Extra Condensed","Goudy Stout",
"Gulim","GulimChe",
"Harrington","Impact","Imprint MT Shadow","Jokerman","Lobster","Lobster Two","Lucida Sans Unicode","Microsoft Sans Serif","Monotype Corsiva",
"MS Gothic",
"Niagara Engraved","Niagara Solid","OCR A Extended","Old English Text MT","Onyx","Open Sans","Open Sans Condensed","Oswald",
"Pacifico","Palatino Linotype","Papyrus","Perpetua","Playbill","Pristina","PT Sans","Ravie","Rockwell",
"Segoe UI","Showcard Gothic",
"SimHei",
"Snap ITC","Symbol","Tahoma","Times New Roman","Trebuchet MS","Ubuntu","Ubuntu Condensed",
"Verdana","Viner Hand ITC","Vladimir Script","Webdings","Wide Latin","Wingdings","Wingdings 2","Wingdings 3"];
}
var _count = standarts.length;
var _infos = this.fontInfos;
var _map = this.map_font_index;
for (var i = 0; i < _count; i++)
{
_infos[_map[standarts[i]]].Type = FONT_TYPE_STANDART;
}
}
this.CheckFontsPaste = function(_fonts)
{
for (var i in _fonts)
{
var info_ind = this.map_font_index[_fonts[i]];
if (info_ind != undefined)
{
this.fonts_loading[this.fonts_loading.length] = this.fontInfos[info_ind];
}
}
this.Api.asyncFontsDocumentStartLoaded();
this._LoadFonts();
}
this.AddLoadFonts = function(info, need_styles)
{
this.fonts_loading[this.fonts_loading.length] = info;
this.fonts_loading[this.fonts_loading.length - 1].NeedStyles = (need_styles == undefined) ? 0x0F : need_styles;
}
this.LoadDocumentFonts = function(_fonts, is_default)
{
if (this.embedded_cut_manager.bIsCutFontsUse)
return this.embedded_cut_manager.load_cut_fonts();
// в конце метода нужно отдать список шрифтов
var gui_fonts = new Array();
var gui_count = 0;
for (var i = 0; i < this.fontInfos.length; i++)
{
var info = this.fontInfos[i];
if (FONT_TYPE_STANDART == info.Type)
{
var __font = new CFont(info.Name, "", info.Type, info.Thumbnail);
gui_fonts[gui_count++] = __font;
}
}
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
if (_fonts[i].Type != FONT_TYPE_EMBEDDED)
{
var info = this.fontInfos[this.map_font_index[_fonts[i].name]];
this.AddLoadFonts(info, _fonts[i].NeedStyles);
if (info.Type == FONT_TYPE_ADDITIONAL)
{
var __font = new CFont(info.Name, "", info.Type, info.Thumbnail);
gui_fonts[gui_count++] = __font;
}
}
else
{
var ind = -1;
for (var j = 0; j < this.embeddedFontInfos.length; j++)
{
if (this.embeddedFontInfos[j].Name == _fonts[i].name)
{
this.AddLoadFonts(this.embeddedFontInfos[j], 0);
break;
}
}
}
}
this.Api.sync_InitEditorFonts(gui_fonts);
// но только если редактор!!!
if (this.Api.IsNeedDefaultFonts())
{
// теперь добавим шрифты, без которых редактор как без рук (спецсимволы + дефолтовые стили документа)
this.AddLoadFonts(this.fontInfos[this.map_font_index["Arial"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Symbol"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Wingdings"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Wingdings 3"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Courier New"]], 0x0F);
//if (is_default === true)
{
this.AddLoadFonts(this.fontInfos[this.map_font_index["Times New Roman"]], 0x0F);
}
}
this.Api.asyncFontsDocumentStartLoaded();
this.bIsLoadDocumentFirst = true;
this._LoadFonts();
}
this.LoadDocumentFonts2 = function(_fonts)
{
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
var info = this.fontInfos[this.map_font_index[_fonts[i].name]];
this.AddLoadFonts(info, 0x0F);
}
if (null == this.ThemeLoader)
this.Api.asyncFontsDocumentStartLoaded();
else
this.ThemeLoader.asyncFontsStartLoaded();
this._LoadFonts();
}
var oThis = this;
this._LoadFonts = function()
{
if (0 == this.fonts_loading.length)
{
if (null == this.ThemeLoader)
this.Api.asyncFontsDocumentEndLoaded();
else
this.ThemeLoader.asyncFontsEndLoaded();
if (this.bIsLoadDocumentFirst === true)
{
var _count = this.fonts_loading_after_style.length;
for (var i = 0; i < _count; i++)
{
var _info = this.fonts_loading_after_style[i];
_info.NeedStyles = 0x0F;
_info.CheckFontLoadStyles(this);
}
this.fonts_loading_after_style.splice(0, this.fonts_loading_after_style.length);
this.bIsLoadDocumentFirst = false;
}
return;
}
var fontinfo = this.fonts_loading[0];
var IsNeed = fontinfo.CheckFontLoadStyles(this);
if (IsNeed)
{
setTimeout(oThis._check_loaded, 50);
//setTimeout(__global_check_load_fonts, 50);
}
else
{
if (this.bIsLoadDocumentFirst === true)
{
this.Api.OpenDocumentProgress.CurrentFont++;
this.Api.SendOpenProgress();
}
this.fonts_loading_after_style[this.fonts_loading_after_style.length] = this.fonts_loading[0];
this.fonts_loading.shift();
this._LoadFonts();
}
}
this._check_loaded = function()
{
var IsNeed = false;
if (0 == oThis.fonts_loading.length)
{
// значит асинхронно удалилось
oThis._LoadFonts();
return;
}
var current = oThis.fonts_loading[0];
var IsNeed = current.CheckFontLoadStyles(oThis);
if (true === IsNeed)
{
setTimeout(oThis._check_loaded, 50);
}
else
{
if (oThis.bIsLoadDocumentFirst === true)
{
oThis.Api.OpenDocumentProgress.CurrentFont++;
oThis.Api.SendOpenProgress();
}
oThis.fonts_loading_after_style[oThis.fonts_loading_after_style.length] = oThis.fonts_loading[0];
oThis.fonts_loading.shift();
oThis._LoadFonts();
}
}
this.LoadFont = function(fontinfo)
{
this.currentInfoLoaded = fontinfo;
this.currentInfoLoaded = fontinfo;
this.currentInfoLoaded.NeedStyles = 15; // все стили
var IsNeed = this.currentInfoLoaded.CheckFontLoadStyles(this);
if (IsNeed)
{
this.Api.asyncFontStartLoaded();
setTimeout(this.check_loaded, 20);
return true;
}
else
{
this.currentInfoLoaded = null;
return false;
}
}
this.check_loaded = function()
{
var current = oThis.currentInfoLoaded;
if (null == current)
return;
var IsNeed = current.CheckFontLoadStyles(oThis);
if (IsNeed)
{
setTimeout(oThis.check_loaded, 50);
}
else
{
oThis.Api.asyncFontEndLoaded(oThis.currentInfoLoaded);
oThis.currentInfoLoaded = null;
}
}
this.LoadFontsFromServer = function(_fonts)
{
var _count = _fonts.length;
for (var i = 0; i < _count; i++)
{
var _info_ind = this.map_font_index[_fonts[i]];
if (undefined !== _info_ind)
{
var _info = this.fontInfos[_info_ind];
_info.LoadFontsFromServer(this);
}
}
}
}
CGlobalFontLoader.prototype.SetStreamIndexEmb = function(font_index, stream_index) {
this.embeddedFontFiles[font_index].SetStreamIndex(stream_index);
}
function CGlobalScriptLoader() {
this.Status = -1; // -1 - notloaded, 0 - loaded, 1 - error, 2 - loading, 3 - imageloading
this.callback = null;
this.oCallBackThis = null;
var oThis = this;
this.CheckLoaded = function()
{
return (0 == oThis.Status || 1 == oThis.Status);
}
this.LoadScriptAsync = function(url, _callback, _callback_this)
{
this.callback = _callback;
this.oCallBackThis = _callback_this;
if (-1 != this.Status)
return true;
this.Status = 2;
var scriptElem = document.createElement('script');
if (scriptElem.readyState && false)
{
scriptElem.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded')
{
scriptElem.onreadystatechange = null;
setTimeout(oThis._callback_script_load, 0);
}
}
}
scriptElem.onload = scriptElem.onerror = oThis._callback_script_load;
scriptElem.setAttribute('src', url);
scriptElem.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(scriptElem);
return false;
}
this._callback_script_load = function()
{
if (oThis.Status != 3)
oThis.Status = 1;
if (null != oThis.callback)
{
oThis.callback(oThis.oCallBackThis);
oThis.callback = null;
}
}
}
// exports
window.g_font_loader = new CGlobalFontLoader();
window.g_image_loader = new CGlobalImageLoader(); window.g_image_loader = new CGlobalImageLoader();
window.g_script_loader = new CGlobalScriptLoader();
window.g_script_loader2 = new CGlobalScriptLoader();
window.g_flow_anchor = new Image();
window.g_flow_anchor.asc_complete = false;
window.g_flow_anchor.onload = function(){
window.g_flow_anchor.asc_complete = true;
};
window.g_flow_anchor.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAARCAYAAADUryzEAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB90FEQkoAWe6v2gAAABoSURBVDjLzZRBDsAgCAQd0v9/eXpqokaxrWlSjgLL7kJELTsRWRIQ8BUAoIpKBhJlM8g8uCarfMbgJwCrVWX+HE8MGw1rJKyaRzVRP96R0jONFcVVrjmku2bWMrY9mJ5yz2YGzu5/cAJM80IX4Fh6ugAAAABJRU5ErkJggg==";
window['CGlobalFontLoader'] = CGlobalFontLoader;
CGlobalFontLoader.prototype['SetStreamIndexEmb'] = CGlobalFontLoader.prototype.SetStreamIndexEmb;
})(window.document); })(window.document);
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment