|
|
|
@ -47,6 +47,16 @@ const menuButton = { |
|
|
|
"rightclickmenu": null, |
|
|
|
"submenuhide": null, |
|
|
|
focus: function($obj, value){ |
|
|
|
if($obj.attr("id")=="luckysheet-icon-font-family-menuButton"){ |
|
|
|
if (isdatatypemulti(value)["num"]) { |
|
|
|
let _locale = locale(); |
|
|
|
const locale_fontarray = _locale.fontarray; |
|
|
|
value = locale_fontarray[parseInt(value)]; |
|
|
|
if(value==null){ |
|
|
|
value = this.defualtFont[itemvalue]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$obj.find(".luckysheet-cols-menuitem").find("span.icon").html(""); |
|
|
|
if(value == null){ |
|
|
|
$obj.find(".luckysheet-cols-menuitem").eq(0).find("span.icon").html('<i class="fa fa-check luckysheet-mousedown-cancel"></i>'); |
|
|
|
@ -468,19 +478,19 @@ const menuButton = { |
|
|
|
let menuButtonId = $(this).attr("id")+"-menuButton"; |
|
|
|
let $menuButton = $("#"+menuButtonId); |
|
|
|
if($menuButton.length == 0){ |
|
|
|
const locale_fontarray = locale().fontarray; |
|
|
|
let itemdata = []; |
|
|
|
|
|
|
|
for(let a=0;a<locale_fontarray.length;a++){ |
|
|
|
let fItem = locale_fontarray[a]; |
|
|
|
let ret = {}; |
|
|
|
ret.value = a; |
|
|
|
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fItem+"'>"+fItem+"</span>"; |
|
|
|
ret.example = ""; |
|
|
|
itemdata.push(ret); |
|
|
|
} |
|
|
|
// const locale_fontarray = locale().fontarray;
|
|
|
|
// let itemdata = [];
|
|
|
|
|
|
|
|
let itemset = _this.createButtonMenu(itemdata); |
|
|
|
// for(let a=0;a<locale_fontarray.length;a++){
|
|
|
|
// let fItem = locale_fontarray[a];
|
|
|
|
// let ret = {};
|
|
|
|
// ret.value = a;
|
|
|
|
// ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fItem+"'>"+fItem+"</span>";
|
|
|
|
// ret.example = "";
|
|
|
|
// itemdata.push(ret);
|
|
|
|
// }
|
|
|
|
|
|
|
|
let itemset = _this.createButtonMenu(_this.fontSelectList); |
|
|
|
|
|
|
|
let menu = replaceHtml(_this.menu, {"id": "font-family", "item": itemset, "subclass": "", "sub": ""}); |
|
|
|
|
|
|
|
@ -488,7 +498,7 @@ const menuButton = { |
|
|
|
$menuButton = $("#"+menuButtonId).width(200); |
|
|
|
_this.focus($menuButton); |
|
|
|
|
|
|
|
$menuButton.find(".luckysheet-cols-menuitem").click(function(){ |
|
|
|
$menuButton.on("click", ".luckysheet-cols-menuitem", function(){ |
|
|
|
$menuButton.hide(); |
|
|
|
luckysheetContainerFocus(); |
|
|
|
|
|
|
|
@ -3317,10 +3327,20 @@ const menuButton = { |
|
|
|
if(isdatatypemulti(foucsStatus)["num"]){ |
|
|
|
itemvalue = parseInt(foucsStatus); |
|
|
|
itemname = locale_fontarray[itemvalue]; |
|
|
|
|
|
|
|
if(itemname==null){ |
|
|
|
itemvalue = _this.defualtFont[itemvalue]; |
|
|
|
itemname = itemvalue; |
|
|
|
if(itemvalue!=null){ |
|
|
|
_this.addFontTolist(itemvalue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
itemvalue = locale_fontjson[foucsStatus]; |
|
|
|
itemname = locale_fontarray[itemvalue]; |
|
|
|
itemvalue = foucsStatus; |
|
|
|
itemname = foucsStatus; |
|
|
|
|
|
|
|
_this.addFontTolist(itemvalue); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -4320,6 +4340,75 @@ const menuButton = { |
|
|
|
} |
|
|
|
|
|
|
|
return style; |
|
|
|
}, |
|
|
|
fontSelectList:[], |
|
|
|
defualtFont:["Times New Roman","Arial","Tahoma","Verdana","微软雅黑","宋体","黑体","楷体","仿宋","新宋体","华文新魏","华文行楷","华文隶书"], |
|
|
|
addFontTolist:function(fontName) { |
|
|
|
let isNone = true; |
|
|
|
for(let a=0;a<this.fontSelectList.length;a++){ |
|
|
|
let fItem = this.fontSelectList[a]; |
|
|
|
if(fItem.value == fontName){ |
|
|
|
isNone = false; |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(isNone){ |
|
|
|
let ret = {}; |
|
|
|
ret.value = fontName; |
|
|
|
ret.index = this.fontSelectList.length; |
|
|
|
ret.type = "userDefined"; |
|
|
|
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fontName+"'>"+fontName+"</span>"; |
|
|
|
ret.example = ""; |
|
|
|
this.fontSelectList.push(ret); |
|
|
|
|
|
|
|
let $menuButton = $("#luckysheet-icon-font-family-menuButton"); |
|
|
|
let itemset = this.createButtonMenu(this.fontSelectList); |
|
|
|
$menuButton.html(itemset); |
|
|
|
} |
|
|
|
}, |
|
|
|
fontInitial:function(fontList) { |
|
|
|
let itemdata = []; |
|
|
|
const locale_fontarray = locale().fontarray; |
|
|
|
for(let a=0;a<locale_fontarray.length;a++){ |
|
|
|
let fItem = locale_fontarray[a]; |
|
|
|
let ret = {}; |
|
|
|
ret.value = fItem; |
|
|
|
ret.index = a; |
|
|
|
ret.type = "inner"; |
|
|
|
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fItem+"'>"+fItem+"</span>"; |
|
|
|
ret.example = ""; |
|
|
|
itemdata.push(ret); |
|
|
|
} |
|
|
|
|
|
|
|
if(fontList!=null){ |
|
|
|
for(let a=0;a<fontList.length;a++){ |
|
|
|
let fItem = fontList[a]; |
|
|
|
let ret = {}; |
|
|
|
ret.value = fItem.fontName; |
|
|
|
ret.index = a; |
|
|
|
ret.type = "userDefined"; |
|
|
|
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fItem.fontName+"'>"+fItem.fontName+"</span>"; |
|
|
|
ret.example = ""; |
|
|
|
itemdata.push(ret); |
|
|
|
|
|
|
|
if(!document.fonts.check("12px "+fItem.fontName)){ |
|
|
|
if(fItem.url){ |
|
|
|
const fontface = new FontFace(fItem.fontName, `url(${fItem.url})`); |
|
|
|
document.fonts.add(fontface); |
|
|
|
fontface.load(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
document.fonts.ready.then(function() { |
|
|
|
// Any operation that needs to be done only after all the fonts
|
|
|
|
// have finished loading can go here.
|
|
|
|
console.log("font ready"); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
this.fontSelectList = itemdata; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|