radial-tool.js revision a72d4a27c0d01842fa9746d86918a99f810d2734
3b28a6cd6294fa40166327b097529ae5da1698ceJeff ConniffYUI({filter:"raw"}).use('graphics','dd','event-key','dd-delegate','dd-constrain','resize','json', 'cssbutton', 'cssbuttons', 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
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('#btn-close-code').setStyle('visibility', 'visible');
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('#output-grad textarea').setStyle('visibility', 'visible');
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'+
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff var closeCode = function(){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff if(tarea.getStyle('visibility') === 'visible'){
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('#btn-close-code').setStyle('visibility', 'hidden');
3b28a6cd6294fa40166327b097529ae5da1698ceJeff Conniff Y.one('#btn-close-code').on('click', function(){
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