Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Gallery Build Tag: gallery-2011.03.11-23-49

  • Loading branch information...
commit 5a3b7b6dee2c3ffac2db28bda7e8146e324a5205 1 parent eb07cfd
YUI Builder authored
Showing with 2,894 additions and 826 deletions.
  1. +198 −0 build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-debug.js
  2. +1 −0  build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-min.js
  3. +198 −0 build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue.js
  4. +7 −12 build/gallery-button-toggle/gallery-button-toggle-debug.js
  5. +1 −1  build/gallery-button-toggle/gallery-button-toggle-min.js
  6. +7 −12 build/gallery-button-toggle/gallery-button-toggle.js
  7. +16 −16 build/gallery-dialog/gallery-dialog-debug.js
  8. +1 −1  build/gallery-dialog/gallery-dialog-min.js
  9. +16 −16 build/gallery-dialog/gallery-dialog.js
  10. +79 −0 build/gallery-google-maps-frame/gallery-google-maps-frame-debug.js
  11. +1 −0  build/gallery-google-maps-frame/gallery-google-maps-frame-min.js
  12. +79 −0 build/gallery-google-maps-frame/gallery-google-maps-frame.js
  13. +86 −48 build/gallery-graphics-canvas/gallery-graphics-canvas-debug.js
  14. +3 −3 build/gallery-graphics-canvas/gallery-graphics-canvas-min.js
  15. +86 −48 build/gallery-graphics-canvas/gallery-graphics-canvas.js
  16. +48 −43 build/gallery-graphics-svg/gallery-graphics-svg-debug.js
  17. +2 −2 build/gallery-graphics-svg/gallery-graphics-svg-min.js
  18. +48 −43 build/gallery-graphics-svg/gallery-graphics-svg.js
  19. +149 −13 build/gallery-graphics-vml/gallery-graphics-vml-debug.js
  20. +2 −2 build/gallery-graphics-vml/gallery-graphics-vml-min.js
  21. +149 −13 build/gallery-graphics-vml/gallery-graphics-vml.js
  22. +1 −1  build/gallery-graphics/gallery-graphics-debug.js
  23. +1 −1  build/gallery-graphics/gallery-graphics-min.js
  24. +1 −1  build/gallery-graphics/gallery-graphics.js
  25. +427 −0 build/gallery-io-multiresponse/gallery-io-multiresponse-debug.js
  26. +1 −0  build/gallery-io-multiresponse/gallery-io-multiresponse-min.js
  27. +418 −0 build/gallery-io-multiresponse/gallery-io-multiresponse.js
  28. +29 −19 build/gallery-notify/gallery-notify-debug.js
  29. +1 −1  build/gallery-notify/gallery-notify-min.js
  30. +29 −19 build/gallery-notify/gallery-notify.js
  31. +3 −3 build/gallery-plugin-simple-datatable-sort/gallery-plugin-simple-datatable-sort-debug.js
  32. +1 −1  build/gallery-plugin-simple-datatable-sort/gallery-plugin-simple-datatable-sort-min.js
  33. +3 −3 build/gallery-plugin-simple-datatable-sort/gallery-plugin-simple-datatable-sort.js
  34. +23 −16 build/gallery-plugin-title-scroll/gallery-plugin-title-scroll-debug.js
  35. +1 −1  build/gallery-plugin-title-scroll/gallery-plugin-title-scroll-min.js
  36. +23 −16 build/gallery-plugin-title-scroll/gallery-plugin-title-scroll.js
  37. +69 −79 build/gallery-scroll-nav/gallery-scroll-nav-debug.js
  38. +1 −1  build/gallery-scroll-nav/gallery-scroll-nav-min.js
  39. +69 −79 build/gallery-scroll-nav/gallery-scroll-nav.js
  40. +79 −79 build/gallery-simple-datatable/gallery-simple-datatable-debug.js
  41. +1 −1  build/gallery-simple-datatable/gallery-simple-datatable-min.js
  42. +79 −79 build/gallery-simple-datatable/gallery-simple-datatable.js
  43. +6 −2 build/gallery-text-resizer/gallery-text-resizer-debug.js
  44. +1 −1  build/gallery-text-resizer/gallery-text-resizer-min.js
  45. +6 −2 build/gallery-text-resizer/gallery-text-resizer.js
  46. +5 −4 build/gallery-timer/gallery-timer-debug.js
  47. +1 −1  build/gallery-timer/gallery-timer-min.js
  48. +5 −4 build/gallery-timer/gallery-timer.js
  49. +65 −66 build/gallery-title/gallery-title-debug.js
  50. +1 −1  build/gallery-title/gallery-title-min.js
  51. +65 −66 build/gallery-title/gallery-title.js
  52. +152 −0 build/gallery-xarno-clipboard/gallery-xarno-clipboard-debug.js
  53. +1 −0  build/gallery-xarno-clipboard/gallery-xarno-clipboard-min.js
  54. +143 −0 build/gallery-xarno-clipboard/gallery-xarno-clipboard.js
  55. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommand-debug.js
  56. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommand-min.js
  57. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommand.js
  58. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-base-debug.js
  59. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-base-min.js
  60. +1 −1  src/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-base.js
