123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- $(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('<i class="numposition" style="font-size:10px">'+$(this).attr("num")+'</i>');
- });
- }
- 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;
- }
- }
|