$(function(){ enableGsEditor(); }); function enableGsEditor(){ var tag = "button"; if($.browser.msie && parseInt($.browser.version)<8){ tag = "div"; } window.gseditor = com.wiris.jsEditor.JsEditor.newInstance({ 'language': 'zh' }); gseditor.insertInto(document.getElementById('editorContainer')); gseditor.onIsReady(function(){ $(tag+".wrs_button").each(function(i,n){$(this).attr("num",i)}); setTimeout(function(){ $("#gsedit_loading").hide(); $("#editorContainer").removeAttr("style"); gseditor.focus() },180); }); js.Lib.isIE = $.browser.msie; var cmdstr = ""; $("#editorContainer").keydown(function(e){ if(e.keyCode==33){ $(tag+".wrs_selected").prev().click(); return false; }else if(e.keyCode==34){ $(tag+".wrs_selected").next().click(); return false; }if(e.keyCode==36){ $(tag+"[role]").first().click(); return false; }else if(e.keyCode==35){ $(tag+"[role]").last().click(); return false; } if(e.keyCode==27 || e.keyCode==112){ var btnList = $("div.wrs_selected "+tag+".wrs_button"); if(btnList.eq(0).find(".numposition").length==0){ btnList.each(function(){ $(this).append(''+$(this).attr("num")+''); }); } btnList.addClass("position"); return false; } if(e.altKey && e.ctrlKey){ if(/48|49|5[0-7]/.test(e.keyCode)){ cmdstr+=e.keyCode-48; }else if(/9[6-9]|10[0-5]/.test(e.keyCode)){ cmdstr+=e.keyCode-96; } } }).keyup(function(e){ if(e.keyCode==27 || e.keyCode==112){ var btnList = $(tag+".position"); btnList.removeClass("position"); } if(e.keyCode==18){ $(tag+"[num='"+$.trim(cmdstr)+"']").click(); cmdstr = ""; e.preventDefault(); return false; } }); } if(!window.editGs){ window.editGs = function(obj){ var mathML = $.gs[obj.id]; $("#gseditor").ui("dialog",{ close : ".pup_close" }); $("#gsinsert").data("element",obj); if($.browser.msie){ gseditor.setMathML(mathML); }else{ gseditor.editorModel.reset(); gseditor.editorModel.insertMathML(mathML); } gs.focus(); setTimeout(function(){ $("button[num=34]").focus(); },100); return false; } }