198 build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-debug.js
View
@@ -0,0 +1,198 @@
+YUI.add('gallery-asynchronouscommandqueue-base', function(Y) {
+
+'use strict';
+
+var _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ completed: {
+ readOnly: true,
+ value: false
+ },
+ paused: {
+ value: false
+ },
+ started: {
+ readOnly: true,
+ value: false
+ },
+ queue: {
+ value: [],
+ writeOnce: 'initOnly'
+ }
+};
+_class.NAME = 'AsynchronousCommandQueue';
+
+Y.extend(_class, Y.Base, {
+ addCommand: function (asynchronousCommand) {
+ this.get('queue').push(asynchronousCommand);
+ return this;
+ },
+ getCommandCount: function () {
+ return this.get('queue.length');
+ },
+ initializer: function () {
+ this.publish('complete', {
+ fireOnce: true
+ });
+ this.publish('pause');
+ this.publish('resume');
+ this.publish('start', {
+ fireOnce: true
+ });
+
+ this.on('complete', function (eventFacade, response, args) {
+ this._set('completed', true);
+ }, this);
+
+ this.on('start', function (eventFacade, response, args) {
+ this._set('started', true);
+ }, this);
+ },
+ pauseQueue: function () {
+ this.set('paused', true);
+ this.fire('pause');
+ return this;
+ },
+ resumeQueue: function () {
+ this.set('paused', false);
+ this.fire('resume');
+ return this.startQueue();
+ },
+ startAll: function () {
+ var commandCount,
+ completeCount = 0,
+ i,
+ startCommand,
+ queue = this.get('queue');
+
+ startCommand = function (asynchronousCommand) {
+ asynchronousCommand.execute().on('complete', function () {
+ completeCount += 1;
+ if (completeCount === commandCount) {
+ this._set('queue', queue.slice(commandCount));
+ if (this.get('queue.length')) {
+ this.startAll();
+ } else {
+ this.fire('complete');
+ }
+ }
+ }, this);
+ };
+
+ this.fire('start');
+
+ for (i = 0, commandCount = queue.length; i < commandCount; i += 1) {
+ startCommand.call(this, queue[i]);
+ }
+
+ return this;
+ },
+ startQueue: function () {
+ if (this.get('paused')) {
+ return this;
+ } else if (!this.get('queue.length')) {
+ this.fire('complete');
+ return this;
+ }
+
+ this.fire('start');
+ this.get('queue').shift().execute().on('complete', function () {
+ this.startQueue();
+ }, this);
+
+ return this;
+ }
+});
+
+Y.AsynchronousCommandQueue = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base'], skinnable:false});
+YUI.add('gallery-asynchronouscommand', function(Y) {
+
+'use strict';
+
+var _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ args: {
+ value: [],
+ writeOnce: 'initOnly'
+ },
+ completed: {
+ readOnly: true,
+ value: false
+ },
+ context: {
+ value: Y.config.win,
+ writeOnce: 'initOnly'
+ },
+ delay: {
+ readOnly: true,
+ value: 0
+ },
+ fn: {
+ value: function (asynchronousCommand) {
+ asynchronousCommand.fire('complete');
+ },
+ writeOnce: 'initOnly'
+ },
+ started: {
+ readOnly: true,
+ value: false
+ }
+};
+_class.NAME = 'AsynchronousCommand';
+
+Y.extend(_class, Y.Base, {
+ execute: function () {
+ Y.later(this.get('delay'), this, function () {
+ this.fire('start');
+ this.get('fn').apply(this.get('context'), this.get('args'));
+ });
+ return this;
+ },
+ initializer: function () {
+ this.publish('complete', {
+ fireOnce: true
+ });
+ this.publish('start', {
+ fireOnce: true
+ });
+
+ var args = this.get('args');
+
+ if (!Y.Lang.isArray(args)) {
+ args = [args];
+ }
+
+ args.unshift(this);
+ this._set('args', args);
+
+ this.on('complete', function () {
+ this._set('completed', true);
+ }, this);
+
+ this.on('start', function () {
+ this._set('started', true);
+ }, this);
+ }
+});
+
+Y.AsynchronousCommand = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base'], skinnable:false});
+
+
+YUI.add('gallery-asynchronouscommandqueue', function(Y){}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-asynchronouscommand', 'gallery-asynchronouscommandqueue-base'], skinnable:false});
+
1  build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue-min.js
View
@@ -0,0 +1 @@
+YUI.add("gallery-asynchronouscommandqueue-base",function(b){var a;a=function(c){a.superclass.constructor.call(this,c);};a.ATTRS={completed:{readOnly:true,value:false},paused:{value:false},started:{readOnly:true,value:false},queue:{value:[],writeOnce:"initOnly"}};a.NAME="AsynchronousCommandQueue";b.extend(a,b.Base,{addCommand:function(c){this.get("queue").push(c);return this;},getCommandCount:function(){return this.get("queue.length");},initializer:function(){this.publish("complete",{fireOnce:true});this.publish("pause");this.publish("resume");this.publish("start",{fireOnce:true});this.on("complete",function(e,c,d){this._set("completed",true);},this);this.on("start",function(e,c,d){this._set("started",true);},this);},pauseQueue:function(){this.set("paused",true);this.fire("pause");return this;},resumeQueue:function(){this.set("paused",false);this.fire("resume");return this.startQueue();},startAll:function(){var d,e=0,f,g,c=this.get("queue");g=function(h){h.execute().on("complete",function(){e+=1;if(e===d){this._set("queue",c.slice(d));if(this.get("queue.length")){this.startAll();}else{this.fire("complete");}}},this);};this.fire("start");for(f=0,d=c.length;f<d;f+=1){g.call(this,c[f]);}return this;},startQueue:function(){if(this.get("paused")){return this;}else{if(!this.get("queue.length")){this.fire("complete");return this;}}this.fire("start");this.get("queue").shift().execute().on("complete",function(){this.startQueue();},this);return this;}});b.AsynchronousCommandQueue=a;},"gallery-2011.03.11-23-49",{requires:["base"],skinnable:false});YUI.add("gallery-asynchronouscommand",function(b){var a;a=function(c){a.superclass.constructor.call(this,c);};a.ATTRS={args:{value:[],writeOnce:"initOnly"},completed:{readOnly:true,value:false},context:{value:b.config.win,writeOnce:"initOnly"},delay:{readOnly:true,value:0},fn:{value:function(c){c.fire("complete");},writeOnce:"initOnly"},started:{readOnly:true,value:false}};a.NAME="AsynchronousCommand";b.extend(a,b.Base,{execute:function(){b.later(this.get("delay"),this,function(){this.fire("start");this.get("fn").apply(this.get("context"),this.get("args"));});return this;},initializer:function(){this.publish("complete",{fireOnce:true});this.publish("start",{fireOnce:true});var c=this.get("args");if(!b.Lang.isArray(c)){c=[c];}c.unshift(this);this._set("args",c);this.on("complete",function(){this._set("completed",true);},this);this.on("start",function(){this._set("started",true);},this);}});b.AsynchronousCommand=a;},"gallery-2011.03.11-23-49",{requires:["base"],skinnable:false});YUI.add("gallery-asynchronouscommandqueue",function(a){},"gallery-2011.03.11-23-49",{requires:["gallery-asynchronouscommand","gallery-asynchronouscommandqueue-base"],skinnable:false});
198 build/gallery-asynchronouscommandqueue/gallery-asynchronouscommandqueue.js
View
@@ -0,0 +1,198 @@
+YUI.add('gallery-asynchronouscommandqueue-base', function(Y) {
+
+'use strict';
+
+var _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ completed: {
+ readOnly: true,
+ value: false
+ },
+ paused: {
+ value: false
+ },
+ started: {
+ readOnly: true,
+ value: false
+ },
+ queue: {
+ value: [],
+ writeOnce: 'initOnly'
+ }
+};
+_class.NAME = 'AsynchronousCommandQueue';
+
+Y.extend(_class, Y.Base, {
+ addCommand: function (asynchronousCommand) {
+ this.get('queue').push(asynchronousCommand);
+ return this;
+ },
+ getCommandCount: function () {
+ return this.get('queue.length');
+ },
+ initializer: function () {
+ this.publish('complete', {
+ fireOnce: true
+ });
+ this.publish('pause');
+ this.publish('resume');
+ this.publish('start', {
+ fireOnce: true
+ });
+
+ this.on('complete', function (eventFacade, response, args) {
+ this._set('completed', true);
+ }, this);
+
+ this.on('start', function (eventFacade, response, args) {
+ this._set('started', true);
+ }, this);
+ },
+ pauseQueue: function () {
+ this.set('paused', true);
+ this.fire('pause');
+ return this;
+ },
+ resumeQueue: function () {
+ this.set('paused', false);
+ this.fire('resume');
+ return this.startQueue();
+ },
+ startAll: function () {
+ var commandCount,
+ completeCount = 0,
+ i,
+ startCommand,
+ queue = this.get('queue');
+
+ startCommand = function (asynchronousCommand) {
+ asynchronousCommand.execute().on('complete', function () {
+ completeCount += 1;
+ if (completeCount === commandCount) {
+ this._set('queue', queue.slice(commandCount));
+ if (this.get('queue.length')) {
+ this.startAll();
+ } else {
+ this.fire('complete');
+ }
+ }
+ }, this);
+ };
+
+ this.fire('start');
+
+ for (i = 0, commandCount = queue.length; i < commandCount; i += 1) {
+ startCommand.call(this, queue[i]);
+ }
+
+ return this;
+ },
+ startQueue: function () {
+ if (this.get('paused')) {
+ return this;
+ } else if (!this.get('queue.length')) {
+ this.fire('complete');
+ return this;
+ }
+
+ this.fire('start');
+ this.get('queue').shift().execute().on('complete', function () {
+ this.startQueue();
+ }, this);
+
+ return this;
+ }
+});
+
+Y.AsynchronousCommandQueue = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base'], skinnable:false});
+YUI.add('gallery-asynchronouscommand', function(Y) {
+
+'use strict';
+
+var _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ args: {
+ value: [],
+ writeOnce: 'initOnly'
+ },
+ completed: {
+ readOnly: true,
+ value: false
+ },
+ context: {
+ value: Y.config.win,
+ writeOnce: 'initOnly'
+ },
+ delay: {
+ readOnly: true,
+ value: 0
+ },
+ fn: {
+ value: function (asynchronousCommand) {
+ asynchronousCommand.fire('complete');
+ },
+ writeOnce: 'initOnly'
+ },
+ started: {
+ readOnly: true,
+ value: false
+ }
+};
+_class.NAME = 'AsynchronousCommand';
+
+Y.extend(_class, Y.Base, {
+ execute: function () {
+ Y.later(this.get('delay'), this, function () {
+ this.fire('start');
+ this.get('fn').apply(this.get('context'), this.get('args'));
+ });
+ return this;
+ },
+ initializer: function () {
+ this.publish('complete', {
+ fireOnce: true
+ });
+ this.publish('start', {
+ fireOnce: true
+ });
+
+ var args = this.get('args');
+
+ if (!Y.Lang.isArray(args)) {
+ args = [args];
+ }
+
+ args.unshift(this);
+ this._set('args', args);
+
+ this.on('complete', function () {
+ this._set('completed', true);
+ }, this);
+
+ this.on('start', function () {
+ this._set('started', true);
+ }, this);
+ }
+});
+
+Y.AsynchronousCommand = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base'], skinnable:false});
+
+
+YUI.add('gallery-asynchronouscommandqueue', function(Y){}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-asynchronouscommand', 'gallery-asynchronouscommandqueue-base'], skinnable:false});
+
19 build/gallery-button-toggle/gallery-button-toggle-debug.js
View
@@ -5,26 +5,21 @@ var YL = Y.Lang,
Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {
- initializer : function(config) {
- this.after('selectedChange',this._afterSelectedChanged, this);
- },
-
_defPressFn : function(e) {
- this.set('selected', (this.get('selected') === 0) ? 1 : 0);
- },
+ var newSelected = (this.get('selected') === 0) ? 1 : 0;
+ this.set('selected', newSelected);
- _afterSelectedChanged : function(e) {
- if(e.newVal) {
- this._executeCallback();
+ if(newSelected) {
+ this._executeCallback(e);
}else{
- this._executeDeselectCallback();
+ this._executeDeselectCallback(e);
}
},
_executeDeselectCallback : function(e) {
Y.log('Y.ButtonToggle::_executeDeselectCallback');
if(this.get(DESELECTED_CALLBACK)) {
- (this.get(DESELECTED_CALLBACK))();
+ (this.get(DESELECTED_CALLBACK))(e);
}
}
@@ -37,4 +32,4 @@ Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {
});
-}, 'gallery-2010.09.08-19-45' ,{requires:['gallery-button']});
+}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-button']});
2  build/gallery-button-toggle/gallery-button-toggle-min.js
View
@@ -1 +1 @@
-YUI.add("gallery-button-toggle",function(C){var B=C.Lang,A="deselectedCallback";C.ButtonToggle=C.Base.create("button",C.Button,[],{initializer:function(D){this.after("selectedChange",this._afterSelectedChanged,this);},_defPressFn:function(D){this.set("selected",(this.get("selected")===0)?1:0);},_afterSelectedChanged:function(D){if(D.newVal){this._executeCallback();}else{this._executeDeselectCallback();}},_executeDeselectCallback:function(D){if(this.get(A)){(this.get(A))();}}},{ATTRS:{deselectedCallback:{validator:B.isFunction}}});},"gallery-2010.09.08-19-45",{requires:["gallery-button"]});
+YUI.add("gallery-button-toggle",function(c){var b=c.Lang,a="deselectedCallback";c.ButtonToggle=c.Base.create("button",c.Button,[],{_defPressFn:function(f){var d=(this.get("selected")===0)?1:0;this.set("selected",d);if(d){this._executeCallback(f);}else{this._executeDeselectCallback(f);}},_executeDeselectCallback:function(d){if(this.get(a)){(this.get(a))(d);}}},{ATTRS:{deselectedCallback:{validator:b.isFunction}}});},"gallery-2011.03.11-23-49",{requires:["gallery-button"]});
19 build/gallery-button-toggle/gallery-button-toggle.js
View
@@ -5,25 +5,20 @@ var YL = Y.Lang,
Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {
- initializer : function(config) {
- this.after('selectedChange',this._afterSelectedChanged, this);
- },
-
_defPressFn : function(e) {
- this.set('selected', (this.get('selected') === 0) ? 1 : 0);
- },
+ var newSelected = (this.get('selected') === 0) ? 1 : 0;
+ this.set('selected', newSelected);
- _afterSelectedChanged : function(e) {
- if(e.newVal) {
- this._executeCallback();
+ if(newSelected) {
+ this._executeCallback(e);
}else{
- this._executeDeselectCallback();
+ this._executeDeselectCallback(e);
}
},
_executeDeselectCallback : function(e) {
if(this.get(DESELECTED_CALLBACK)) {
- (this.get(DESELECTED_CALLBACK))();
+ (this.get(DESELECTED_CALLBACK))(e);
}
}
@@ -36,4 +31,4 @@ Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {
});
-}, 'gallery-2010.09.08-19-45' ,{requires:['gallery-button']});
+}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-button']});
32 build/gallery-dialog/gallery-dialog-debug.js
View
@@ -2,7 +2,7 @@ YUI.add('gallery-dialog', function(Y) {
var YL = Y.Lang,
LABEL_CANCEL = 'Cancel',
- LABEL_OK = 'OK',
+ LABEL_OK = 'OK',
CALLBACK_CANCEL = 'cancel',
CALLBACK_OK = 'ok',
EMPTY_FN = function(){},
@@ -67,7 +67,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
this.handleEscape = Y.once('esc', Y.bind(function(){ this.hide(); }, this), Y.config.doc);
Y.Dialog.superclass.show.apply(this,arguments);
- this.syncUI();
+ this.syncUI();
var dBtn = this.get(ATTR_DEFAULT_BUTTON);
@@ -127,7 +127,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
*/
build : function(header, body, buttons) {
Y.log('initializer','info','Y.Dialog');
-
+
var i, l, btn;
this.purge();
@@ -323,7 +323,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
// need to build the input box and bind the events to it
// then append it to the body
promptInput = Y.Node.create('<input type="text" style="display: block; margin-top: 0.5em;">');
- promptInput.addClass(this.getClassName('prompt'));
+ promptInput.addClass(this.getClassName('prompt'));
promptInput.on('keyup', Y.bind(function(e){
this.set(ATTR_RETURN_VAL, promptInput.get('value'));
@@ -409,23 +409,23 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
ATTRS : {
centered : {
- value : true
- },
-
+ value : true
+ },
+
callbacks : {
value : {}
},
-
+
constrain : {
value : true
},
-
+
defaultButton : {
validator : function(val) {
return (val instanceof Y.Button);
}
},
-
+
draggable : {
value : true,
validator : YL.isBoolean,
@@ -434,15 +434,15 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
return val;
}
},
-
+
render : {
value : true
},
-
+
returnVal : {
value : null
},
-
+
icon : {
validator : YL.isString,
setter : function(val) {
@@ -453,11 +453,11 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
return val;
}
},
-
+
visible : {
value : false
},
-
+
zIndex : {
value : 20000
}
@@ -465,4 +465,4 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
});
-}, 'gallery-2011.02.02-21-07' ,{requires:['gallery-overlay-extras','gallery-button','overlay','widget-anim','node','gallery-event-nav-keys','dd-plugin']});
+}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-overlay-extras','gallery-button','overlay','widget-anim','node','gallery-event-nav-keys','dd-plugin']});
2  build/gallery-dialog/gallery-dialog-min.js
View
@@ -1 +1 @@
-YUI.add("gallery-dialog",function(a){var h=a.Lang,i="Cancel",k="OK",l="cancel",d="ok",c=function(){},j="callbacks",g="defaultButton",f="draggable",e="returnVal",b="icon";a.Dialog=a.Base.create("dialog",a.Overlay,[],{handleEnter:null,handleEscape:null,initializer:function(m){this.plug(a.Plugin.WidgetAnim);this.plug(a.Plugin.OverlayModal);this.plug(a.Plugin.OverlayKeepaligned);},hide:function(n){a.one("body").set("tabIndex",-1).focus();a.Dialog.superclass.hide.apply(this,arguments);var m=(n)?this.getCallback(n):this.getCallback(l);if(h.isFunction(m)){(a.bind(m,this,this.get(e)))();this.set(e,null);}this.anim.get("animHide").on("end",a.bind(function(){this.purge();},this));},show:function(){this.get(f);this.handleEscape=a.once("esc",a.bind(function(){this.hide();},this),a.config.doc);a.Dialog.superclass.show.apply(this,arguments);this.syncUI();var m=this.get(g);if(m){m.focus();}this.get("boundingBox").set("tabIndex",-1);},header:function(n,m){this._setContent(a.WidgetStdMod.HEADER,n,m);},body:function(n,m){this._setContent(a.WidgetStdMod.BODY,n,m);},footer:function(n,m){this._setContent(a.WidgetStdMod.FOOTER,n,m);},build:function(r,m,q){var p,n,o;this.purge();if(r){this.header(r);}if(m){this.body(m||null);}if(q){for(p=0,n=q.length;p<n;p++){o=q[p];o.render();if(o.get("default")){this.set(g,o);}this.footer(o.get("boundingBox"),"after");}}return this;},getCallback:function(m){return(this.get(j)[m]||null);},addCallback:function(n,m){if(h.isFunction(m)){this.get(j)[n]=m;}},removeCallback:function(m){if(this.get(j)[m]){this.get(j)[m]=null;}},addCloseButton:function(){var m=new a.Button({label:"X",callback:a.bind(function(n){this.hide();},this),title:"Close"});m.render();this.header(m.get("boundingBox"),"after");return this;},purge:function(){this.header(null);this.body(null);this.footer(null);},alert:function(p,o,r){this.set(b,"alert");this.addCallback(l,r||c);var q=o||this._getDefaultTitle(),m=p||null,n=new a.Button({label:k,callback:a.bind(function(s){this.hide();},this),"default":true});this.build(q,m,[n]).addCloseButton().show();},confirm:function(s,r,q,n){this.set(b,"confirm");this.addCallback(d,q||c);this.addCallback(l,n||c);var t=r||this._getDefaultTitle(),m=s||null,o=new a.Button({label:k,callback:a.bind(function(u){this.hide(d);},this),"default":true}),p=new a.Button({label:i,callback:a.bind(function(u){this.hide();},this)});this.build(t,m,[o,p]).addCloseButton().show();},prompt:function(m,s,p,u){this.set(b,"prompt");this.addCallback(d,p||c);this.addCallback(l,u||c);var n=s||this._getDefaultTitle(),o=m||null,t,q=new a.Button({label:k,callback:a.bind(function(v){this.hide(d);},this),"default":true}),r=new a.Button({label:i,callback:a.bind(function(v){this.hide();},this)});this.build(n,o,[q,r]);t=a.Node.create('<input type="text" style="display: block; margin-top: 0.5em;">');t.addClass(this.getClassName("prompt"));t.on("keyup",a.bind(function(v){this.set(e,t.get("value"));},this));this.handleEnter=a.once("enter",a.bind(function(w){var v=this.get(g);if(v){v.fire("press");}},this),t);this.body(t,"after");this.addCloseButton().show();},_getDefaultTitle:function(){return"The page "+location.protocol+"//"+location.host+"/ says:";},_updateDraggable:function(m){var o=this.get("boundingBox"),n=o.all(".yui3-widget-hd");if(m){o.plug(a.Plugin.Drag,{handle:n}).dd.plug(a.Plugin.DDConstrained,{constrain2view:true,gutter:"20"});}else{o.unplug(a.Plugin.Drag).unplug(a.Plugin.DDContrained);}},_setContent:function(o,n,m){this.setStdModContent(o,n,this._standardizePlacement(m));},_standardizePlacement:function(m){var n=(h.isString(m))?m.toLowerCase():null;switch(n){case"prepend":case"before":return a.WidgetStdMod.BEFORE;case"append":case"after":return a.WidgetStdMod.AFTER;default:return a.WidgetStdMod.REPLACE;}}},{ATTRS:{centered:{value:true},callbacks:{value:{}},constrain:{value:true},defaultButton:{validator:function(m){return(m instanceof a.Button);}},draggable:{value:true,validator:h.isBoolean,setter:function(m){this._updateDraggable(m);return m;}},render:{value:true},returnVal:{value:null},icon:{validator:h.isString,setter:function(m){this.get("boundingBox").replaceClass(this.getClassName(b,this.get(b)||"default"),this.getClassName(b,m||"default"));return m;}},visible:{value:false},zIndex:{value:20000}}});},"gallery-2011.02.02-21-07",{requires:["gallery-overlay-extras","gallery-button","overlay","widget-anim","node","gallery-event-nav-keys","dd-plugin"]});
+YUI.add("gallery-dialog",function(a){var h=a.Lang,i="Cancel",k="OK",l="cancel",d="ok",c=function(){},j="callbacks",g="defaultButton",f="draggable",e="returnVal",b="icon";a.Dialog=a.Base.create("dialog",a.Overlay,[],{handleEnter:null,handleEscape:null,initializer:function(m){this.plug(a.Plugin.WidgetAnim);this.plug(a.Plugin.OverlayModal);this.plug(a.Plugin.OverlayKeepaligned);},hide:function(n){a.one("body").set("tabIndex",-1).focus();a.Dialog.superclass.hide.apply(this,arguments);var m=(n)?this.getCallback(n):this.getCallback(l);if(h.isFunction(m)){(a.bind(m,this,this.get(e)))();this.set(e,null);}this.anim.get("animHide").on("end",a.bind(function(){this.purge();},this));},show:function(){this.get(f);this.handleEscape=a.once("esc",a.bind(function(){this.hide();},this),a.config.doc);a.Dialog.superclass.show.apply(this,arguments);this.syncUI();var m=this.get(g);if(m){m.focus();}this.get("boundingBox").set("tabIndex",-1);},header:function(n,m){this._setContent(a.WidgetStdMod.HEADER,n,m);},body:function(n,m){this._setContent(a.WidgetStdMod.BODY,n,m);},footer:function(n,m){this._setContent(a.WidgetStdMod.FOOTER,n,m);},build:function(r,m,q){var p,n,o;this.purge();if(r){this.header(r);}if(m){this.body(m||null);}if(q){for(p=0,n=q.length;p<n;p++){o=q[p];o.render();if(o.get("default")){this.set(g,o);}this.footer(o.get("boundingBox"),"after");}}return this;},getCallback:function(m){return(this.get(j)[m]||null);},addCallback:function(n,m){if(h.isFunction(m)){this.get(j)[n]=m;}},removeCallback:function(m){if(this.get(j)[m]){this.get(j)[m]=null;}},addCloseButton:function(){var m=new a.Button({label:"X",callback:a.bind(function(n){this.hide();},this),title:"Close"});m.render();this.header(m.get("boundingBox"),"after");return this;},purge:function(){this.header(null);this.body(null);this.footer(null);},alert:function(p,o,r){this.set(b,"alert");this.addCallback(l,r||c);var q=o||this._getDefaultTitle(),m=p||null,n=new a.Button({label:k,callback:a.bind(function(s){this.hide();},this),"default":true});this.build(q,m,[n]).addCloseButton().show();},confirm:function(s,r,q,n){this.set(b,"confirm");this.addCallback(d,q||c);this.addCallback(l,n||c);var t=r||this._getDefaultTitle(),m=s||null,o=new a.Button({label:k,callback:a.bind(function(u){this.hide(d);},this),"default":true}),p=new a.Button({label:i,callback:a.bind(function(u){this.hide();},this)});this.build(t,m,[o,p]).addCloseButton().show();},prompt:function(m,s,p,u){this.set(b,"prompt");this.addCallback(d,p||c);this.addCallback(l,u||c);var n=s||this._getDefaultTitle(),o=m||null,t,q=new a.Button({label:k,callback:a.bind(function(v){this.hide(d);},this),"default":true}),r=new a.Button({label:i,callback:a.bind(function(v){this.hide();},this)});this.build(n,o,[q,r]);t=a.Node.create('<input type="text" style="display: block; margin-top: 0.5em;">');t.addClass(this.getClassName("prompt"));t.on("keyup",a.bind(function(v){this.set(e,t.get("value"));},this));this.handleEnter=a.once("enter",a.bind(function(w){var v=this.get(g);if(v){v.fire("press");}},this),t);this.body(t,"after");this.addCloseButton().show();},_getDefaultTitle:function(){return"The page "+location.protocol+"//"+location.host+"/ says:";},_updateDraggable:function(m){var o=this.get("boundingBox"),n=o.all(".yui3-widget-hd");if(m){o.plug(a.Plugin.Drag,{handle:n}).dd.plug(a.Plugin.DDConstrained,{constrain2view:true,gutter:"20"});}else{o.unplug(a.Plugin.Drag).unplug(a.Plugin.DDContrained);}},_setContent:function(o,n,m){this.setStdModContent(o,n,this._standardizePlacement(m));},_standardizePlacement:function(m){var n=(h.isString(m))?m.toLowerCase():null;switch(n){case"prepend":case"before":return a.WidgetStdMod.BEFORE;case"append":case"after":return a.WidgetStdMod.AFTER;default:return a.WidgetStdMod.REPLACE;}}},{ATTRS:{centered:{value:true},callbacks:{value:{}},constrain:{value:true},defaultButton:{validator:function(m){return(m instanceof a.Button);}},draggable:{value:true,validator:h.isBoolean,setter:function(m){this._updateDraggable(m);return m;}},render:{value:true},returnVal:{value:null},icon:{validator:h.isString,setter:function(m){this.get("boundingBox").replaceClass(this.getClassName(b,this.get(b)||"default"),this.getClassName(b,m||"default"));return m;}},visible:{value:false},zIndex:{value:20000}}});},"gallery-2011.03.11-23-49",{requires:["gallery-overlay-extras","gallery-button","overlay","widget-anim","node","gallery-event-nav-keys","dd-plugin"]});
32 build/gallery-dialog/gallery-dialog.js
View
@@ -2,7 +2,7 @@ YUI.add('gallery-dialog', function(Y) {
var YL = Y.Lang,
LABEL_CANCEL = 'Cancel',
- LABEL_OK = 'OK',
+ LABEL_OK = 'OK',
CALLBACK_CANCEL = 'cancel',
CALLBACK_OK = 'ok',
EMPTY_FN = function(){},
@@ -64,7 +64,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
this.handleEscape = Y.once('esc', Y.bind(function(){ this.hide(); }, this), Y.config.doc);
Y.Dialog.superclass.show.apply(this,arguments);
- this.syncUI();
+ this.syncUI();
var dBtn = this.get(ATTR_DEFAULT_BUTTON);
@@ -120,7 +120,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
* @return this
*/
build : function(header, body, buttons) {
-
+
var i, l, btn;
this.purge();
@@ -308,7 +308,7 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
// need to build the input box and bind the events to it
// then append it to the body
promptInput = Y.Node.create('<input type="text" style="display: block; margin-top: 0.5em;">');
- promptInput.addClass(this.getClassName('prompt'));
+ promptInput.addClass(this.getClassName('prompt'));
promptInput.on('keyup', Y.bind(function(e){
this.set(ATTR_RETURN_VAL, promptInput.get('value'));
@@ -390,23 +390,23 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
ATTRS : {
centered : {
- value : true
- },
-
+ value : true
+ },
+
callbacks : {
value : {}
},
-
+
constrain : {
value : true
},
-
+
defaultButton : {
validator : function(val) {
return (val instanceof Y.Button);
}
},
-
+
draggable : {
value : true,
validator : YL.isBoolean,
@@ -415,15 +415,15 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
return val;
}
},
-
+
render : {
value : true
},
-
+
returnVal : {
value : null
},
-
+
icon : {
validator : YL.isString,
setter : function(val) {
@@ -434,11 +434,11 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
return val;
}
},
-
+
visible : {
value : false
},
-
+
zIndex : {
value : 20000
}
@@ -446,4 +446,4 @@ Y.Dialog = Y.Base.create('dialog', Y.Overlay, [], {
});
-}, 'gallery-2011.02.02-21-07' ,{requires:['gallery-overlay-extras','gallery-button','overlay','widget-anim','node','gallery-event-nav-keys','dd-plugin']});
+}, 'gallery-2011.03.11-23-49' ,{requires:['gallery-overlay-extras','gallery-button','overlay','widget-anim','node','gallery-event-nav-keys','dd-plugin']});
79 build/gallery-google-maps-frame/gallery-google-maps-frame-debug.js
View
@@ -0,0 +1,79 @@
+YUI.add('gallery-google-maps-frame', function(Y) {
+
+'use strict';
+
+var _loaded = false,
+
+ _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ container: {
+ writeOnce: 'initOnly'
+ },
+ domNode: {
+ readOnly: true
+ },
+ frame: {
+ readOnly: true
+ },
+ parameters: {
+ writeOnce: 'initOnly'
+ }
+};
+
+_class.NAME = 'GoogleMapsFrame';
+
+Y.extend(_class, Y.Base, {
+ initializer: function () {
+ this.publish('failure');
+ this.publish('load', {
+ fireOnce: true
+ });
+ this.publish('timeout');
+
+ var frame = new Y.Frame({
+ content: '<div id="map"></div>',
+ extracss: 'body, html, #map {height: 100%; width: 100%;}'
+ });
+
+ frame.on('ready', function () {
+ var iY = frame.getInstance(),
+ me = this;
+
+ iY.config.win.YUI = YUI;
+ iY.use('gallery-google-maps-loader', 'node', function (iY) {
+ var googleMapsLoader = iY.GoogleMapsLoader;
+
+ googleMapsLoader.on('failure', function () {
+ this.fire('failure');
+ }, me);
+ googleMapsLoader.on('success', function () {
+ _loaded = true;
+ this.google = iY.config.win.google;
+ this.fire('load');
+ }, me);
+ googleMapsLoader.on('timeout', function () {
+ this.fire('timeout');
+ }, me);
+ googleMapsLoader.load(me.get('parameters'));
+
+ me._set('domNode', iY.Node.getDOMNode(iY.one('#map')));
+ me._set('frame', frame);
+ });
+ }, this);
+
+ frame.render(this.get('container'));
+ },
+ isLoaded: function () {
+ return _loaded;
+ }
+});
+
+Y.GoogleMapsFrame = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base', 'frame', 'gallery-google-maps-loader'], skinnable:false});
1  build/gallery-google-maps-frame/gallery-google-maps-frame-min.js
View
@@ -0,0 +1 @@
+YUI.add("gallery-google-maps-frame",function(c){var b=false,a;a=function(d){a.superclass.constructor.call(this,d);};a.ATTRS={container:{writeOnce:"initOnly"},domNode:{readOnly:true},frame:{readOnly:true},parameters:{writeOnce:"initOnly"}};a.NAME="GoogleMapsFrame";c.extend(a,c.Base,{initializer:function(){this.publish("failure");this.publish("load",{fireOnce:true});this.publish("timeout");var d=new c.Frame({content:'<div id="map"></div>',extracss:"body, html, #map {height: 100%; width: 100%;}"});d.on("ready",function(){var f=d.getInstance(),e=this;f.config.win.YUI=YUI;f.use("gallery-google-maps-loader","node",function(h){var g=h.GoogleMapsLoader;g.on("failure",function(){this.fire("failure");},e);g.on("success",function(){b=true;this.google=h.config.win.google;this.fire("load");},e);g.on("timeout",function(){this.fire("timeout");},e);g.load(e.get("parameters"));e._set("domNode",h.Node.getDOMNode(h.one("#map")));e._set("frame",d);});},this);d.render(this.get("container"));},isLoaded:function(){return b;}});c.GoogleMapsFrame=a;},"gallery-2011.03.11-23-49",{requires:["base","frame","gallery-google-maps-loader"],skinnable:false});
79 build/gallery-google-maps-frame/gallery-google-maps-frame.js
View
@@ -0,0 +1,79 @@
+YUI.add('gallery-google-maps-frame', function(Y) {
+
+'use strict';
+
+var _loaded = false,
+
+ _class;
+
+_class = function (config) {
+ _class.superclass.constructor.call(this, config);
+};
+
+_class.ATTRS = {
+ container: {
+ writeOnce: 'initOnly'
+ },
+ domNode: {
+ readOnly: true
+ },
+ frame: {
+ readOnly: true
+ },
+ parameters: {
+ writeOnce: 'initOnly'
+ }
+};
+
+_class.NAME = 'GoogleMapsFrame';
+
+Y.extend(_class, Y.Base, {
+ initializer: function () {
+ this.publish('failure');
+ this.publish('load', {
+ fireOnce: true
+ });
+ this.publish('timeout');
+
+ var frame = new Y.Frame({
+ content: '<div id="map"></div>',
+ extracss: 'body, html, #map {height: 100%; width: 100%;}'
+ });
+
+ frame.on('ready', function () {
+ var iY = frame.getInstance(),
+ me = this;
+
+ iY.config.win.YUI = YUI;
+ iY.use('gallery-google-maps-loader', 'node', function (iY) {
+ var googleMapsLoader = iY.GoogleMapsLoader;
+
+ googleMapsLoader.on('failure', function () {
+ this.fire('failure');
+ }, me);
+ googleMapsLoader.on('success', function () {
+ _loaded = true;
+ this.google = iY.config.win.google;
+ this.fire('load');
+ }, me);
+ googleMapsLoader.on('timeout', function () {
+ this.fire('timeout');
+ }, me);
+ googleMapsLoader.load(me.get('parameters'));
+
+ me._set('domNode', iY.Node.getDOMNode(iY.one('#map')));
+ me._set('frame', frame);
+ });
+ }, this);
+
+ frame.render(this.get('container'));
+ },
+ isLoaded: function () {
+ return _loaded;
+ }
+});
+
+Y.GoogleMapsFrame = _class;
+
+
+}, 'gallery-2011.03.11-23-49' ,{requires:['base', 'frame', 'gallery-google-maps-loader'], skinnable:false});
134 build/gallery-graphics-canvas/gallery-graphics-canvas-debug.js
View
@@ -404,9 +404,19 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
+ var hiX,
+ hiY,
+ loX,
+ loY;
this._updateDrawingQueue(["bezierCurveTo", cp1x, cp1y, cp2x, cp2y, x, y]);
this._drawingComplete = false;
this._updateShapeProps(x, y);
+ hiX = Math.max(x, Math.max(cp1x, cp2x));
+ hiY = Math.max(y, Math.max(cp1y, cp2y));
+ loX = Math.min(x, Math.min(cp1x, cp2x));
+ loY = Math.min(y, Math.min(cp1y, cp2y));
+ this._updatePosition(hiX, hiY);
+ this._updatePosition(loX, loY);
return this;
},
@@ -419,10 +429,20 @@ Drawing.prototype = {
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
- quadraticCurveTo: function(controlX, controlY, anchorX, anchorY) {
- this._updateDrawingQueue(["quadraticCurveTo", controlX, controlY, anchorX, anchorY]);
+ quadraticCurveTo: function(cpx, cpy, x, y) {
+ var hiX,
+ hiY,
+ loX,
+ loY;
+ this._updateDrawingQueue(["quadraticCurveTo", cpx, cpy, x, y]);
this._drawingComplete = false;
- this._updateShapeProps(anchorX, anchorY);
+ this._updateShapeProps(x, y);
+ hiX = Math.max(x, cpx);
+ hiY = Math.max(y, cpy);
+ loX = Math.min(x, cpx);
+ loY = Math.min(y, cpy);
+ this._updatePosition(hiX, hiY);
+ this._updatePosition(loX, loY);
return this;
},
@@ -1030,7 +1050,6 @@ Y.Drawing = Drawing;
*/
_draw: function()
{
- this.clear();
this._paint();
},
@@ -1050,68 +1069,87 @@ Y.Drawing = Drawing;
w = this.get("width") || this._width,
h = this.get("height") || this._height,
context = this._context,
- methods = this._methods,
+ methods = [],
+ cachedMethods = this._methods.concat(),
i = 0,
- lineToMethods = this._lineToMethods,
- lineToLen = lineToMethods ? lineToMethods.length : 0,
+ j,
method,
args,
- len = methods ? methods.length : 0;
- node.setAttribute("width", w);
- node.setAttribute("height", h);
- if(!len || len < 1)
- {
- return;
- }
- for(; i < lineToLen; ++i)
- {
- args = lineToMethods[i];
- args[1] = args[1] - this._left;
- args[2] = args[2] - this._top;
- }
- context.beginPath();
- for(i = 0; i < len; ++i)
- {
- args = methods[i];
- if(args && args.length > 0)
+ len = 0,
+ right = this._right,
+ left = this._left,
+ top = this._top,
+ bottom = this._bottom;
+ if(this._methods)
+ {
+ len = cachedMethods.length;
+ if(!len || len < 1)
+ {
+ return;
+ }
+ for(; i < len; ++i)
{
- method = args.shift();
- if(method)
+ methods[i] = cachedMethods[i].concat();
+ args = methods[i];
+ for(j = 1; j < args.length; ++j)
{
- if(method && method == "lineTo" && this._dashstyle)
+ if(j % 2 === 0)
{
- args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
- this._drawDashedLine.apply(this, args);
+ args[j] = args[j] - this._top;
}
else
{
- context[method].apply(context, args);
+ args[j] = args[j] - this._left;
+ }
+ }
+ }
+ node.setAttribute("width", w);
+ node.setAttribute("height", h);
+ context.beginPath();
+ for(i = 0; i < len; ++i)
+ {
+ args = methods[i];
+ if(args && args.length > 0)
+ {
+ method = args.shift();
+ if(method)
+ {
+ if(method && method == "lineTo" && this._dashstyle)
+ {
+ args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
+ this._drawDashedLine.apply(this, args);
+ }
+ else
+ {
+ context[method].apply(context, args);
+ }
}
}
}
- }
- if (this._fillType) {
- context.fillStyle = this._fillColor;
- context.closePath();
- }
+ if (this._fillType) {
+ context.fillStyle = this._fillColor;
+ context.closePath();
+ }
- if (this._fillType) {
- context.fill();
- }
+ if (this._fillType) {
+ context.fill();
+ }
- if (this._stroke) {
- if(this._strokeWeight)
- {
- context.lineWidth = this._strokeWeight;
+ if (this._stroke) {
+ if(this._strokeWeight)
+ {
+ context.lineWidth = this._strokeWeight;
+ }
+ context.strokeStyle = this._strokeStyle;
+ context.stroke();
}
- context.strokeStyle = this._strokeStyle;
- context.stroke();
+ this._drawingComplete = true;
+ this._clearAndUpdateCoords();
+ this._updateNodePosition();
+ this._methods = cachedMethods;
}
- this._drawingComplete = true;
- this._clearAndUpdateCoords();
- this._updateNodePosition();
},
/**
6 build/gallery-graphics-canvas/gallery-graphics-canvas-min.js
View
@@ -1,3 +1,3 @@
-YUI.add("gallery-graphics-canvas",function(e){function d(f){this.initializer.apply(this,arguments);}d.prototype={autoSize:true,initializer:function(g){g=g||{};var f=g.width||0,i=g.height||0;this.node=e.config.doc.createElement("div");this.setSize(f,i);if(g.render){this.render(g.render);}},setSize:function(f,g){if(this.autoSize){if(f>this.node.getAttribute("width")){this.node.style.width=f+"px";this.node.setAttribute("width",f);}if(g>this.node.getAttribute("height")){this.node.style.height=g+"px";this.node.setAttribute("height",g);}}},_trackSize:function(f,g){if(f>this._width){this._width=f;}if(g>this._height){this._height=g;}this.setSize(f,g);},setPosition:function(f,g){this.node.style.left=f+"px";this.node.style.top=g+"px";},render:function(j){var k=this.node,f=e.one(j),g=f.get("width")||f.get("offsetWidth"),i=f.get("height")||f.get("offsetHeight");k.style.display="block";k.style.position="absolute";k.style.left=e.one(k).getStyle("left");k.style.top=e.one(k).getStyle("top");k.style.pointerEvents="visiblePainted";f=f||e.config.doc.body;f.appendChild(this.node);this.setSize(g,i);return this;},toggleVisible:function(f){this.node.style.visibility=f?"visible":"hidden";},addShape:function(f){var g=f.get("node");this.node.appendChild(g);if(!this._graphicsList){this._graphicsList=[];}this._graphicsList.push(g);},destroy:function(){this._removeChildren(this.node);if(this.node&&this.node.parentNode){this.node.parentNode.removeChild(this.node);}},_removeChildren:function(f){if(f.hasChildNodes()){var g;while(f.firstChild){g=f.firstChild;this._removeChildren(g);f.removeChild(g);}}}};e.Graphic=d;var b;function c(){if(!b){b=e.config.doc.createElement("div");}b.style.height=0;b.style.width=0;b.style.overflow="hidden";e.config.doc.documentElement.appendChild(b);return b;}function a(){}a.prototype={_reHex:/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,_2RGBA:function(g,f){f=(f!==undefined)?f:1;if(this._reHex.exec(g)){g="rgba("+[parseInt(RegExp.$1,16),parseInt(RegExp.$2,16),parseInt(RegExp.$3,16)].join(",")+","+f+")";}return g;},_2RGB:function(g){var f=c();f.style.background=g;return f.style.backgroundColor;},setSize:function(f,g){if(this.get("autoSize")){if(f>this.node.getAttribute("width")){this.node.style.width=f+"px";this.node.setAttribute("width",f);}if(g>this.node.getAttribute("height")){this.node.style.height=g+"px";this.node.setAttribute("height",g);}}},_updatePosition:function(f,g){this._updateCoords(f,g);if(f<=this._left){this._left=f;}else{if(f>=this._right){this._right=f;}}if(g<=this._top){this._top=g;}else{if(g>=this._bottom){this._bottom=g;}}this._width=this._right-this._left;this._height=this._bottom-this._top;},_updateCoords:function(f,g){this._xcoords.push(f);this._ycoords.push(g);},_clearAndUpdateCoords:function(){var f=this._xcoords.pop()||0,g=this._ycoords.pop()||0;this._updateCoords(f,g);},_updateNodePosition:function(){var g=this.get("node"),f=this.get("x"),h=this.get("y");g.style.position="absolute";g.style.left=(f+this._left)+"px";g.style.top=(h+this._top)+"px";},_methods:null,_properties:null,_updateDrawingQueue:function(f){if(!this._methods){this._methods=[];}this._methods.push(f);},lineTo:function(l,k,h){var g=arguments,j,f;if(!this._lineToMethods){this._lineToMethods=[];}if(typeof l==="string"||typeof l==="number"){g=[[l,k]];}for(j=0,f=g.length;j<f;++j){this._updateDrawingQueue(["lineTo",g[j][0],g[j][1]]);this._lineToMethods[this._lineToMethods.length]=this._methods[this._methods.length-1];this._updateShapeProps.apply(this,g[j]);this._updatePosition(g[j][0],g[j][1]);}this._drawingComplete=false;return this;},moveTo:function(f,g){this._updateDrawingQueue(["moveTo",f,g]);this._updateShapeProps(f,g);this._updatePosition(f,g);this._drawingComplete=false;return this;},curveTo:function(h,g,j,i,f,k){this._updateDrawingQueue(["bezierCurveTo",h,g,j,i,f,k]);this._drawingComplete=false;this._updateShapeProps(f,k);return this;},quadraticCurveTo:function(h,g,f,i){this._updateDrawingQueue(["quadraticCurveTo",h,g,f,i]);this._drawingComplete=false;this._updateShapeProps(f,i);return this;},drawCircle:function(g,k,f){var i=0,h=2*Math.PI,j=f*2;this._shape={x:g,y:k,w:j,h:j};this._drawingComplete=false;this._updatePosition(g+j,k+j);this._updateDrawingQueue(["arc",g+f,k+f,f,i,h,false]);return this;},drawEllipse:function(s,q,t,B){this._shape={x:s,y:q,w:t,h:B};if(this._stroke&&this._strokeWeight>0){t-=this._strokeWeight*2;B-=this._strokeWeight*2;s+=this._strokeWeight;q+=this._strokeWeight;}var v=8,n=-(45/180)*Math.PI,D=0,m,j=t/2,k=B/2,z=0,p=s+j,o=q+k,u,r,C,A,g,f;u=p+Math.cos(0)*j;r=o+Math.sin(0)*k;this.moveTo(u,r);for(;z<v;z++){D+=n;m=D-(n/2);C=p+Math.cos(D)*j;A=o+Math.sin(D)*k;g=p+Math.cos(m)*(j/Math.cos(n/2));f=o+Math.sin(m)*(k/Math.cos(n/2));this.quadraticCurveTo(g,f,C,A);}this._trackPos(s,q);this._trackSize(s+t,q+B);return this;},drawRect:function(f,j,g,i){this._shape={x:f,y:j,w:g,h:i};this._drawingComplete=false;this.moveTo(f,j);this.lineTo(f+g,j);this.lineTo(f+g,j+i);this.lineTo(f,j+i);this.lineTo(f,j);return this;},drawRoundRect:function(f,l,g,j,i,k){this._shape={x:f,y:l,w:g,h:j};this._drawingComplete=false;this._updateDrawingQueue(["moveTo",f,l+k]);this._updateDrawingQueue(["lineTo",f,l+j-k]);this._updateDrawingQueue(["quadraticCurveTo",f,l+j,f+i,l+j]);this._updateDrawingQueue(["lineTo",f+g-i,l+j]);this._updateDrawingQueue(["quadraticCurveTo",f+g,l+j,f+g,l+j-k]);this._updateDrawingQueue(["lineTo",f+g,l+k]);this._updateDrawingQueue(["quadraticCurveTo",f+g,l,f+g-i,l]);this._updateDrawingQueue(["lineTo",f+i,l]);this._updateDrawingQueue(["quadraticCurveTo",f,l,f,l+k]);this._trackPos(f,l);this._trackSize(g,j);this._paint();return this;},drawWedge:function(j){var q=j.x,o=j.y,u=j.startAngle,n=j.arc,h=j.radius,k=j.yRadius,t,s,m,A,l,r,p,z,w,g,f,v=0;this._drawingComplete=false;this._updateRenderQueue(["moveTo",q,o]);k=k||h;if(Math.abs(n)>360){n=360;}t=Math.ceil(Math.abs(n)/45);s=n/t;m=-(s/180)*Math.PI;A=-(u/180)*Math.PI;if(t>0){r=q+Math.cos(u/180*Math.PI)*h;p=o+Math.sin(-u/180*Math.PI)*k;this.lineTo(r,p);
-for(;v<t;++v){A+=m;l=A-(m/2);z=q+Math.cos(A)*h;w=o+Math.sin(A)*k;g=q+Math.cos(l)*(h/Math.cos(m/2));f=o+Math.sin(l)*(k/Math.cos(m/2));this._updateRenderQueue(["quadraticCurveTo",g,f,z,w]);}this._updateRenderQueue(["lineTo",q,o]);}this._trackPos(q,o);this._trackSize(h,h);this._paint();},end:function(){this._paint();return this;},_initProps:function(){var f=this._context;this._methods=[];this._lineToMethods=[];this._xcoords=[0];this._ycoords=[0];this._width=0;this._height=0;this._left=0;this._top=0;this._right=0;this._bottom=0;this._x=0;this._y=0;},_drawingComplete:false,_createGraphic:function(f){var g=e.config.doc.createElement("canvas");return g;},_trackSize:function(f,g){if(f>this._width){this._width=f;}if(g>this._height){this._height=g;}},_trackPos:function(f,g){if(f>this._x){this._x=f;}if(g>this._y){this._y=g;}},_updateShapeProps:function(f,j){var g,i;if(!this._shape){this._shape={};}if(!this._shape.x){this._shape.x=f;}else{this._shape.x=Math.min(this._shape.x,f);}if(!this._shape.y){this._shape.y=j;}else{this._shape.y=Math.min(this._shape.y,j);}g=Math.abs(f-this._shape.x);if(!this._shape.w){this._shape.w=g;}else{this._shape.w=Math.max(g,this._shape.w);}i=Math.abs(j-this._shape.y);if(!this._shape.h){this._shape.h=i;}else{this._shape.h=Math.max(i,this._shape.h);}}};e.Drawing=a;e.Shape=e.Base.create("shape",e.Base,[e.Drawing],{_left:0,_right:0,_top:0,_bottom:0,initializer:function(){this._xcoords=[0];this._ycoords=[0];this.get("stroke");this.get("fill");this._addListeners();var f=this.get("node");f.setAttribute("width",this.get("width"));f.setAttribute("height",this.get("height"));this._draw();},_getNode:function(){var f=e.config.doc.createElement("canvas");this._context=f.getContext("2d");return f;},_addListeners:function(){this.after("strokeChange",this._updateHandler);this.after("fillChange",this._updateHandler);this.after("widthChange",this._updateHandler);this.after("heightChange",this._updateHandler);},_setStrokeProps:function(j){var g=j.color,h=j.weight,i=j.alpha,f=j.dashstyle;this._dashstyle=(f&&e.Lang.isArray(f)&&f.length>1)?f:null;this._strokeWeight=h;if(h){this._stroke=1;}else{this._stroke=0;}if(i){this._strokeStyle=this._2RGBA(g,i);}else{this._strokeStyle=g;}},_setFillProps:function(h){var f=h.color,g=h.alpha;if(f){if(g){f=this._2RGBA(f,g);}else{f=this._2RGB(f);}this._fillColor=f;this._fillType="solid";}else{this._fillColor=null;}},translate:function(f,i){var g=this.get("node"),h="translate("+f+"px, "+i+"px)";this._updateTransform("translate",/translate\(.*\)/,h);},skewX:function(f){},skewY:function(f){},rotate:function(g,h){var f="rotate("+g+"deg)";this._updateTransform("rotate",/rotate\(.*\)/,f);},scale:function(f){},matrix:function(h,g,l,k,j,i){},_updateTransform:function(g,j,i){var h=this.get("node"),f=h.style.MozTransform||h.style.webkitTransform||h.style.msTransform||h.style.OTransform;if(f&&f.length>0){if(f.indexOf(g)>-1){f=f.replace(j,i);}else{f+=" "+i;}}else{f=i;}h.style.MozTransform=f;h.style.webkitTransform=f;h.style.msTransform=f;h.style.OTransform=f;},_updateHandler:function(f){this._draw();},_draw:function(){this.clear();this._paint();},_paint:function(){if(!this._methods){return;}var j=this.get("node"),q=this.get("width")||this._width,m=this.get("height")||this._height,g=this._context,k=this._methods,l=0,p=this._lineToMethods,r=p?p.length:0,f,o,n=k?k.length:0;j.setAttribute("width",q);j.setAttribute("height",m);if(!n||n<1){return;}for(;l<r;++l){o=p[l];o[1]=o[1]-this._left;o[2]=o[2]-this._top;}g.beginPath();for(l=0;l<n;++l){o=k[l];if(o&&o.length>0){f=o.shift();if(f){if(f&&f=="lineTo"&&this._dashstyle){o.unshift(this._xcoords[l]-this._left,this._ycoords[l]-this._top);this._drawDashedLine.apply(this,o);}else{g[f].apply(g,o);}}}}if(this._fillType){g.fillStyle=this._fillColor;g.closePath();}if(this._fillType){g.fill();}if(this._stroke){if(this._strokeWeight){g.lineWidth=this._strokeWeight;}g.strokeStyle=this._strokeStyle;g.stroke();}this._drawingComplete=true;this._clearAndUpdateCoords();this._updateNodePosition();},_drawDashedLine:function(p,v,f,s){var g=this._context,t=this._dashstyle[0],r=this._dashstyle[1],j=t+r,m=f-p,q=s-v,u=Math.sqrt(Math.pow(m,2)+Math.pow(q,2)),k=Math.floor(Math.abs(u/j)),h=Math.atan2(q,m),o=p,n=v,l;m=Math.cos(h)*j;q=Math.sin(h)*j;for(l=0;l<k;++l){g.moveTo(o,n);g.lineTo(o+Math.cos(h)*t,n+Math.sin(h)*t);o+=m;n+=q;}g.moveTo(o,n);u=Math.sqrt((f-o)*(f-o)+(s-n)*(s-n));if(u>t){g.lineTo(o+Math.cos(h)*t,n+Math.sin(h)*t);}else{if(u>0){g.lineTo(o+Math.cos(h)*u,n+Math.sin(h)*u);}}g.moveTo(f,s);},clear:function(){var f=this.get("width"),g=this.get("height");this._initProps();this._context.clearRect(0,0,f,g);return this;}},{ATTRS:{node:{readOnly:true,valueFn:"_getNode"},width:{},height:{},x:{value:0,setter:function(g){var f=this.get("node");f.style.left=(g+this._left)+"px";return g;}},y:{value:0,setter:function(g){var f=this.get("node");f.style.top=(g+this._top)+"px";return g;}},visible:{value:true,setter:function(g){var f=g?"visible":"hidden";this.get("node").style.visibility=f;return g;}},fill:{setter:function(g){var f=this.get("fill")||this._getAttrCfg("fill").defaultValue;g=(g)?e.merge(f,g):null;this._setFillProps(g);return g;}},stroke:{valueFn:function(){return{weight:1,dashstyle:null,color:"#000",alpha:1};},setter:function(g){var f=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;g=(g)?e.merge(f,g):null;this._setStrokeProps(g);return g;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"}}});e.Path=e.Base.create("path",e.Shape,[],{_type:"path",_addListeners:function(){},_draw:function(){this._paint();},end:function(){this._draw();}},{ATTRS:{width:{getter:function(){return this._width;},setter:function(f){this._width=f;return f;}},height:{getter:function(){return this._height;},setter:function(f){this._height=f;return f;}},path:{getter:function(){return this._path;},setter:function(f){this._path=f;return f;}}}});e.Rect=e.Base.create("rect",e.Shape,[],{_type:"rect",_draw:function(){var f=this.get("x"),l=this.get("y"),g=this.get("width"),i=this.get("height"),k=this.get("fill"),j=this.get("stroke");
-this.drawRect(f,l,g,i);this._paint();}});e.Ellipse=e.Base.create("ellipse",e.Shape,[],{_type:"ellipse",_draw:function(){var f=this.get("width"),g=this.get("height"),j=this.get("fill"),i=this.get("stroke");this.drawEllipse(0,0,f,g);this._paint();}});e.Circle=e.Base.create("circle",e.Base,[e.Shape],{_type:"circle",_draw:function(){var f=this.get("radius"),h=this.get("fill"),g=this.get("stroke");if(f){this.drawCircle(0,0,f);this._paint();}},_addListeners:function(){this.after("radiusChange",this._updateHandler);e.Shape.prototype._addListeners.apply(this,arguments);}},{ATTRS:{width:{readOnly:true,getter:function(){return this.get("radius")*2;}},height:{readOnly:true,getter:function(){return this.get("radius")*2;}},radius:{lazyAdd:false,setter:function(h){var f=this.get("node"),g=h*2;f.setAttribute("width",g);f.setAttribute("height",g);return h;}}}});},"@VERSION@",{requires:["graphics"],skinnable:false});
+YUI.add("gallery-graphics-canvas",function(e){function d(f){this.initializer.apply(this,arguments);}d.prototype={autoSize:true,initializer:function(g){g=g||{};var f=g.width||0,i=g.height||0;this.node=e.config.doc.createElement("div");this.setSize(f,i);if(g.render){this.render(g.render);}},setSize:function(f,g){if(this.autoSize){if(f>this.node.getAttribute("width")){this.node.style.width=f+"px";this.node.setAttribute("width",f);}if(g>this.node.getAttribute("height")){this.node.style.height=g+"px";this.node.setAttribute("height",g);}}},_trackSize:function(f,g){if(f>this._width){this._width=f;}if(g>this._height){this._height=g;}this.setSize(f,g);},setPosition:function(f,g){this.node.style.left=f+"px";this.node.style.top=g+"px";},render:function(j){var k=this.node,f=e.one(j),g=f.get("width")||f.get("offsetWidth"),i=f.get("height")||f.get("offsetHeight");k.style.display="block";k.style.position="absolute";k.style.left=e.one(k).getStyle("left");k.style.top=e.one(k).getStyle("top");k.style.pointerEvents="visiblePainted";f=f||e.config.doc.body;f.appendChild(this.node);this.setSize(g,i);return this;},toggleVisible:function(f){this.node.style.visibility=f?"visible":"hidden";},addShape:function(f){var g=f.get("node");this.node.appendChild(g);if(!this._graphicsList){this._graphicsList=[];}this._graphicsList.push(g);},destroy:function(){this._removeChildren(this.node);if(this.node&&this.node.parentNode){this.node.parentNode.removeChild(this.node);}},_removeChildren:function(f){if(f.hasChildNodes()){var g;while(f.firstChild){g=f.firstChild;this._removeChildren(g);f.removeChild(g);}}}};e.Graphic=d;var b;function c(){if(!b){b=e.config.doc.createElement("div");}b.style.height=0;b.style.width=0;b.style.overflow="hidden";e.config.doc.documentElement.appendChild(b);return b;}function a(){}a.prototype={_reHex:/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,_2RGBA:function(g,f){f=(f!==undefined)?f:1;if(this._reHex.exec(g)){g="rgba("+[parseInt(RegExp.$1,16),parseInt(RegExp.$2,16),parseInt(RegExp.$3,16)].join(",")+","+f+")";}return g;},_2RGB:function(g){var f=c();f.style.background=g;return f.style.backgroundColor;},setSize:function(f,g){if(this.get("autoSize")){if(f>this.node.getAttribute("width")){this.node.style.width=f+"px";this.node.setAttribute("width",f);}if(g>this.node.getAttribute("height")){this.node.style.height=g+"px";this.node.setAttribute("height",g);}}},_updatePosition:function(f,g){this._updateCoords(f,g);if(f<=this._left){this._left=f;}else{if(f>=this._right){this._right=f;}}if(g<=this._top){this._top=g;}else{if(g>=this._bottom){this._bottom=g;}}this._width=this._right-this._left;this._height=this._bottom-this._top;},_updateCoords:function(f,g){this._xcoords.push(f);this._ycoords.push(g);},_clearAndUpdateCoords:function(){var f=this._xcoords.pop()||0,g=this._ycoords.pop()||0;this._updateCoords(f,g);},_updateNodePosition:function(){var g=this.get("node"),f=this.get("x"),h=this.get("y");g.style.position="absolute";g.style.left=(f+this._left)+"px";g.style.top=(h+this._top)+"px";},_methods:null,_properties:null,_updateDrawingQueue:function(f){if(!this._methods){this._methods=[];}this._methods.push(f);},lineTo:function(l,k,h){var g=arguments,j,f;if(!this._lineToMethods){this._lineToMethods=[];}if(typeof l==="string"||typeof l==="number"){g=[[l,k]];}for(j=0,f=g.length;j<f;++j){this._updateDrawingQueue(["lineTo",g[j][0],g[j][1]]);this._lineToMethods[this._lineToMethods.length]=this._methods[this._methods.length-1];this._updateShapeProps.apply(this,g[j]);this._updatePosition(g[j][0],g[j][1]);}this._drawingComplete=false;return this;},moveTo:function(f,g){this._updateDrawingQueue(["moveTo",f,g]);this._updateShapeProps(f,g);this._updatePosition(f,g);this._drawingComplete=false;return this;},curveTo:function(i,g,n,m,l,k){var j,h,f,o;this._updateDrawingQueue(["bezierCurveTo",i,g,n,m,l,k]);this._drawingComplete=false;this._updateShapeProps(l,k);j=Math.max(l,Math.max(i,n));h=Math.max(k,Math.max(g,m));f=Math.min(l,Math.min(i,n));o=Math.min(k,Math.min(g,m));this._updatePosition(j,h);this._updatePosition(f,o);return this;},quadraticCurveTo:function(j,i,f,m){var h,g,l,k;this._updateDrawingQueue(["quadraticCurveTo",j,i,f,m]);this._drawingComplete=false;this._updateShapeProps(f,m);h=Math.max(f,j);g=Math.max(m,i);l=Math.min(f,j);k=Math.min(m,i);this._updatePosition(h,g);this._updatePosition(l,k);return this;},drawCircle:function(g,k,f){var i=0,h=2*Math.PI,j=f*2;this._shape={x:g,y:k,w:j,h:j};this._drawingComplete=false;this._updatePosition(g+j,k+j);this._updateDrawingQueue(["arc",g+f,k+f,f,i,h,false]);return this;},drawEllipse:function(s,q,t,B){this._shape={x:s,y:q,w:t,h:B};if(this._stroke&&this._strokeWeight>0){t-=this._strokeWeight*2;B-=this._strokeWeight*2;s+=this._strokeWeight;q+=this._strokeWeight;}var v=8,n=-(45/180)*Math.PI,D=0,m,j=t/2,k=B/2,z=0,p=s+j,o=q+k,u,r,C,A,g,f;u=p+Math.cos(0)*j;r=o+Math.sin(0)*k;this.moveTo(u,r);for(;z<v;z++){D+=n;m=D-(n/2);C=p+Math.cos(D)*j;A=o+Math.sin(D)*k;g=p+Math.cos(m)*(j/Math.cos(n/2));f=o+Math.sin(m)*(k/Math.cos(n/2));this.quadraticCurveTo(g,f,C,A);}this._trackPos(s,q);this._trackSize(s+t,q+B);return this;},drawRect:function(f,j,g,i){this._shape={x:f,y:j,w:g,h:i};this._drawingComplete=false;this.moveTo(f,j);this.lineTo(f+g,j);this.lineTo(f+g,j+i);this.lineTo(f,j+i);this.lineTo(f,j);return this;},drawRoundRect:function(f,l,g,j,i,k){this._shape={x:f,y:l,w:g,h:j};this._drawingComplete=false;this._updateDrawingQueue(["moveTo",f,l+k]);this._updateDrawingQueue(["lineTo",f,l+j-k]);this._updateDrawingQueue(["quadraticCurveTo",f,l+j,f+i,l+j]);this._updateDrawingQueue(["lineTo",f+g-i,l+j]);this._updateDrawingQueue(["quadraticCurveTo",f+g,l+j,f+g,l+j-k]);this._updateDrawingQueue(["lineTo",f+g,l+k]);this._updateDrawingQueue(["quadraticCurveTo",f+g,l,f+g-i,l]);this._updateDrawingQueue(["lineTo",f+i,l]);this._updateDrawingQueue(["quadraticCurveTo",f,l,f,l+k]);this._trackPos(f,l);this._trackSize(g,j);this._paint();return this;},drawWedge:function(j){var q=j.x,o=j.y,u=j.startAngle,n=j.arc,h=j.radius,k=j.yRadius,t,s,m,A,l,r,p,z,w,g,f,v=0;
+this._drawingComplete=false;this._updateRenderQueue(["moveTo",q,o]);k=k||h;if(Math.abs(n)>360){n=360;}t=Math.ceil(Math.abs(n)/45);s=n/t;m=-(s/180)*Math.PI;A=-(u/180)*Math.PI;if(t>0){r=q+Math.cos(u/180*Math.PI)*h;p=o+Math.sin(-u/180*Math.PI)*k;this.lineTo(r,p);for(;v<t;++v){A+=m;l=A-(m/2);z=q+Math.cos(A)*h;w=o+Math.sin(A)*k;g=q+Math.cos(l)*(h/Math.cos(m/2));f=o+Math.sin(l)*(k/Math.cos(m/2));this._updateRenderQueue(["quadraticCurveTo",g,f,z,w]);}this._updateRenderQueue(["lineTo",q,o]);}this._trackPos(q,o);this._trackSize(h,h);this._paint();},end:function(){this._paint();return this;},_initProps:function(){var f=this._context;this._methods=[];this._lineToMethods=[];this._xcoords=[0];this._ycoords=[0];this._width=0;this._height=0;this._left=0;this._top=0;this._right=0;this._bottom=0;this._x=0;this._y=0;},_drawingComplete:false,_createGraphic:function(f){var g=e.config.doc.createElement("canvas");return g;},_trackSize:function(f,g){if(f>this._width){this._width=f;}if(g>this._height){this._height=g;}},_trackPos:function(f,g){if(f>this._x){this._x=f;}if(g>this._y){this._y=g;}},_updateShapeProps:function(f,j){var g,i;if(!this._shape){this._shape={};}if(!this._shape.x){this._shape.x=f;}else{this._shape.x=Math.min(this._shape.x,f);}if(!this._shape.y){this._shape.y=j;}else{this._shape.y=Math.min(this._shape.y,j);}g=Math.abs(f-this._shape.x);if(!this._shape.w){this._shape.w=g;}else{this._shape.w=Math.max(g,this._shape.w);}i=Math.abs(j-this._shape.y);if(!this._shape.h){this._shape.h=i;}else{this._shape.h=Math.max(i,this._shape.h);}}};e.Drawing=a;e.Shape=e.Base.create("shape",e.Base,[e.Drawing],{_left:0,_right:0,_top:0,_bottom:0,initializer:function(){this._xcoords=[0];this._ycoords=[0];this.get("stroke");this.get("fill");this._addListeners();var f=this.get("node");f.setAttribute("width",this.get("width"));f.setAttribute("height",this.get("height"));this._draw();},_getNode:function(){var f=e.config.doc.createElement("canvas");this._context=f.getContext("2d");return f;},_addListeners:function(){this.after("strokeChange",this._updateHandler);this.after("fillChange",this._updateHandler);this.after("widthChange",this._updateHandler);this.after("heightChange",this._updateHandler);},_setStrokeProps:function(j){var g=j.color,h=j.weight,i=j.alpha,f=j.dashstyle;this._dashstyle=(f&&e.Lang.isArray(f)&&f.length>1)?f:null;this._strokeWeight=h;if(h){this._stroke=1;}else{this._stroke=0;}if(i){this._strokeStyle=this._2RGBA(g,i);}else{this._strokeStyle=g;}},_setFillProps:function(h){var f=h.color,g=h.alpha;if(f){if(g){f=this._2RGBA(f,g);}else{f=this._2RGB(f);}this._fillColor=f;this._fillType="solid";}else{this._fillColor=null;}},translate:function(f,i){var g=this.get("node"),h="translate("+f+"px, "+i+"px)";this._updateTransform("translate",/translate\(.*\)/,h);},skewX:function(f){},skewY:function(f){},rotate:function(g,h){var f="rotate("+g+"deg)";this._updateTransform("rotate",/rotate\(.*\)/,f);},scale:function(f){},matrix:function(h,g,l,k,j,i){},_updateTransform:function(g,j,i){var h=this.get("node"),f=h.style.MozTransform||h.style.webkitTransform||h.style.msTransform||h.style.OTransform;if(f&&f.length>0){if(f.indexOf(g)>-1){f=f.replace(j,i);}else{f+=" "+i;}}else{f=i;}h.style.MozTransform=f;h.style.webkitTransform=f;h.style.msTransform=f;h.style.OTransform=f;},_updateHandler:function(f){this._draw();},_draw:function(){this._paint();},_paint:function(){if(!this._methods){return;}var n=this.get("node"),v=this.get("width")||this._width,r=this.get("height")||this._height,k=this._context,o=[],l=this._methods.concat(),q=0,p,g,t,s=0,x=this._right,m=this._left,u=this._top,f=this._bottom;if(this._methods){s=l.length;if(!s||s<1){return;}for(;q<s;++q){o[q]=l[q].concat();t=o[q];for(p=1;p<t.length;++p){if(p%2===0){t[p]=t[p]-this._top;}else{t[p]=t[p]-this._left;}}}n.setAttribute("width",v);n.setAttribute("height",r);k.beginPath();for(q=0;q<s;++q){t=o[q];if(t&&t.length>0){g=t.shift();if(g){if(g&&g=="lineTo"&&this._dashstyle){t.unshift(this._xcoords[q]-this._left,this._ycoords[q]-this._top);this._drawDashedLine.apply(this,t);}else{k[g].apply(k,t);}}}}if(this._fillType){k.fillStyle=this._fillColor;k.closePath();}if(this._fillType){k.fill();}if(this._stroke){if(this._strokeWeight){k.lineWidth=this._strokeWeight;}k.strokeStyle=this._strokeStyle;k.stroke();}this._drawingComplete=true;this._clearAndUpdateCoords();this._updateNodePosition();this._methods=l;}},_drawDashedLine:function(p,v,f,s){var g=this._context,t=this._dashstyle[0],r=this._dashstyle[1],j=t+r,m=f-p,q=s-v,u=Math.sqrt(Math.pow(m,2)+Math.pow(q,2)),k=Math.floor(Math.abs(u/j)),h=Math.atan2(q,m),o=p,n=v,l;m=Math.cos(h)*j;q=Math.sin(h)*j;for(l=0;l<k;++l){g.moveTo(o,n);g.lineTo(o+Math.cos(h)*t,n+Math.sin(h)*t);o+=m;n+=q;}g.moveTo(o,n);u=Math.sqrt((f-o)*(f-o)+(s-n)*(s-n));if(u>t){g.lineTo(o+Math.cos(h)*t,n+Math.sin(h)*t);}else{if(u>0){g.lineTo(o+Math.cos(h)*u,n+Math.sin(h)*u);}}g.moveTo(f,s);},clear:function(){var f=this.get("width"),g=this.get("height");this._initProps();this._context.clearRect(0,0,f,g);return this;}},{ATTRS:{node:{readOnly:true,valueFn:"_getNode"},width:{},height:{},x:{value:0,setter:function(g){var f=this.get("node");f.style.left=(g+this._left)+"px";return g;}},y:{value:0,setter:function(g){var f=this.get("node");f.style.top=(g+this._top)+"px";return g;}},visible:{value:true,setter:function(g){var f=g?"visible":"hidden";this.get("node").style.visibility=f;return g;}},fill:{setter:function(g){var f=this.get("fill")||this._getAttrCfg("fill").defaultValue;g=(g)?e.merge(f,g):null;this._setFillProps(g);return g;}},stroke:{valueFn:function(){return{weight:1,dashstyle:null,color:"#000",alpha:1};},setter:function(g){var f=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;g=(g)?e.merge(f,g):null;this._setStrokeProps(g);return g;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"}}});e.Path=e.Base.create("path",e.Shape,[],{_type:"path",_addListeners:function(){},_draw:function(){this._paint();},end:function(){this._draw();}},{ATTRS:{width:{getter:function(){return this._width;
+},setter:function(f){this._width=f;return f;}},height:{getter:function(){return this._height;},setter:function(f){this._height=f;return f;}},path:{getter:function(){return this._path;},setter:function(f){this._path=f;return f;}}}});e.Rect=e.Base.create("rect",e.Shape,[],{_type:"rect",_draw:function(){var f=this.get("x"),l=this.get("y"),g=this.get("width"),i=this.get("height"),k=this.get("fill"),j=this.get("stroke");this.drawRect(f,l,g,i);this._paint();}});e.Ellipse=e.Base.create("ellipse",e.Shape,[],{_type:"ellipse",_draw:function(){var f=this.get("width"),g=this.get("height"),j=this.get("fill"),i=this.get("stroke");this.drawEllipse(0,0,f,g);this._paint();}});e.Circle=e.Base.create("circle",e.Base,[e.Shape],{_type:"circle",_draw:function(){var f=this.get("radius"),h=this.get("fill"),g=this.get("stroke");if(f){this.drawCircle(0,0,f);this._paint();}},_addListeners:function(){this.after("radiusChange",this._updateHandler);e.Shape.prototype._addListeners.apply(this,arguments);}},{ATTRS:{width:{readOnly:true,getter:function(){return this.get("radius")*2;}},height:{readOnly:true,getter:function(){return this.get("radius")*2;}},radius:{lazyAdd:false,setter:function(h){var f=this.get("node"),g=h*2;f.setAttribute("width",g);f.setAttribute("height",g);return h;}}}});},"@VERSION@",{requires:["graphics"],skinnable:false});
134 build/gallery-graphics-canvas/gallery-graphics-canvas.js
View
@@ -404,9 +404,19 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
+ var hiX,
+ hiY,
+ loX,
+ loY;
this._updateDrawingQueue(["bezierCurveTo", cp1x, cp1y, cp2x, cp2y, x, y]);
this._drawingComplete = false;
this._updateShapeProps(x, y);
+ hiX = Math.max(x, Math.max(cp1x, cp2x));
+ hiY = Math.max(y, Math.max(cp1y, cp2y));
+ loX = Math.min(x, Math.min(cp1x, cp2x));
+ loY = Math.min(y, Math.min(cp1y, cp2y));
+ this._updatePosition(hiX, hiY);
+ this._updatePosition(loX, loY);
return this;
},
@@ -419,10 +429,20 @@ Drawing.prototype = {
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
- quadraticCurveTo: function(controlX, controlY, anchorX, anchorY) {
- this._updateDrawingQueue(["quadraticCurveTo", controlX, controlY, anchorX, anchorY]);
+ quadraticCurveTo: function(cpx, cpy, x, y) {
+ var hiX,
+ hiY,
+ loX,
+ loY;
+ this._updateDrawingQueue(["quadraticCurveTo", cpx, cpy, x, y]);
this._drawingComplete = false;
- this._updateShapeProps(anchorX, anchorY);
+ this._updateShapeProps(x, y);
+ hiX = Math.max(x, cpx);
+ hiY = Math.max(y, cpy);
+ loX = Math.min(x, cpx);
+ loY = Math.min(y, cpy);
+ this._updatePosition(hiX, hiY);
+ this._updatePosition(loX, loY);
return this;
},
@@ -1030,7 +1050,6 @@ Y.Drawing = Drawing;
*/
_draw: function()
{
- this.clear();
this._paint();
},
@@ -1050,68 +1069,87 @@ Y.Drawing = Drawing;
w = this.get("width") || this._width,
h = this.get("height") || this._height,
context = this._context,
- methods = this._methods,
+ methods = [],
+ cachedMethods = this._methods.concat(),
i = 0,
- lineToMethods = this._lineToMethods,
- lineToLen = lineToMethods ? lineToMethods.length : 0,
+ j,
method,
args,
- len = methods ? methods.length : 0;
- node.setAttribute("width", w);
- node.setAttribute("height", h);
- if(!len || len < 1)
- {
- return;
- }
- for(; i < lineToLen; ++i)
- {
- args = lineToMethods[i];
- args[1] = args[1] - this._left;
- args[2] = args[2] - this._top;
- }
- context.beginPath();
- for(i = 0; i < len; ++i)
- {
- args = methods[i];
- if(args && args.length > 0)
+ len = 0,
+ right = this._right,
+ left = this._left,
+ top = this._top,
+ bottom = this._bottom;
+ if(this._methods)
+ {
+ len = cachedMethods.length;
+ if(!len || len < 1)
+ {
+ return;
+ }
+ for(; i < len; ++i)
{
- method = args.shift();
- if(method)
+ methods[i] = cachedMethods[i].concat();
+ args = methods[i];
+ for(j = 1; j < args.length; ++j)
{
- if(method && method == "lineTo" && this._dashstyle)
+ if(j % 2 === 0)
{
- args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
- this._drawDashedLine.apply(this, args);
+ args[j] = args[j] - this._top;
}
else
{
- context[method].apply(context, args);
+ args[j] = args[j] - this._left;
+ }
+ }
+ }
+ node.setAttribute("width", w);
+ node.setAttribute("height", h);
+ context.beginPath();
+ for(i = 0; i < len; ++i)
+ {
+ args = methods[i];
+ if(args && args.length > 0)
+ {
+ method = args.shift();
+ if(method)
+ {
+ if(method && method == "lineTo" && this._dashstyle)
+ {
+ args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
+ this._drawDashedLine.apply(this, args);
+ }
+ else
+ {
+ context[method].apply(context, args);
+ }
}
}
}
- }
- if (this._fillType) {
- context.fillStyle = this._fillColor;
- context.closePath();
- }
+ if (this._fillType) {
+ context.fillStyle = this._fillColor;
+ context.closePath();
+ }
- if (this._fillType) {
- context.fill();
- }
+ if (this._fillType) {
+ context.fill();
+ }
- if (this._stroke) {
- if(this._strokeWeight)
- {
- context.lineWidth = this._strokeWeight;
+ if (this._stroke) {
+ if(this._strokeWeight)
+ {
+ context.lineWidth = this._strokeWeight;
+ }
+ context.strokeStyle = this._strokeStyle;
+ context.stroke();
}
- context.strokeStyle = this._strokeStyle;
- context.stroke();
+ this._drawingComplete = true;
+ this._clearAndUpdateCoords();
+ this._updateNodePosition();
+ this._methods = cachedMethods;
}
- this._drawingComplete = true;
- this._clearAndUpdateCoords();
- this._updateNodePosition();
},
/**
91 build/gallery-graphics-svg/gallery-graphics-svg-debug.js
View
@@ -949,65 +949,69 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
*/
_draw: function()
{
- var pathArray = this._pathArray,
+ var pathArray,
segmentArray,
pathType,
len,
val,
val2,
i,
- path = this.get("path"),
+ path = "",
node = this.get("node"),
tx = this.get("translateX"),
ty = this.get("translateY"),
left = this._left,
top = this._top;
- while(pathArray && pathArray.length > 0)
+ if(this._pathArray)
{
- segmentArray = pathArray.shift();
- len = segmentArray.length;
- pathType = segmentArray[0];
- path += " " + pathType + (segmentArray[1] - left);
- switch(pathType)
+ pathArray = this._pathArray.concat();
+ while(pathArray && pathArray.length > 0)
{
- case "L" :
- case "M" :
- for(i = 2; i < len; ++i)
- {
- val = (i % 2 === 0) ? top : left;
- val = segmentArray[i] - val;
- path += ", " + val;
- }
- break;
- case "Q" :
- case "C" :
- for(i = 2; i < len; ++i)
- {
- val = (i % 2 === 0) ? top : left;
- val2 = segmentArray[i];
- val2 -= val;
- path += " " + val2;
- }
- break;
+ segmentArray = pathArray.shift();
+ len = segmentArray.length;
+ pathType = segmentArray[0];
+ path += " " + pathType + (segmentArray[1] - left);
+ switch(pathType)
+ {
+ case "L" :
+ case "M" :
+ case "Q" :
+ for(i = 2; i < len; ++i)
+ {
+ val = (i % 2 === 0) ? top : left;
+ val = segmentArray[i] - val;
+ path += ", " + val;
+ }
+ break;
+ case "C" :
+ for(i = 2; i < len; ++i)
+ {
+ val = (i % 2 === 0) ? top : left;
+ val2 = segmentArray[i];
+ val2 -= val;
+ path += " " + val2;
+ }
+ break;
+ }
}
+ if(this._fill)
+ {
+ path += 'z';
+ }
+ if(path)
+ {
+ node.setAttribute("d", path);
+ }
+ //Use transform to handle positioning.
+ this._transformArgs = this._transformArgs || {};
+ this._transformArgs.translate = [left + tx, top + ty];
+
+ this.set("path", path);
+ this._fillChangeHandler();
+ this._strokeChangeHandler();
+ this._updateTransform();
}
- if(this._fill)
- {
- path += 'z';
- }
- if(path)
- {
- node.setAttribute("d", path);
- }
- //Use transform to handle positioning.
- this._transformArgs = this._transformArgs || {};
- this._transformArgs.translate = [left + tx, top + ty];
-
- this.set("path", path);
- this._fillChangeHandler();
- this._strokeChangeHandler();
- this._updateTransform();
},
/**
@@ -1047,6 +1051,7 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
this._right = 0;
this._top = 0;
this._bottom = 0;
+ this._pathArray = [];
this.set("path", "");
},
4 build/gallery-graphics-svg/gallery-graphics-svg-min.js
View
@@ -1,3 +1,3 @@
YUI.add("gallery-graphics-svg",function(c){function a(){}a.prototype={curveTo:function(i,g,n,m,l,k){var e,j,h,d,f,o;if(this._pathType!=="C"){this._pathType="C";j=["C"];this._pathArray.push(j);}else{j=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!j){j=[];this._pathArray.push(j);}}e=this._pathArray.length-1;this._pathArray[e]=this._pathArray[e].concat([Math.round(i),Math.round(g),Math.round(n),Math.round(m),l,k]);h=Math.max(l,Math.max(i,n));f=Math.max(k,Math.max(g,m));d=Math.min(l,Math.min(i,n));o=Math.min(k,Math.min(g,m));this._trackSize(h,f);this._trackSize(d,o);},quadraticCurveTo:function(i,h,l,k){var e,j,g,d,f,m;if(this._pathType!=="Q"){this._pathType="Q";j=["Q"];this._pathArray.push(j);}else{j=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!j){j=[];this._pathArray.push(j);}}e=this._pathArray.length-1;this._pathArray[e]=this._pathArray[e].concat([Math.round(i),Math.round(h),Math.round(l),Math.round(k)]);g=Math.max(l,i);f=Math.max(k,h);d=Math.min(l,i);m=Math.min(k,h);this._trackSize(g,f);this._trackSize(d,m);},drawRect:function(d,g,e,f){this.moveTo(d,g);this.lineTo(d+e,g);this.lineTo(d+e,g+f);this.lineTo(d,g+f);this.lineTo(d,g);},drawRoundRect:function(d,j,e,g,f,i){this.moveTo(d,j+i);this.lineTo(d,j+g-i);this.quadraticCurveTo(d,j+g,d+f,j+g);this.lineTo(d+e-f,j+g);this.quadraticCurveTo(d+e,j+g,d+e,j+g-i);this.lineTo(d+e,j+i);this.quadraticCurveTo(d+e,j,d+e-f,j);this.lineTo(d+f,j);this.quadraticCurveTo(d,j,d,j+i);},drawWedge:function(f,i,h,g,e,d){this._drawingComplete=false;this.path=this._getWedgePath({x:f,y:i,startAngle:h,arc:g,radius:e,yRadius:d});},_getWedgePath:function(A){var o=A.x,l=A.y,t=A.startAngle,k=A.arc,f=A.radius,g=A.yRadius||f,s,q,j,z,h,p,n,w,v,e,d,u=0,m=f*2,r=" M"+o+", "+l;if(Math.abs(k)>360){k=360;}s=Math.ceil(Math.abs(k)/45);q=k/s;j=-(q/180)*Math.PI;z=(t/180)*Math.PI;if(s>0){p=o+Math.cos(t/180*Math.PI)*f;n=l+Math.sin(t/180*Math.PI)*g;r+=" L"+Math.round(p)+", "+Math.round(n);r+=" Q";for(;u<s;++u){z+=j;h=z-(j/2);w=o+Math.cos(z)*f;v=l+Math.sin(z)*g;e=o+Math.cos(h)*(f/Math.cos(j/2));d=l+Math.sin(h)*(g/Math.cos(j/2));r+=Math.round(e)+" "+Math.round(d)+" "+Math.round(w)+" "+Math.round(v)+" ";}r+=" L"+o+", "+l;}this._trackSize(m,m);return r;},lineTo:function(j,h,f){var e=arguments,g,d,l,k;this._pathArray=this._pathArray||[];if(typeof j==="string"||typeof j==="number"){e=[[j,h]];}d=e.length;this._shapeType="path";if(this._pathType!=="L"){this._pathType="L";k=["L"];this._pathArray.push(k);}else{k=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!k){k=[];this._pathArray.push(k);}}l=this._pathArray.length-1;for(g=0;g<d;++g){this._pathArray[l]=this._pathArray[l].concat([e[g][0],e[g][1]]);this._trackSize.apply(this,e[g]);}},moveTo:function(d,g){var f,e;this._pathArray=this._pathArray||[];if(this._pathType!="M"){this._pathType="M";e=["M"];this._pathArray.push(e);}else{e=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!e){e=[];this._pathArray.push(e);}}f=this._pathArray.length-1;this._pathArray[f]=this._pathArray[f].concat([d,g]);this._trackSize(d,g);},end:function(){this._draw();},setSize:function(d,e){var f;if(this.get("autoSize")){f=this.get("node");if(d>f.getAttribute("width")){f.setAttribute("width",d);}if(e>f.getAttribute("height")){f.setAttribute("height",e);}}},_trackSize:function(d,e){var f=this.get("node");if(d>this._right){this._right=d;}if(d<this._left){this._left=d;}if(e<this._top){this._top=e;}if(e>this._bottom){this._bottom=e;}this._width=this._right-this._left;this._height=this._bottom-this._top;f.style.left=this._left+"px";f.style.top=this._top+"px";this.setSize(this._width,this._height);}};c.Drawing=a;c.Shape=c.Base.create("shape",c.Base,[],{initializer:function(){this.publish("shapeUpdate");this._addListeners();},_getNode:function(){var e=document.createElementNS("http://www.w3.org/2000/svg","svg:"+this._type),d=this.get("pointerEvents")||"none";e.setAttribute("pointer-events",d);e.setAttribute("class","yui3-"+this.name);e.setAttribute("id",this.get("id"));return e;},_addListeners:function(){this.after("initializedChange",this._updateHandler);this.after("transformAdded",this._updateHandler);this.after("strokeChange",this._updateHandler);this.after("fillChange",this._updateHandler);this.after("widthChange",this._updateHandler);this.after("heightChange",this._updateHandler);this.after("xChange",this._updateHandler);this.after("yChange",this._updateHandler);},_strokeChangeHandler:function(l){var g=this.get("node"),m=this.get("stroke"),n,f,j,h,k,d;if(m&&m.weight&&m.weight>0){n=m.alpha;f=m.dashstyle||"none";j=c.Lang.isArray(f)?f.toString():f;m.color=m.color||"#000000";m.weight=m.weight||1;m.alpha=c.Lang.isNumber(n)?n:1;m.linecap=m.linecap||"butt";g.setAttribute("stroke-dasharray",j);g.setAttribute("stroke",m.color);g.setAttribute("stroke-linecap",m.linecap);g.setAttribute("stroke-width",m.weight);g.setAttribute("stroke-opacity",m.alpha);}else{g.setAttribute("stroke","none");}},_fillChangeHandler:function(h){var f=this.get("node"),g=this.get("fill"),d;if(g){if(!g.color){f.setAttribute("fill","none");}else{d=g.alpha;g.alpha=c.Lang.isNumber(d)?d:1;f.setAttribute("fill",g.color);f.setAttribute("fill-opacity",d);}}else{f.setAttribute("fill","none");}},translate:function(d,e){this._translateX=d;this._translateY=e;this._translate.apply(this,arguments);},_translate:function(d,e){this._addTransform("translate",arguments);},skewX:function(d){this._addTransform("skewX",arguments);},skewY:function(d){this._addTransform("skewY",arguments);},rotate:function(d){this._addTransform("rotate",arguments);},scale:function(d){this._addTransform("scale",arguments);},matrix:function(h,g,l,k,j,i){this._addTransform("matrix",arguments);},_addTransform:function(e,d){if(!this._transformArgs){this._transformArgs={};}this._transformArgs[e]=Array.prototype.slice.call(d,0);this.fire("transformAdded");},_updateTransform:function(){var g=this.get("node"),f,e,h,d=g.getAttribute("transform"),i;if(this._transformArgs){if(this._transformArgs.hasOwnProperty("rotate")){e=this._transformArgs.rotate;
-e[1]=this.get("x")+(this.get("width")*0.5);e[2]=this.get("y")+(this.get("height")*0.5);}}for(f in this._transformArgs){if(f&&this._transformArgs.hasOwnProperty(f)){h=f+"("+this._transformArgs[f].toString()+")";if(d&&d.length>0){i=new RegExp(f+"(.*)");if(d.indexOf(f)>-1){d=d.replace(i,h);}else{d+=" "+h;}}else{d=h;}}}if(d){g.setAttribute("transform",d);}},_draw:function(){var d=this.get("node");d.setAttribute("width",this.get("width"));d.setAttribute("height",this.get("height"));d.setAttribute("x",this.get("x"));d.setAttribute("y",this.get("y"));d.style.left=this.get("x")+"px";d.style.top=this.get("y")+"px";this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();},_updateHandler:function(d){this._draw();this.fire("shapeUpdate");},_translateX:0,_translateY:0,getBounds:function(){var l=this.get("width"),g=this.get("height"),m=this.get("stroke"),k=this.get("x"),j=this.get("y"),i=0,f=this.get("translateX"),e=this.get("translateY"),d={};if(m&&m.weight){i=m.weight;}d.left=k-i+f;d.top=j-i+e;d.right=k+l+i+f;d.bottom=j+g+i+e;return d;}},{ATTRS:{node:{readOnly:true,valueFn:"_getNode"},id:{valueFn:function(){return c.guid();},setter:function(e){var d=this.get("node");d.setAttribute("id",e);return e;}},x:{value:0},y:{value:0},width:{},height:{},visible:{value:true,setter:function(e){var d=e?"visible":"hidden";this.get("node").style.visibility=d;return e;}},fill:{setter:function(e){var d=this.get("fill")||this._getAttrCfg("fill").defaultValue;return(e)?c.merge(d,e):null;}},stroke:{valueFn:function(){return{weight:1,dashstyle:null,color:"#000",alpha:1};},setter:function(e){var d=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;return(e)?c.merge(d,e):null;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"},translateX:{getter:function(){return this._translateX;},setter:function(d){this._translateX=d;this._transform(d,this._translateY);return d;}},translateY:{getter:function(){return this._translateY;},setter:function(d){this._translateY=d;this._transform(this._translateX,d);return d;}},graphic:{setter:function(d){this.after("shapeUpdate",c.bind(d.updateCoordSpace,d));return d;}}}});c.Path=c.Base.create("path",c.Shape,[c.Drawing],{_left:0,_right:0,_top:0,_bottom:0,_type:"path",_draw:function(){var e=this._pathArray,l,d,o,f,n,m,q=this.get("path"),h=this.get("node"),k=this.get("translateX"),j=this.get("translateY"),g=this._left,p=this._top;while(e&&e.length>0){l=e.shift();o=l.length;d=l[0];q+=" "+d+(l[1]-g);switch(d){case"L":case"M":for(m=2;m<o;++m){f=(m%2===0)?p:g;f=l[m]-f;q+=", "+f;}break;case"Q":case"C":for(m=2;m<o;++m){f=(m%2===0)?p:g;n=l[m];n-=f;q+=" "+n;}break;}}if(this._fill){q+="z";}if(q){h.setAttribute("d",q);}this._transformArgs=this._transformArgs||{};this._transformArgs.translate=[g+k,p+j];this.set("path",q);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();},translate:function(d,f){var e=this.get("node");this._translateX=d;this._translateY=f;this._translate(this._left+d,this._top+f);},end:function(){this._draw();this.fire("shapeUpdate");},clear:function(){this._left=0;this._right=0;this._top=0;this._bottom=0;this.set("path","");},getBounds:function(){var e=0,g={},h=this.get("stroke"),f=this.get("translateX"),d=this.get("translateY");if(h&&h.weight){e=h.weight;}g.left=this._left-e+f;g.top=this._top-e+d;g.right=(this._right-this._left)+e+f;g.bottom=(this._bottom-this._top)+e+d;return g;}},{ATTRS:{path:{value:""},width:{getter:function(){var d=this._right,e=this._left,f=Math.max(this._right-this._left,0);return f;}},height:{getter:function(){return Math.max(this._bottom-this._top,0);}}}});c.Rect=c.Base.create("rect",c.Shape,[],{_type:"rect"});c.Ellipse=c.Base.create("ellipse",c.Shape,[],{_type:"ellipse",_draw:function(){var d=this.get("node"),m=this.get("width"),g=this.get("height"),l=this.get("x"),j=this.get("y"),k=m*0.5,i=g*0.5,f=l+k,e=j+i;d.setAttribute("rx",k);d.setAttribute("ry",i);d.setAttribute("cx",f);d.setAttribute("cy",e);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},{ATTRS:{xRadius:{readOnly:true,getter:function(){var d=this.get("width");if(d){d*=0.5;}return d;}},yRadius:{readOnly:true,getter:function(){var d=this.get("height");if(d){d*=0.5;}return d;}},x:{lazyAdd:false,value:0},y:{lazyAdd:false}}});c.Circle=c.Base.create("circle",c.Shape,[],{_type:"circle",_addListeners:function(){c.Circle.superclass._addListeners.apply(this);this.after("radiusChange",this._updateHandler);},_draw:function(){var g=this.get("node"),f=this.get("x"),i=this.get("y"),e=this.get("radius"),d=f+e,h=i+e;g.setAttribute("r",e);g.setAttribute("cx",d);g.setAttribute("cy",h);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},{ATTRS:{width:{readOnly:true,getter:function(){return this.get("radius")*2;}},height:{readOnly:true,getter:function(){return this.get("radius")*2;}},radius:{value:0}}});function b(d){this.initializer.apply(this,arguments);}b.prototype={autoSize:true,initializer:function(e){e=e||{};var d=e.width||0,f=e.height||0;this.id=c.guid();this.node=this._createGraphics();this.node.setAttribute("id",this.id);this.setSize(d,f);if(e.render){this.render(e.render);}},destroy:function(){this._removeChildren(this.node);if(this.node&&this.node.parentNode){this.node.parentNode.removeChild(this.node);}},_removeChildren:function(d){if(d.hasChildNodes()){var e;while(d.firstChild){e=d.firstChild;this._removeChildren(e);d.removeChild(e);}}},toggleVisible:function(d){this._toggleVisible(this.node,d);},_toggleVisible:function(h,j){var g=c.Selector.query(">/*",h),e=j?"visible":"hidden",f=0,d;if(g){d=g.length;for(;f<d;++f){this._toggleVisible(g[f],j);}}h.style.visibility=e;},clear:function(){if(this._graphicsList){while(this._graphicsList.length>0){this.node.removeChild(this._graphicsList.shift());}}},setSize:function(d,e){if(this.autoSize){if(d>this.node.getAttribute("width")){this.node.setAttribute("width",d);}if(e>this.node.getAttribute("height")){this.node.setAttribute("height",e);}}},_trackSize:function(d,e){if(d>this._right){this._right=d;
-}if(d<this._left){this._left=d;}if(e<this._top){this._top=e;}if(e>this._bottom){this._bottom=e;}this._width=this._right-this._left;this._height=this._bottom-this._top;this.node.style.left=this._left+"px";this.node.style.top=this._top+"px";this.setSize(this._width,this._height);},render:function(g){var d=c.one(g),e=parseInt(d.getComputedStyle("width"),10),f=parseInt(d.getComputedStyle("height"),10);d=d||c.config.doc.body;d.appendChild(this.node);this.setSize(e,f);return this;},_createGraphics:function(){var d=this._createGraphicNode("svg");this._styleGroup(d);return d;},_styleGroup:function(d){d.style.position="absolute";d.style.top="0px";d.style.left="0px";d.style.overflow="auto";d.setAttribute("overflow","auto");d.setAttribute("pointer-events","none");},_createGraphicNode:function(f,d){var g=document.createElementNS("http://www.w3.org/2000/svg","svg:"+f),e=d||"none";if(f!=="defs"&&f!=="stop"&&f!=="linearGradient"){g.setAttribute("pointer-events",e);}return g;},addShape:function(d){var e=d.get("node");d.set("graphic",this);this.node.appendChild(e);if(!this._graphicsList){this._graphicsList=[];}if(!this._shapes){this._shapes={};}this._graphicsList.push(e);this._shapes[d.get("id")]=d;this.updateCoordSpace();},getShape:function(d){return this._shapes[d];},updateCoordSpace:function(k){var j,h=0,g,f=this._graphicsList,d=f.length;this._left=0;this._right=0;this._top=0;this._bottom=0;for(;h<d;++h){g=this.getShape(f[h].getAttribute("id"));j=g.getBounds();this._left=Math.min(this._left,j.left);this._top=Math.min(this._top,j.top);this._right=Math.max(this._right,j.right);this._bottom=Math.max(this._bottom,j.bottom);}this._width=this._right-this._left;this._height=this._bottom-this._top;this.node.setAttribute("width",this._width);this.node.setAttribute("height",this._height);this.node.style.width=this._width+"px";this.node.style.height=this._height+"px";this.node.style.left=this._left+"px";this.node.style.top=this._top+"px";this.node.setAttribute("viewBox",""+this._left+" "+this._top+" "+this._width+" "+this._height+"");},_left:0,_right:0,_top:0,_bottom:0};c.Graphic=b;},"@VERSION@",{requires:["graphics"],skinnable:false});
+e[1]=this.get("x")+(this.get("width")*0.5);e[2]=this.get("y")+(this.get("height")*0.5);}}for(f in this._transformArgs){if(f&&this._transformArgs.hasOwnProperty(f)){h=f+"("+this._transformArgs[f].toString()+")";if(d&&d.length>0){i=new RegExp(f+"(.*)");if(d.indexOf(f)>-1){d=d.replace(i,h);}else{d+=" "+h;}}else{d=h;}}}if(d){g.setAttribute("transform",d);}},_draw:function(){var d=this.get("node");d.setAttribute("width",this.get("width"));d.setAttribute("height",this.get("height"));d.setAttribute("x",this.get("x"));d.setAttribute("y",this.get("y"));d.style.left=this.get("x")+"px";d.style.top=this.get("y")+"px";this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();},_updateHandler:function(d){this._draw();this.fire("shapeUpdate");},_translateX:0,_translateY:0,getBounds:function(){var l=this.get("width"),g=this.get("height"),m=this.get("stroke"),k=this.get("x"),j=this.get("y"),i=0,f=this.get("translateX"),e=this.get("translateY"),d={};if(m&&m.weight){i=m.weight;}d.left=k-i+f;d.top=j-i+e;d.right=k+l+i+f;d.bottom=j+g+i+e;return d;}},{ATTRS:{node:{readOnly:true,valueFn:"_getNode"},id:{valueFn:function(){return c.guid();},setter:function(e){var d=this.get("node");d.setAttribute("id",e);return e;}},x:{value:0},y:{value:0},width:{},height:{},visible:{value:true,setter:function(e){var d=e?"visible":"hidden";this.get("node").style.visibility=d;return e;}},fill:{setter:function(e){var d=this.get("fill")||this._getAttrCfg("fill").defaultValue;return(e)?c.merge(d,e):null;}},stroke:{valueFn:function(){return{weight:1,dashstyle:null,color:"#000",alpha:1};},setter:function(e){var d=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;return(e)?c.merge(d,e):null;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"},translateX:{getter:function(){return this._translateX;},setter:function(d){this._translateX=d;this._transform(d,this._translateY);return d;}},translateY:{getter:function(){return this._translateY;},setter:function(d){this._translateY=d;this._transform(this._translateX,d);return d;}},graphic:{setter:function(d){this.after("shapeUpdate",c.bind(d.updateCoordSpace,d));return d;}}}});c.Path=c.Base.create("path",c.Shape,[c.Drawing],{_left:0,_right:0,_top:0,_bottom:0,_type:"path",_draw:function(){var e,l,d,o,f,n,m,q="",h=this.get("node"),k=this.get("translateX"),j=this.get("translateY"),g=this._left,p=this._top;if(this._pathArray){e=this._pathArray.concat();while(e&&e.length>0){l=e.shift();o=l.length;d=l[0];q+=" "+d+(l[1]-g);switch(d){case"L":case"M":case"Q":for(m=2;m<o;++m){f=(m%2===0)?p:g;f=l[m]-f;q+=", "+f;}break;case"C":for(m=2;m<o;++m){f=(m%2===0)?p:g;n=l[m];n-=f;q+=" "+n;}break;}}if(this._fill){q+="z";}if(q){h.setAttribute("d",q);}this._transformArgs=this._transformArgs||{};this._transformArgs.translate=[g+k,p+j];this.set("path",q);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},translate:function(d,f){var e=this.get("node");this._translateX=d;this._translateY=f;this._translate(this._left+d,this._top+f);},end:function(){this._draw();this.fire("shapeUpdate");},clear:function(){this._left=0;this._right=0;this._top=0;this._bottom=0;this._pathArray=[];this.set("path","");},getBounds:function(){var e=0,g={},h=this.get("stroke"),f=this.get("translateX"),d=this.get("translateY");if(h&&h.weight){e=h.weight;}g.left=this._left-e+f;g.top=this._top-e+d;g.right=(this._right-this._left)+e+f;g.bottom=(this._bottom-this._top)+e+d;return g;}},{ATTRS:{path:{value:""},width:{getter:function(){var d=this._right,e=this._left,f=Math.max(this._right-this._left,0);return f;}},height:{getter:function(){return Math.max(this._bottom-this._top,0);}}}});c.Rect=c.Base.create("rect",c.Shape,[],{_type:"rect"});c.Ellipse=c.Base.create("ellipse",c.Shape,[],{_type:"ellipse",_draw:function(){var d=this.get("node"),m=this.get("width"),g=this.get("height"),l=this.get("x"),j=this.get("y"),k=m*0.5,i=g*0.5,f=l+k,e=j+i;d.setAttribute("rx",k);d.setAttribute("ry",i);d.setAttribute("cx",f);d.setAttribute("cy",e);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},{ATTRS:{xRadius:{readOnly:true,getter:function(){var d=this.get("width");if(d){d*=0.5;}return d;}},yRadius:{readOnly:true,getter:function(){var d=this.get("height");if(d){d*=0.5;}return d;}},x:{lazyAdd:false,value:0},y:{lazyAdd:false}}});c.Circle=c.Base.create("circle",c.Shape,[],{_type:"circle",_addListeners:function(){c.Circle.superclass._addListeners.apply(this);this.after("radiusChange",this._updateHandler);},_draw:function(){var g=this.get("node"),f=this.get("x"),i=this.get("y"),e=this.get("radius"),d=f+e,h=i+e;g.setAttribute("r",e);g.setAttribute("cx",d);g.setAttribute("cy",h);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},{ATTRS:{width:{readOnly:true,getter:function(){return this.get("radius")*2;}},height:{readOnly:true,getter:function(){return this.get("radius")*2;}},radius:{value:0}}});function b(d){this.initializer.apply(this,arguments);}b.prototype={autoSize:true,initializer:function(e){e=e||{};var d=e.width||0,f=e.height||0;this.id=c.guid();this.node=this._createGraphics();this.node.setAttribute("id",this.id);this.setSize(d,f);if(e.render){this.render(e.render);}},destroy:function(){this._removeChildren(this.node);if(this.node&&this.node.parentNode){this.node.parentNode.removeChild(this.node);}},_removeChildren:function(d){if(d.hasChildNodes()){var e;while(d.firstChild){e=d.firstChild;this._removeChildren(e);d.removeChild(e);}}},toggleVisible:function(d){this._toggleVisible(this.node,d);},_toggleVisible:function(h,j){var g=c.Selector.query(">/*",h),e=j?"visible":"hidden",f=0,d;if(g){d=g.length;for(;f<d;++f){this._toggleVisible(g[f],j);}}h.style.visibility=e;},clear:function(){if(this._graphicsList){while(this._graphicsList.length>0){this.node.removeChild(this._graphicsList.shift());}}},setSize:function(d,e){if(this.autoSize){if(d>this.node.getAttribute("width")){this.node.setAttribute("width",d);}if(e>this.node.getAttribute("height")){this.node.setAttribute("height",e);
+}}},_trackSize:function(d,e){if(d>this._right){this._right=d;}if(d<this._left){this._left=d;}if(e<this._top){this._top=e;}if(e>this._bottom){this._bottom=e;}this._width=this._right-this._left;this._height=this._bottom-this._top;this.node.style.left=this._left+"px";this.node.style.top=this._top+"px";this.setSize(this._width,this._height);},render:function(g){var d=c.one(g),e=parseInt(d.getComputedStyle("width"),10),f=parseInt(d.getComputedStyle("height"),10);d=d||c.config.doc.body;d.appendChild(this.node);this.setSize(e,f);return this;},_createGraphics:function(){var d=this._createGraphicNode("svg");this._styleGroup(d);return d;},_styleGroup:function(d){d.style.position="absolute";d.style.top="0px";d.style.left="0px";d.style.overflow="auto";d.setAttribute("overflow","auto");d.setAttribute("pointer-events","none");},_createGraphicNode:function(f,d){var g=document.createElementNS("http://www.w3.org/2000/svg","svg:"+f),e=d||"none";if(f!=="defs"&&f!=="stop"&&f!=="linearGradient"){g.setAttribute("pointer-events",e);}return g;},addShape:function(d){var e=d.get("node");d.set("graphic",this);this.node.appendChild(e);if(!this._graphicsList){this._graphicsList=[];}if(!this._shapes){this._shapes={};}this._graphicsList.push(e);this._shapes[d.get("id")]=d;this.updateCoordSpace();},getShape:function(d){return this._shapes[d];},updateCoordSpace:function(k){var j,h=0,g,f=this._graphicsList,d=f.length;this._left=0;this._right=0;this._top=0;this._bottom=0;for(;h<d;++h){g=this.getShape(f[h].getAttribute("id"));j=g.getBounds();this._left=Math.min(this._left,j.left);this._top=Math.min(this._top,j.top);this._right=Math.max(this._right,j.right);this._bottom=Math.max(this._bottom,j.bottom);}this._width=this._right-this._left;this._height=this._bottom-this._top;this.node.setAttribute("width",this._width);this.node.setAttribute("height",this._height);this.node.style.width=this._width+"px";this.node.style.height=this._height+"px";this.node.style.left=this._left+"px";this.node.style.top=this._top+"px";this.node.setAttribute("viewBox",""+this._left+" "+this._top+" "+this._width+" "+this._height+"");},_left:0,_right:0,_top:0,_bottom:0};c.Graphic=b;},"@VERSION@",{requires:["graphics"],skinnable:false});
91 build/gallery-graphics-svg/gallery-graphics-svg.js
View
@@ -949,65 +949,69 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
*/
_draw: function()
{
- var pathArray = this._pathArray,
+ var pathArray,
segmentArray,
pathType,
len,
val,
val2,
i,
- path = this.get("path"),
+ path = "",
node = this.get("node"),
tx = this.get("translateX"),
ty = this.get("translateY"),
left = this._left,
top = this._top;
- while(pathArray && pathArray.length > 0)
+ if(this._pathArray)
{
- segmentArray = pathArray.shift();
- len = segmentArray.length;
- pathType = segmentArray[0];
- path += " " + pathType + (segmentArray[1] - left);
- switch(pathType)
+ pathArray = this._pathArray.concat();
+ while(pathArray && pathArray.length > 0)
{
- case "L" :
- case "M" :
- for(i = 2; i < len; ++i)
- {
- val = (i % 2 === 0) ? top : left;
- val = segmentArray[i] - val;
- path += ", " + val;
- }
- break;
- case "Q" :
- case "C" :
- for(i = 2; i < len; ++i)
- {
- val = (i % 2 === 0) ? top : left;
- val2 = segmentArray[i];
- val2 -= val;
- path += " " + val2;
- }
- break;
+ segmentArray = pathArray.shift();
+ len = segmentArray.length;
+ pathType = segmentArray[0];
+ path += " " + pathType + (segmentArray[1] - left);
+ switch(pathType)
+ {
+ case "L" :
+ case "M" :
+ case "Q" :
+ for(i = 2; i < len; ++i)
+ {
+ val = (i % 2 === 0) ? top : left;
+ val = segmentArray[i] - val;
+ path += ", " + val;
+ }
+ break;
+ case "C" :
+ for(i = 2; i < len; ++i)
+ {
+ val = (i % 2 === 0) ? top : left;
+ val2 = segmentArray[i];
+ val2 -= val;
+ path += " " + val2;
+ }
+ break;
+ }
}
+ if(this._fill)
+ {
+ path += 'z';
+ }
+ if(path)
+ {
+ node.setAttribute("d", path);
+ }
+ //Use transform to handle positioning.
+ this._transformArgs = this._transformArgs || {};
+ this._transformArgs.translate = [left + tx, top + ty];
+
+ this.set("path", path);
+ this._fillChangeHandler();
+ this._strokeChangeHandler();
+ this._updateTransform();
}
- if(this._fill)
- {
- path += 'z';
- }
- if(path)
- {
- node.setAttribute("d", path);
- }
- //Use transform to handle positioning.
- this._transformArgs = this._transformArgs || {};
- this._transformArgs.translate = [left + tx, top + ty];
-
- this.set("path", path);
- this._fillChangeHandler();
- this._strokeChangeHandler();
- this._updateTransform();
},
/**
@@ -1047,6 +1051,7 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
this._right = 0;
this._top = 0;
this._bottom = 0;
+ this._pathArray = [];
this.set("path", "");
},
162 build/gallery-graphics-vml/gallery-graphics-vml-debug.js
View
@@ -18,6 +18,16 @@ function Drawing() {}
Drawing.prototype = {
/**
+ * @private
+ */
+ _currentX: 0,
+
+ /**
+ * @private
+ */
+ _currentY: 0,
+
+ /**
* Draws a bezier curve.
*
* @method curveTo
@@ -29,8 +39,19 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
+ var hiX,
+ loX,
+ hiY,
+ loY;
this._path += ' c ' + Math.round(cp1x) + ", " + Math.round(cp1y) + ", " + Math.round(cp2x) + ", " + Math.round(cp2y) + ", " + x + ", " + y;
- this._trackSize(x, y);
+ this._currentX = x;
+ this._currentY = y;
+ hiX = Math.max(x, Math.max(cp1x, cp2x));
+ hiY = Math.max(y, Math.max(cp1y, cp2y));
+ loX = Math.min(x, Math.min(cp1x, cp2x));
+ loY = Math.min(y, Math.min(cp1y, cp2y));
+ this._trackSize(hiX, hiY);
+ this._trackSize(loX, loY);
},
/**
@@ -43,13 +64,13 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
quadraticCurveTo: function(cpx, cpy, x, y) {
- var hiX = Math.max(x, cpx),
- hiY = Math.max(y, cpy),
- loX = Math.min(x, cpx),
- loY = Math.min(y, cpy);
- this._path += ' qb ' + cpx + ", " + cpy + ", " + x + ", " + y;
- this._trackSize(hiX, hiY);
- this._trackSize(loX, loY);
+ var currentX = this._currentX,
+ currentY = this._currentY,
+ cp1x = currentX + 0.67*(cpx - currentX),
+ cp1y = currentY + 0.67*(cpy - currentY),
+ cp2x = cp1x + (x - currentX) * 0.34,
+ cp2y = cp1y + (y - currentY) * 0.34;
+ this.curveTo( cp1x, cp1y, cp2x, cp2y, x, y );
},
/**
@@ -67,6 +88,9 @@ Drawing.prototype = {
this.lineTo(x + w, y + h);
this.lineTo(x, y + h);
this.lineTo(x, y);
+ this._currentX = x;
+ this._currentY = y;
+ return this;
},
/**
@@ -90,6 +114,7 @@ Drawing.prototype = {
this.quadraticCurveTo(x + w, y, x + w - ew, y);
this.lineTo(x + ew, y);
this.quadraticCurveTo(x, y, x, y + eh);
+ return this;
},
/**
@@ -108,6 +133,9 @@ Drawing.prototype = {
yRadius = yRadius || radius;
this._path += this._getWedgePath({x:x, y:y, startAngle:startAngle, arc:arc, radius:radius, yRadius:yRadius});
this._trackSize(diameter, diameter);
+ this._currentX = x;
+ this._currentY = y;
+ return this;
},
/**
@@ -169,6 +197,8 @@ Drawing.prototype = {
for (i = 0; i < len; ++i) {
this._path += ' ' + Math.round(args[i][0]) + ', ' + Math.round(args[i][1]);
this._trackSize.apply(this, args[i]);
+ this._currentX = args[i][0];
+ this._currentY = args[i][1];
}
var path = this._path;
return this;
@@ -188,6 +218,8 @@ Drawing.prototype = {
}
this._path += ' m ' + Math.round(x) + ', ' + Math.round(y);
this._trackSize(x, y);
+ this._currentX = x;
+ this._currentY = y;
},
@@ -225,6 +257,7 @@ Y.Drawing = Drawing;
*/
initializer: function()
{
+ this.publish("shapeUpdate");
this._addListeners();
this._draw();
},
@@ -370,7 +403,10 @@ Y.Drawing = Drawing;
coordSize = node.coordSize;
x = 0 - (coordSize.x/w * x);
y = 0 - (coordSize.y/h * y);
+ this._translateX = x;
+ this._translateY = y;
node.coordOrigin = x + "," + y;
+ this.fire("shapeUpdate");
},
/**
@@ -405,6 +441,7 @@ Y.Drawing = Drawing;
{
var node = this.get("node");
node.style.rotation = deg;
+ this.fire("shapeUpdate");
},
/**
@@ -438,6 +475,7 @@ Y.Drawing = Drawing;
y = this.get("y"),
w = this.get("width"),
h = this.get("height");
+ node.style.visible = "hidden";
node.style.position = "absolute";
node.style.left = x + "px";
node.style.top = y + "px";
@@ -445,6 +483,8 @@ Y.Drawing = Drawing;
node.style.height = h + "px";
this._fillChangeHandler();
this._strokeChangeHandler();
+ this.fire("shapeUpdate");
+ node.style.visible = "visible";
},
/**
@@ -460,6 +500,32 @@ Y.Drawing = Drawing;
{
type = type || this._type;
return document.createElement('<' + type + ' xmlns="urn:schemas-microsft.com:vml" class="vml' + type + '"/>');
+ },
+
+ /**
+ * Returns the bounds for a shape.
+ *
+ * @method getBounds
+ * @return Object
+ */
+ getBounds: function()
+ {
+ var w = this.get("width"),
+ h = this.get("height"),
+ stroke = this.get("stroke"),
+ x = this.get("x"),
+ y = this.get("y"),
+ wt = 0,
+ bounds = {};
+ if(stroke && stroke.weight)
+ {
+ wt = stroke.weight;
+ }
+ bounds.left = x - wt;
+ bounds.top = y - wt;
+ bounds.right = x + w + wt;
+ bounds.bottom = y + h + wt;
+ return bounds;
}
}, {
ATTRS: {
@@ -644,6 +710,19 @@ Y.Drawing = Drawing;
*/
pointerEvents: {
value: "visiblePainted"
+ },
+
+ /**
+ * Reference to the container Graphic.
+ *
+ * @attribute graphic
+ * @type Graphic
+ */
+ graphic: {
+ setter: function(val){
+ this.after("shapeUpdate", Y.bind(val.updateSize, val));
+ return val;
+ }
}
}
});
@@ -678,23 +757,25 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
node = this.get("node"),
w = this.get("width"),
h = this.get("height"),
- path = this.get("path");
+ path = this.get("path"),
+ pathEnd = "";
+ node.style.visible = "hidden";
this._fillChangeHandler();
this._strokeChangeHandler();
if(path)
{
if(fill && fill.color)
{
- path += ' x';
+ pathEnd += ' x';
}
if(stroke)
{
- path += ' e';
+ pathEnd += ' e';
}
}
if(path)
{
- node.path = path;
+ node.path = path + pathEnd;
}
if(w && h)
{
@@ -704,6 +785,8 @@ Y.Path = Y.Base.create("path", Y.Shape, [Y.Drawing], {
node.style.height = h + "px";
}
this.set("path", path);
+ this.fire("shapeUpdate");
+ node.style.visible = "visible";
},
/**
@@ -1161,6 +1244,7 @@ Graphic.prototype = {
addShape: function(shape)
{
var node = shape.get("node");
+ shape.set("graphic", this);
this.node.appendChild(node);
if(!this._graphicsList)
{
@@ -1196,7 +1280,59 @@ Graphic.prototype = {
addChild: function(child)
{
this.node.appendChild(child);
- }
+ },
+
+ /**
+ * Updates the size of the graphics container and.
+ *
+ * @method updateSize
+ */
+ updateSize: function(e)
+ {
+ var bounds,
+ i = 0,
+ shape,
+ shapes = this._graphicsList,
+ len = shapes.length,
+ w,
+ h;
+ this._left = 0;
+ this._right = 0;
+ this._top = 0;
+ this._bottom = 0;
+ for(; i < len; ++i)
+ {
+ shape = this.getShape(shapes[i].getAttribute("id"));
+ bounds = shape.getBounds();
+ this._left = Math.min(this._left, bounds.left);
+ this._top = Math.min(this._top, bounds.top);
+ this._right = Math.max(this._right, bounds.right);
+ this._bottom = Math.max(this._bottom, bounds.bottom);
+ }
+ w = this._width = this._right - this._left;
+ h = this._height = this._bottom - this._top;
+ this.setSize(this._width, this._height);
+ },
+
+ /**
+ * @private
+ */
+ _left: 0,
+
+ /**
+ * @private
+ */
+ _right: 0,
+
+ /**
+ * @private
+ */
+ _top: 0,
+
+ /**
+ * @private
+ */
+ _bottom: 0
};
Y.Graphic = Graphic;
4 build/gallery-graphics-vml/gallery-graphics-vml-min.js
View
@@ -1,2 +1,2 @@
-YUI.add("gallery-graphics-vml",function(d){var b=document.createStyleSheet();b.addRule(".vmlgroup","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlgroup","display:inline-block",b.rules.length);b.addRule(".vmlgroup","zoom:1",b.rules.length);b.addRule(".vmlshape","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlshape","display:inline-block",b.rules.length);b.addRule(".vmloval","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmloval","display:inline-block",b.rules.length);b.addRule(".vmlrect","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlrect","display:block",b.rules.length);b.addRule(".vmlfill","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlstroke","behavior:url(#default#VML)",b.rules.length);function a(){}a.prototype={curveTo:function(g,f,i,h,e,j){this._path+=" c "+Math.round(g)+", "+Math.round(f)+", "+Math.round(i)+", "+Math.round(h)+", "+e+", "+j;this._trackSize(e,j);},quadraticCurveTo:function(i,h,e,l){var g=Math.max(e,i),f=Math.max(l,h),k=Math.min(e,i),j=Math.min(l,h);this._path+=" qb "+i+", "+h+", "+e+", "+l;this._trackSize(g,f);this._trackSize(k,j);},drawRect:function(e,i,f,g){this.moveTo(e,i);this.lineTo(e+f,i);this.lineTo(e+f,i+g);this.lineTo(e,i+g);this.lineTo(e,i);},drawRoundRect:function(e,k,f,i,g,j){this.moveTo(e,k+j);this.lineTo(e,k+i-j);this.quadraticCurveTo(e,k+i,e+g,k+i);this.lineTo(e+f-g,k+i);this.quadraticCurveTo(e+f,k+i,e+f,k+i-j);this.lineTo(e+f,k+j);this.quadraticCurveTo(e+f,k,e+f-g,k);this.lineTo(e+g,k);this.quadraticCurveTo(e,k,e,k+j);},drawWedge:function(g,k,i,h,f,e){var j=f*2;e=e||f;this._path+=this._getWedgePath({x:g,y:k,startAngle:i,arc:h,radius:f,yRadius:e});this._trackSize(j,j);},_getWedgePath:function(h){var g=h.x,l=h.y,j=h.startAngle,i=h.arc,f=h.radius,e=h.yRadius||f,k;if(Math.abs(i)>360){i=360;}j*=-65535;i*=65536;k=" m "+g+" "+l+" ae "+g+" "+l+" "+f+" "+e+" "+j+" "+i;return k;},end:function(){this._draw();},lineTo:function(k,j,g){var f=arguments,h,e;if(typeof k==="string"||typeof k==="number"){f=[[k,j]];}e=f.length;if(!this._path){this._path="";}this._path+=" l ";for(h=0;h<e;++h){this._path+=" "+Math.round(f[h][0])+", "+Math.round(f[h][1]);this._trackSize.apply(this,f[h]);}var l=this._path;return this;},moveTo:function(e,f){if(!this._path){this._path="";}this._path+=" m "+Math.round(e)+", "+Math.round(f);this._trackSize(e,f);},_trackSize:function(e,g){var i=this._width||0,f=this._height||0;if(e>i){this._width=e;}if(g>f){this._height=g;}}};d.Drawing=a;d.Shape=d.Base.create("shape",d.Base,[],{initializer:function(){this._addListeners();this._draw();},_getNode:function(){var e=this._createGraphicNode();e.setAttribute("id",this.get("id"));d.one(e).addClass("yui3-"+this.name);return e;},_addListeners:function(){this.after("strokeChange",this._strokeChangeHandler);this.after("fillChange",this._fillChangeHandler);},_strokeChangeHandler:function(n){var h=this.get("node"),o=this.get("stroke"),p,g,l="",f,j,k=0,m;if(o&&o.weight&&o.weight>0){p=o.alpha;g=o.dashstyle||"none";j=o.endcap||"flat";o.color=o.color||"#000000";o.weight=o.weight||1;o.alpha=d.Lang.isNumber(p)?p:1;h.stroked=true;h.endcap=j;h.strokeColor=o.color;h.strokeWeight=o.weight+"px";if(!this._strokeNode){this._strokeNode=this._createGraphicNode("stroke");h.appendChild(this._strokeNode);}this._strokeNode.opacity=o.alpha;if(d.Lang.isArray(g)){l=[];m=g.length;for(k=0;k<m;++k){f=g[k];l[k]=f/o.weight;}}this._strokeNode.dashstyle=l;}else{h.stroked=false;}},_fillChangeHandler:function(j){var h=this.get("node"),i=this.get("fill"),f,g;if(i){g=i.alpha;if(!i.color){h.filled=false;}else{if(d.Lang.isNumber(g)){g=Math.max(Math.min(g,1),0);if(!this._fillNode){this._fillNode=this._createGraphicNode("fill");h.appendChild(this._fillNode);}i.alpha=g;this._fillNode.opacity=g;this._fillNode.color=i.color;}else{if(this._fillNode){h.removeChild(this._fillNode);this._fillNode=null;}h.fillColor=i.color;}}}else{h.filled=false;}},translate:function(e,k){var j=this.get("node"),g=this.get("width"),i=this.get("height"),f=j.coordSize;e=0-(f.x/g*e);k=0-(f.y/i*k);j.coordOrigin=e+","+k;},skewX:function(e){},skewY:function(e){},rotate:function(f,g){var e=this.get("node");e.style.rotation=f;},scale:function(e){},matrix:function(h,g,l,k,j,i){},_draw:function(){var i=this.get("node"),e=this.get("x"),j=this.get("y"),f=this.get("width"),g=this.get("height");i.style.position="absolute";i.style.left=e+"px";i.style.top=j+"px";i.style.width=f+"px";i.style.height=g+"px";this._fillChangeHandler();this._strokeChangeHandler();},_createGraphicNode:function(e){e=e||this._type;return document.createElement("<"+e+' xmlns="urn:schemas-microsft.com:vml" class="vml'+e+'"/>');}},{ATTRS:{x:{value:0,setter:function(f){var e=this.get("node");e.style.left=f+"px";return f;}},y:{value:0,setter:function(f){var e=this.get("node");e.style.top=f+"px";return f;}},node:{readOnly:true,valueFn:"_getNode"},id:{valueFn:function(){return d.guid();},setter:function(f){var e=this.get("node");e.setAttribute("id",f);return f;}},width:{value:0,setter:function(f){var e=this.get("node");e.setAttribute("width",f);e.style.width=f+"px";return f;}},height:{value:0,setter:function(f){var e=this.get("node");e.setAttribute("height",f);e.style.height=f+"px";return f;}},visible:{value:true,setter:function(f){var e=f?"visible":"hidden";this.get("node").style.visibility=e;return f;}},fill:{setter:function(f){var e=this.get("fill")||this._getAttrCfg("fill").defaultValue;return(f)?d.merge(e,f):null;}},stroke:{valueFn:function(){return{weight:1,dashstyle:"none",color:"#000",alpha:1};},setter:function(f){var e=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;return(f)?d.merge(e,f):null;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"}}});d.Path=d.Base.create("path",d.Shape,[d.Drawing],{_type:"shape",_draw:function(){var k=this.get("fill"),j=this.get("stroke"),g=this.get("node"),e=this.get("width"),f=this.get("height"),i=this.get("path");this._fillChangeHandler();this._strokeChangeHandler();if(i){if(k&&k.color){i+=" x";
-}if(j){i+=" e";}}if(i){g.path=i;}if(e&&f){g.coordSize=e+", "+f;g.style.position="absolute";g.style.width=e+"px";g.style.height=f+"px";}this.set("path",i);},end:function(){this._draw();},clear:function(){this.set("path","");}},{ATTRS:{width:{getter:function(){return this._width;},setter:function(e){this._width=e;return e;}},height:{getter:function(){return this._height;},setter:function(e){this._height=e;return e;}},path:{getter:function(){return this._path;},setter:function(e){this._path=e;return e;}}}});d.Rect=d.Base.create("rect",d.Shape,[],{_type:"rect"});d.Ellipse=d.Base.create("ellipse",d.Shape,[],{_type:"oval"},{ATTRS:{xRadius:{lazyAdd:false,getter:function(){var e=this.get("width");e=Math.round((e/2)*100)/100;return e;},setter:function(f){var e=f*2;this.set("width",e);return f;}},yRadius:{lazyAdd:false,getter:function(){var e=this.get("height");e=Math.round((e/2)*100)/100;return e;},setter:function(f){var e=f*2;this.set("height",e);return f;}}}});d.Circle=d.Base.create("circle",d.Shape,[],{_type:"oval"},{ATTRS:{radius:{lazyAdd:false,value:0,setter:function(g){var f=this.get("node"),e=g*2;f.style.width=e+"px";f.style.height=e+"px";return g;}},width:{readOnly:true,getter:function(){var e=this.get("radius"),f=e&&e>0?e*2:0;return f;}},height:{readOnly:true,getter:function(){var e=this.get("radius"),f=e&&e>0?e*2:0;return f;}}}});var c=function(e){this.initializer.apply(this,arguments);};c.prototype={initializer:function(f){f=f||{};var e=f.width||0,g=f.height||0;this.id=d.guid();this.node=this._createGraphic();this.node.setAttribute("id",this.id);this.setSize(e,g);this._initProps();},clear:function(){this._path="";this._removeChildren(this.node);},destroy:function(){this._removeChildren(this.node);this.node.parentNode.removeChild(this.node);},_removeChildren:function(e){if(e.hasChildNodes()){var f;while(e.firstChild){f=e.firstChild;this._removeChildren(f);e.removeChild(f);}}},toggleVisible:function(e){this._toggleVisible(this.node,e);},_toggleVisible:function(j,k){var h=d.one(j).get("children"),f=k?"visible":"hidden",g=0,e;if(h){e=h.length;for(;g<e;++g){this._toggleVisible(h[g],k);}}j.style.visibility=f;},setSize:function(e,f){e=Math.round(e);f=Math.round(f);this.node.style.width=e+"px";this.node.style.height=f+"px";this.node.coordSize=e+" "+f;this._canvasWidth=e;this._canvasHeight=f;},setPosition:function(e,f){e=Math.round(e);f=Math.round(f);this.node.style.left=e+"px";this.node.style.top=f+"px";},render:function(e){var f=parseInt(e.getComputedStyle("width"),10),g=parseInt(e.getComputedStyle("height"),10);e=e||d.config.doc.body;e.appendChild(this.node);this.setSize(f,g);this._initProps();return this;},_trackSize:function(e,f){if(e>this._width){this._width=e;}if(f>this._height){this._height=f;}},_initProps:function(){this._fillColor=null;this._strokeColor=null;this._strokeOpacity=null;this._strokeWeight=0;this._fillProps=null;this._path="";this._width=0;this._height=0;this._x=0;this._y=0;this._fill=null;this._stroke=0;this._stroked=false;this._dashstyle=null;},_createGraphic:function(){var e=this._createGraphicNode("group");e.style.display="block";e.style.position="absolute";return e;},_createGraphicNode:function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsft.com:vml" class="vml'+e+'"/>');},addShape:function(e){var f=e.get("node");this.node.appendChild(f);if(!this._graphicsList){this._graphicsList=[];}if(!this._shapes){this._shapes={};}this._graphicsList.push(f);this._shapes[e.get("id")]=e;},getShape:function(e){return this._shapes[e];},addChild:function(e){this.node.appendChild(e);}};d.Graphic=c;},"@VERSION@",{requires:["graphics"],skinnable:false});
+YUI.add("gallery-graphics-vml",function(d){var b=document.createStyleSheet();b.addRule(".vmlgroup","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlgroup","display:inline-block",b.rules.length);b.addRule(".vmlgroup","zoom:1",b.rules.length);b.addRule(".vmlshape","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlshape","display:inline-block",b.rules.length);b.addRule(".vmloval","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmloval","display:inline-block",b.rules.length);b.addRule(".vmlrect","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlrect","display:block",b.rules.length);b.addRule(".vmlfill","behavior:url(#default#VML)",b.rules.length);b.addRule(".vmlstroke","behavior:url(#default#VML)",b.rules.length);function a(){}a.prototype={_currentX:0,_currentY:0,curveTo:function(h,g,m,l,k,j){var i,e,f,n;this._path+=" c "+Math.round(h)+", "+Math.round(g)+", "+Math.round(m)+", "+Math.round(l)+", "+k+", "+j;this._currentX=k;this._currentY=j;i=Math.max(k,Math.max(h,m));f=Math.max(j,Math.max(g,l));e=Math.min(k,Math.min(h,m));n=Math.min(j,Math.min(g,l));this._trackSize(i,f);this._trackSize(e,n);},quadraticCurveTo:function(j,i,l,k){var f=this._currentX,e=this._currentY,h=f+0.67*(j-f),g=e+0.67*(i-e),n=h+(l-f)*0.34,m=g+(k-e)*0.34;this.curveTo(h,g,n,m,l,k);},drawRect:function(e,i,f,g){this.moveTo(e,i);this.lineTo(e+f,i);this.lineTo(e+f,i+g);this.lineTo(e,i+g);this.lineTo(e,i);this._currentX=e;this._currentY=i;return this;},drawRoundRect:function(e,k,f,i,g,j){this.moveTo(e,k+j);this.lineTo(e,k+i-j);this.quadraticCurveTo(e,k+i,e+g,k+i);this.lineTo(e+f-g,k+i);this.quadraticCurveTo(e+f,k+i,e+f,k+i-j);this.lineTo(e+f,k+j);this.quadraticCurveTo(e+f,k,e+f-g,k);this.lineTo(e+g,k);this.quadraticCurveTo(e,k,e,k+j);return this;},drawWedge:function(g,k,i,h,f,e){var j=f*2;e=e||f;this._path+=this._getWedgePath({x:g,y:k,startAngle:i,arc:h,radius:f,yRadius:e});this._trackSize(j,j);this._currentX=g;this._currentY=k;return this;},_getWedgePath:function(h){var g=h.x,l=h.y,j=h.startAngle,i=h.arc,f=h.radius,e=h.yRadius||f,k;if(Math.abs(i)>360){i=360;}j*=-65535;i*=65536;k=" m "+g+" "+l+" ae "+g+" "+l+" "+f+" "+e+" "+j+" "+i;return k;},end:function(){this._draw();},lineTo:function(k,j,g){var f=arguments,h,e;if(typeof k==="string"||typeof k==="number"){f=[[k,j]];}e=f.length;if(!this._path){this._path="";}this._path+=" l ";for(h=0;h<e;++h){this._path+=" "+Math.round(f[h][0])+", "+Math.round(f[h][1]);this._trackSize.apply(this,f[h]);this._currentX=f[h][0];this._currentY=f[h][1];}var l=this._path;return this;},moveTo:function(e,f){if(!this._path){this._path="";}this._path+=" m "+Math.round(e)+", "+Math.round(f);this._trackSize(e,f);this._currentX=e;this._currentY=f;},_trackSize:function(e,g){var i=this._width||0,f=this._height||0;if(e>i){this._width=e;}if(g>f){this._height=g;}}};d.Drawing=a;d.Shape=d.Base.create("shape",d.Base,[],{initializer:function(){this.publish("shapeUpdate");this._addListeners();this._draw();},_getNode:function(){var e=this._createGraphicNode();e.setAttribute("id",this.get("id"));d.one(e).addClass("yui3-"+this.name);return e;},_addListeners:function(){this.after("strokeChange",this._strokeChangeHandler);this.after("fillChange",this._fillChangeHandler);},_strokeChangeHandler:function(n){var h=this.get("node"),o=this.get("stroke"),p,g,l="",f,j,k=0,m;if(o&&o.weight&&o.weight>0){p=o.alpha;g=o.dashstyle||"none";j=o.endcap||"flat";o.color=o.color||"#000000";o.weight=o.weight||1;o.alpha=d.Lang.isNumber(p)?p:1;h.stroked=true;h.endcap=j;h.strokeColor=o.color;h.strokeWeight=o.weight+"px";if(!this._strokeNode){this._strokeNode=this._createGraphicNode("stroke");h.appendChild(this._strokeNode);}this._strokeNode.opacity=o.alpha;if(d.Lang.isArray(g)){l=[];m=g.length;for(k=0;k<m;++k){f=g[k];l[k]=f/o.weight;}}this._strokeNode.dashstyle=l;}else{h.stroked=false;}},_fillChangeHandler:function(j){var h=this.get("node"),i=this.get("fill"),f,g;if(i){g=i.alpha;if(!i.color){h.filled=false;}else{if(d.Lang.isNumber(g)){g=Math.max(Math.min(g,1),0);if(!this._fillNode){this._fillNode=this._createGraphicNode("fill");h.appendChild(this._fillNode);}i.alpha=g;this._fillNode.opacity=g;this._fillNode.color=i.color;}else{if(this._fillNode){h.removeChild(this._fillNode);this._fillNode=null;}h.fillColor=i.color;}}}else{h.filled=false;}},translate:function(e,k){var j=this.get("node"),g=this.get("width"),i=this.get("height"),f=j.coordSize;e=0-(f.x/g*e);k=0-(f.y/i*k);this._translateX=e;this._translateY=k;j.coordOrigin=e+","+k;this.fire("shapeUpdate");},skewX:function(e){},skewY:function(e){},rotate:function(f,g){var e=this.get("node");e.style.rotation=f;this.fire("shapeUpdate");},scale:function(e){},matrix:function(h,g,l,k,j,i){},_draw:function(){var i=this.get("node"),e=this.get("x"),j=this.get("y"),f=this.get("width"),g=this.get("height");i.style.visible="hidden";i.style.position="absolute";i.style.left=e+"px";i.style.top=j+"px";i.style.width=f+"px";i.style.height=g+"px";this._fillChangeHandler();this._strokeChangeHandler();this.fire("shapeUpdate");i.style.visible="visible";},_createGraphicNode:function(e){e=e||this._type;return document.createElement("<"+e+' xmlns="urn:schemas-microsft.com:vml" class="vml'+e+'"/>');},getBounds:function(){var g=this.get("width"),i=this.get("height"),k=this.get("stroke"),f=this.get("x"),l=this.get("y"),e=0,j={};if(k&&k.weight){e=k.weight;}j.left=f-e;j.top=l-e;j.right=f+g+e;j.bottom=l+i+e;return j;}},{ATTRS:{x:{value:0,setter:function(f){var e=this.get("node");e.style.left=f+"px";return f;}},y:{value:0,setter:function(f){var e=this.get("node");e.style.top=f+"px";return f;}},node:{readOnly:true,valueFn:"_getNode"},id:{valueFn:function(){return d.guid();},setter:function(f){var e=this.get("node");e.setAttribute("id",f);return f;}},width:{value:0,setter:function(f){var e=this.get("node");e.setAttribute("width",f);e.style.width=f+"px";return f;}},height:{value:0,setter:function(f){var e=this.get("node");e.setAttribute("height",f);e.style.height=f+"px";return f;}},visible:{value:true,setter:function(f){var e=f?"visible":"hidden";
+this.get("node").style.visibility=e;return f;}},fill:{setter:function(f){var e=this.get("fill")||this._getAttrCfg("fill").defaultValue;return(f)?d.merge(e,f):null;}},stroke:{valueFn:function(){return{weight:1,dashstyle:"none",color:"#000",alpha:1};},setter:function(f){var e=this.get("stroke")||this._getAttrCfg("stroke").defaultValue;return(f)?d.merge(e,f):null;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"},graphic:{setter:function(e){this.after("shapeUpdate",d.bind(e.updateSize,e));return e;}}}});d.Path=d.Base.create("path",d.Shape,[d.Drawing],{_type:"shape",_draw:function(){var l=this.get("fill"),k=this.get("stroke"),g=this.get("node"),e=this.get("width"),f=this.get("height"),j=this.get("path"),i="";g.style.visible="hidden";this._fillChangeHandler();this._strokeChangeHandler();if(j){if(l&&l.color){i+=" x";}if(k){i+=" e";}}if(j){g.path=j+i;}if(e&&f){g.coordSize=e+", "+f;g.style.position="absolute";g.style.width=e+"px";g.style.height=f+"px";}this.set("path",j);this.fire("shapeUpdate");g.style.visible="visible";},end:function(){this._draw();},clear:function(){this.set("path","");}},{ATTRS:{width:{getter:function(){return this._width;},setter:function(e){this._width=e;return e;}},height:{getter:function(){return this._height;},setter:function(e){this._height=e;return e;}},path:{getter:function(){return this._path;},setter:function(e){this._path=e;return e;}}}});d.Rect=d.Base.create("rect",d.Shape,[],{_type:"rect"});d.Ellipse=d.Base.create("ellipse",d.Shape,[],{_type:"oval"},{ATTRS:{xRadius:{lazyAdd:false,getter:function(){var e=this.get("width");e=Math.round((e/2)*100)/100;return e;},setter:function(f){var e=f*2;this.set("width",e);return f;}},yRadius:{lazyAdd:false,getter:function(){var e=this.get("height");e=Math.round((e/2)*100)/100;return e;},setter:function(f){var e=f*2;this.set("height",e);return f;}}}});d.Circle=d.Base.create("circle",d.Shape,[],{_type:"oval"},{ATTRS:{radius:{lazyAdd:false,value:0,setter:function(g){var f=this.get("node"),e=g*2;f.style.width=e+"px";f.style.height=e+"px";return g;}},width:{readOnly:true,getter:function(){var e=this.get("radius"),f=e&&e>0?e*2:0;return f;}},height:{readOnly:true,getter:function(){var e=this.get("radius"),f=e&&e>0?e*2:0;return f;}}}});var c=function(e){this.initializer.apply(this,arguments);};c.prototype={initializer:function(f){f=f||{};var e=f.width||0,g=f.height||0;this.id=d.guid();this.node=this._createGraphic();this.node.setAttribute("id",this.id);this.setSize(e,g);this._initProps();},clear:function(){this._path="";this._removeChildren(this.node);},destroy:function(){this._removeChildren(this.node);this.node.parentNode.removeChild(this.node);},_removeChildren:function(e){if(e.hasChildNodes()){var f;while(e.firstChild){f=e.firstChild;this._removeChildren(f);e.removeChild(f);}}},toggleVisible:function(e){this._toggleVisible(this.node,e);},_toggleVisible:function(j,k){var h=d.one(j).get("children"),f=k?"visible":"hidden",g=0,e;if(h){e=h.length;for(;g<e;++g){this._toggleVisible(h[g],k);}}j.style.visibility=f;},setSize:function(e,f){e=Math.round(e);f=Math.round(f);this.node.style.width=e+"px";this.node.style.height=f+"px";this.node.coordSize=e+" "+f;this._canvasWidth=e;this._canvasHeight=f;},setPosition:function(e,f){e=Math.round(e);f=Math.round(f);this.node.style.left=e+"px";this.node.style.top=f+"px";},render:function(e){var f=parseInt(e.getComputedStyle("width"),10),g=parseInt(e.getComputedStyle("height"),10);e=e||d.config.doc.body;e.appendChild(this.node);this.setSize(f,g);this._initProps();return this;},_trackSize:function(e,f){if(e>this._width){this._width=e;}if(f>this._height){this._height=f;}},_initProps:function(){this._fillColor=null;this._strokeColor=null;this._strokeOpacity=null;this._strokeWeight=0;this._fillProps=null;this._path="";this._width=0;this._height=0;this._x=0;this._y=0;this._fill=null;this._stroke=0;this._stroked=false;this._dashstyle=null;},_createGraphic:function(){var e=this._createGraphicNode("group");e.style.display="block";e.style.position="absolute";return e;},_createGraphicNode:function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsft.com:vml" class="vml'+e+'"/>');},addShape:function(e){var f=e.get("node");e.set("graphic",this);this.node.appendChild(f);if(!this._graphicsList){this._graphicsList=[];}if(!this._shapes){this._shapes={};}this._graphicsList.push(f);this._shapes[e.get("id")]=e;},getShape:function(e){return this._shapes[e];},addChild:function(e){this.node.appendChild(e);},updateSize:function(o){var n,l=0,k,j=this._graphicsList,f=j.length,g,m;this._left=0;this._right=0;this._top=0;this._bottom=0;for(;l<f;++l){k=this.getShape(j[l].getAttribute("id"));n=k.getBounds();this._left=Math.min(this._left,n.left);this._top=Math.min(this._top,n.top);this._right=Math.max(this._right,n.right);this._bottom=Math.max(this._bottom,n.bottom);}g=this._width=this._right-this._left;m=this._height=this._bottom-this._top;this.setSize(this._width,this._height);},_left:0,_right:0,_top:0,_bottom:0};d.Graphic=c;},"@VERSION@",{requires:["graphics"],skinnable:false});
162 build/gallery-graphics-vml/gallery-graphics-vml.js
View
@@ -17,6 +17,16 @@ function Drawing() {}
Drawing.prototype = {
/**
+ * @private
+ */
+ _currentX: 0,
+
+ /**
+ * @private
+ */
+ _currentY: 0,
+
+ /**
* Draws a bezier curve.
*
* @method curveTo
@@ -28,8 +38,19 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
+ var hiX,
+ loX,
+ hiY,
+ loY;
this._path += ' c ' + Math.round(cp1x) + ", " + Math.round(cp1y) + ", " + Math.round(cp2x) + ", " + Math.round(cp2y) + ", " + x + ", " + y;
- this._trackSize(x, y);
+ this._currentX = x;
+ this._currentY = y;
+ hiX = Math.max(x, Math.max(cp1x, cp2x));
+ hiY = Math.max(y, Math.max(cp1y, cp2y));
+ loX = Math.min(x, Math.min(cp1x, cp2x));
+ loY = Math.min(y, Math.min(cp1y, cp2y));
+ this._trackSize(hiX, hiY);
+ this._trackSize(loX, loY);
},
/**
@@ -42,13 +63,13 @@ Drawing.prototype = {
* @param {Number} y y-coordinate for the end point.
*/
quadraticCurveTo: function(cpx, cpy, x, y) {
- var hiX = Math.max(x, cpx),
- hiY = Math.max(y, cpy),
- loX = Math.min(x, cpx),
- loY = Math.min(y, cpy);
- this._path += ' qb ' + cpx + ", " + cpy + ", " + x + ", " + y;
- this._trackSize(hiX, hiY);
- this._trackSize(loX, loY);
+ var currentX = this._currentX,
+ currentY = this._currentY,
+ cp1x = currentX + 0.67*(cpx - currentX),
+ cp1y = currentY + 0.67*(cpy - currentY),
+ cp2x = cp1x + (x - currentX) * 0.34,
+ cp2y = cp1y + (y - currentY) * 0.34;
+ this.curveTo( cp1x, cp1y, cp2x, cp2y, x, y );
},
/**
@@ -66,6 +87,9 @@ Drawing.prototype = {
this.lineTo(x + w, y + h);
this.lineTo(x, y + h);
this.lineTo(x, y);
+ this._currentX = x;
+ this._currentY = y;
+ return this;
},
/**
@@ -89,6 +113,7 @@ Drawing.prototype = {
this.quadraticCurveTo(x + w, y, x + w - ew, y);
this.lineTo(x + ew, y);
this.quadraticCurveTo(x, y, x, y + eh);
+ return this;
},
/**
@@ -107,6 +132,9 @@ Drawing.prototype = {
yRadius = yRadius || radius;
this._path += this._getWedgePath({x:x, y:y, startAngle:startAngle, arc:arc, radius:radius, yRadius:yRadius});
this._trackSize(diameter, diameter);
+ this._currentX = x;
+ this._currentY = y;
+ return this;
},
/**
@@ -168,6 +196,8 @@ Drawing.prototype = {
for (i = 0; i < len; ++i) {
this._path += ' ' + Math.round(args[i][0]) + ', ' + Math.round(args[i][1]);
this._trackSize.apply(this, args[i]);
+ this._currentX = args[i][0];
+ this._currentY = args[i][1];
}
var path = this._path;
return this;
@@ -187,6 +217,8 @@ Drawing.prototype = {
}
this._path += ' m ' + Math.round(x) + ', ' + Math.round(y);
this._trackSize(x, y);
+ this._currentX = x;
+ this._currentY = y;
},
@@ -224,6 +256,7 @@ Y.Drawing = Drawing;
*/
initializer: function()
{
+ this.publish("shapeUpdate");
this._addListeners();
this._draw();
},
@@ -369,7 +402,10 @@ Y.Drawing = Drawing;
coordSize = node.coordSize;
x = 0 - (coordSize.x/w * x);
y = 0 - (coordSize.y/h * y);
+ this._translateX = x;
+ this._translateY = y;
node.coordOrigin = x + "," + y;
+ this.fire("shapeUpdate");
},
/**
@@ -404,6 +440,7 @@ Y.Drawing = Drawing;
{
var node = this.get("node");
node.style.rotation = deg;
+ this.fire("shapeUpdate");
},
/**
@@ -437,6 +474,7 @@ Y.Drawing = Drawing;
y = this.get("y"),
w = this.get("width"),
h = this.get("height");
+ node.style.visible = "hidden";
node.style.position = "absolute";
node.style.left = x + "px";
node.style.top = y + "px";
@@ -444,6 +482,8 @@ Y.Drawing = Drawing;
node.style.height = h + "px";
this._fillChangeHandler();
this._strokeChangeHandler();
+ this.fire("shapeUpdate");
+ node.style.visible = "visible";
},
/**
@@ -459,6 +499,32 @@ Y.Drawing = Drawing;
{
type = type || this._type;
return document.createElement('<' + type + ' xmlns="urn:schemas-microsft.com:vml" class="vml' + type + '"/>');
+ },
+
+ /**
+ * Returns the bounds for a shape.
+ *
+ * @method getBounds
+ * @return Object
+ */
+ getBounds: function()
+ {
+ var w = this.get("width"),
+ h = this.get("height"),
+ stroke = this.get("stroke"),
+ x = this.get("x"),
+ y = this.get("y"),
+ wt = 0,
+ bounds = {};
+ if(stroke && stroke.weight)
+ {
+ wt = stroke.weight;