a better way of detecting iframe focus

master
Mark MacKay 2012-06-27 13:23:59 -05:00
parent 51025a350b
commit ca0589c404
2 changed files with 15 additions and 11 deletions

View File

@ -2055,8 +2055,12 @@
return false;
}
var closer = function(e){
//Method of Action specific to detect when the iframe has focus
if (top != self && !e.isTrigger) {
top.exports.setEditorFocus();
if(typeof top.exports.setEditorFocus == 'function') {
top.exports.setEditorFocus();
}
}
if (!$(e.target).hasClass("menu_title") && $('#menu_bar').hasClass("active")) {
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) {

View File

@ -440,16 +440,16 @@ B=q?"stroke":"fill",K=a(this).attr("data-rgb"),Q=null;console.log(K);if(K==="tra
"table-cell");a(this).addClass("expanded");xa()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");xa()});var kb=function(q,B){if(a(q).hasClass("disabled"))return false;if(a(q).parent().hasClass("tools_flyout"))return true;var K=K||"normal";B||a(".tools_flyout").fadeOut(K);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=
null,B=null,K=qa[0],Q=false,W=false;a("#svgcanvas").bind("mousemove mouseup",function(ia){if(Q!==false){K.scrollLeft-=ia.clientX-q;K.scrollTop-=ia.clientY-B;q=ia.clientX;B=ia.clientY;if(ia.type==="mouseup")Q=false;return false}}).mousedown(function(ia){if(ia.button===1||W===true){Q=true;q=ia.clientX;B=ia.clientY;return false}});a(window).mouseup(function(){Q=false});a(document).bind("keydown","space",function(ia){f.spaceKey=W=true;ia.preventDefault()}).bind("keyup","space",function(ia){ia.preventDefault();
f.spaceKey=W=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&qa.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&qa.removeClass("out")})})();var Ca=a(".menu"),wb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background="#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},
220);return false};a(".menu_item").live("click",function(q){wb(q)});a("svg, body").on("click",function(q){top!=self&&!q.isTrigger&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title")&&a("#menu_bar").hasClass("active"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))wb(q);else{a("#menu_bar").removeClass("active");a(".tools_flyout").hide();a("input").blur()}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",
function(){Ca.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,B,K){if(a(q).length!=0){var Q=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){Q.removeClass("down");W.hide()}ia=false});Q.bind("mousedown",function(){if(Q.hasClass("down")){Q.removeClass("down");W.hide()}else{Q.addClass("down");if(!K){var va=a(q).offset();
W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,Q){var W=a(q);B=a(B);var ia=false,va=Q.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(Q.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,left:0})}ia=false});B.height();
a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});Q.multiclick&&B.mousedown(function(){ia=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",
function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);mb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,B){mb(B)}});c.addDropDown("#blur_dropdown",a.noop);var yb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,B){yb=false;Ab(B);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){yb=true},
slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),B=q.attr("data-val");B?La(window,B):Na({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,
B=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";qa.mousedown(B)}).blur(function(){U="canvas";qa.unbind("mousedown",B);f.getMode()=="textedit"&&a("#text").focus()})})();var Bb=function(){if(kb("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},ob=function(){kb("#tool_fhpath")&&f.setMode("fhpath")},Cb=function(){kb("#tool_line")&&
f.setMode("line")},Kb=function(){kb("#tool_rect")&&f.setMode("rect")},Ib=function(){kb("#tool_ellipse")&&f.setMode("ellipse")},Rb=function(){kb("#tool_image")&&f.setMode("image")},na=function(){kb("#tool_zoom")&&f.setMode("zoom")},Z=function(){if(kb("#tool_zoom")){h();ma()}},ta=function(){kb("#tool_text")&&f.setMode("text")},M=function(){kb("#tool_path")&&f.setMode("path")},I=function(){if(Y!=null||za)f.deleteSelectedElements()},X=function(){if(Y!=null||za)f.cutSelectedElements()},Ma=function(){if(Y!=
null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},bb=function(){if(Y!=
null||za)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},qb=function(q,B){if(Y!=null||za){if(d.gridSnapping){var K=f.getZoom()*d.snappingStep;q*=K;B*=K}f.moveSelectedElements(q,B)}},Qb=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",
220);return false};a(".menu_item").live("click",function(q){wb(q)});a("svg, body").on("click",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title")&&a("#menu_bar").hasClass("active"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))wb(q);else{a("#menu_bar").removeClass("active");a(".tools_flyout").hide();a("input").blur()}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});
a(".menu_title").on("mouseover",function(){Ca.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,B,K){if(a(q).length!=0){var Q=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){Q.removeClass("down");W.hide()}ia=false});Q.bind("mousedown",function(){if(Q.hasClass("down")){Q.removeClass("down");W.hide()}else{Q.addClass("down");
if(!K){var va=a(q).offset();W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,Q){var W=a(q);B=a(B);var ia=false,va=Q.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(Q.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,
left:0})}ia=false});B.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});Q.multiclick&&B.mousedown(function(){ia=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});
c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);mb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,B){mb(B)}});c.addDropDown("#blur_dropdown",a.noop);var yb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,B){yb=false;Ab(B);a("#blur_dropdown li").show();a(window).mouseup()},
start:function(){yb=true},slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),B=q.attr("data-val");B?La(window,B):Na({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,
"page")})});(function(){var q,B=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";qa.mousedown(B)}).blur(function(){U="canvas";qa.unbind("mousedown",B);f.getMode()=="textedit"&&a("#text").focus()})})();var Bb=function(){if(kb("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},ob=function(){kb("#tool_fhpath")&&f.setMode("fhpath")},Cb=
function(){kb("#tool_line")&&f.setMode("line")},Kb=function(){kb("#tool_rect")&&f.setMode("rect")},Ib=function(){kb("#tool_ellipse")&&f.setMode("ellipse")},Rb=function(){kb("#tool_image")&&f.setMode("image")},na=function(){kb("#tool_zoom")&&f.setMode("zoom")},Z=function(){if(kb("#tool_zoom")){h();ma()}},ta=function(){kb("#tool_text")&&f.setMode("text")},M=function(){kb("#tool_path")&&f.setMode("path")},I=function(){if(Y!=null||za)f.deleteSelectedElements()},X=function(){if(Y!=null||za)f.cutSelectedElements()},
Ma=function(){if(Y!=null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},
bb=function(){if(Y!=null||za)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},qb=function(q,B){if(Y!=null||za){if(d.gridSnapping){var K=f.getZoom()*d.snappingStep;q*=K;B*=K}f.moveSelectedElements(q,B)}},Qb=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",
false);sa.linkControlPoints(q)},$b=function(){sa.getNodePoint()&&sa.clonePathNode()},Zb=function(){sa.getNodePoint()&&sa.deletePathNode()},rb=function(){var q=a("#tool_add_subpath"),B=!q.hasClass("push_button_pressed");B?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");sa.addSubPath(B)},Va=function(){sa.opencloseSubPath()},gc=function(){f.cycleElement(1)},cc=function(){f.cycleElement(0)},Ub=function(q,B){if(!(Y==null||za)){q||
(B*=-1);var K=a("#angle").val()*1+B;f.setRotationAngle(K);Za()}},hc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ma();f.clear();f.setResolution(q[0],q[1]);Tb(true);h();Eb();Za();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},lc=function(){f.setBold(!f.getBold());Za();return false},Wb=function(){f.setItalic(!f.getItalic());Za();return false},ac=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+
q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},nc=function(){f.open()},Vb=function(){},ub=function(q){var B=q.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ic=function(){if(ja.getUndoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));ja.undo();Eb()}},dc=function(){if(ja.getRedoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));