Created
July 12, 2011 14:09
-
-
Save fflorent/1078057 to your computer and use it in GitHub Desktop.
[ORYX] a workaround for containsMorphingRules and showStencilButtons when no morphing rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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