radial-tool.js revision eaee839afff6e24a5ba7277c5fdacd4eeba4253b
eaee839afff6e24a5ba7277c5fdacd4eeba4253bJeff ConniffYUI({filter:"raw"}).use('graphics','dd','event-key','dd-delegate','dd-constrain','resize','json', 'cssbutton', 'panel', 'dd-plugin', function (Y){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff///////////////////// gradient UI controls //////////////////////
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Updates the radial fill properties in myellipse
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff var updateGraphic = function(){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // This recenters the outter edge of the gradient control, as it is sized
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff var recenterGradientR = function(e){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff var radius = resizeNode.get('offsetWidth')/2 + 'px';
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff theR = (resizeNode.get('offsetWidth') / 2) / gradControlNode.get('offsetWidth');
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Instatiate a resize object on the outter gradient control ring
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff //Selector of the node to resize
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff resize.after('resize:resize', function(){ // seem to need both resize:resize and resize:end
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Instantiate a drag on the container of the outter gradient control ring
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Instantiate a drag on the container of the inner gradient control ring
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Handle drag of the container of the outter control ring
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff theCX = (this.lastXY[0] - origX) / (maxX - cW);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff theCY = (this.lastXY[1] - origY) / (maxY - cW);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Handle drag of the container of the inner control ring
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff theFX = (this.lastXY[0] - origX) / (maxX - fW);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff theFY = (this.lastXY[1] - origY) / (maxY - fW);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Handle a click on the 'get code snippet' button
a72d4a27c0d01842fa9746d86918a99f810d2734Jeff Conniff 'var myellipse = mygraphic.addShape({\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' type: "ellipse",\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' fill: {\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' type: "radial",\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' stops: [\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' stroke: {\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' weight: 0,\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' color: "#000" \n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' width: 150,\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' height: 100,\n'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff ' x: 35,\n'+
eaee839afff6e24a5ba7277c5fdacd4eeba4253bJeff Conniff var textArea = Y.one('#panel-content textarea')
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('#center-color').on('change', function(){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('.grad-f').setStyle('backgroundColor', centerColor);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('.grad-r').setStyle('backgroundColor', outerColor);
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff///////////////////// END gradient UI controls //////////////////////
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // Instantiate a new graphic to contain objects
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff // add shapes to the graphics object
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff var loadGraphics = function (e)
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff //create an ellipse with addShape
eaee839afff6e24a5ba7277c5fdacd4eeba4253bJeff Conniff ////////////////////////////////////////
eaee839afff6e24a5ba7277c5fdacd4eeba4253bJeff Conniff bodyContent: '<div class="textarea-box"><textarea></textarea></div>',
eaee839afff6e24a5ba7277c5fdacd4eeba4253bJeff Conniff action : function (e) {