Skip to content

Instantly share code, notes, and snippets.

@fflorent
Created July 12, 2011 14:09
Show Gist options
  • Save fflorent/1078057 to your computer and use it in GitHub Desktop.
Save fflorent/1078057 to your computer and use it in GitHub Desktop.
[ORYX] a workaround for containsMorphingRules and showStencilButtons when no morphing rules
/**
* Fix for containsMorphingRules and showStencilButtons
* which avoids in some case to show the shape menu
* see this bug : http://code.google.com/p/oryx-editor/issues/detail?id=481
*/
(function(){
var prot = ORYX.Core.StencilSet.Rules.prototype;
var origFn = prot.containsMorphingRules;
prot.containsMorphingRules = function(){
// we get the caller function :
var caller = arguments.callee.caller;
// if the caller function is showStencilButtons
if(caller === ORYX.Plugins.ShapeMenuPlugin.prototype.showStencilButtons){
// we get the first argument of the caller function
var elements = caller.arguments[0];
if(elements.length > 1) // if there are more than one element
origFn.call(this); // we should not show the shape menu ...
else{
// we do the same treatment as containsMorphingRules
// but we look for a morphingRule for the specific element only
return this._morphingRules[ elements[0].getStencil().id() ] !== undefined;
}
}
else // otherwise
return origFn.call(this);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment