fabric-rails 1.0.12.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +1 -1
  3. data/lib/fabric/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/cufon.js +1226 -0
  5. data/vendor/assets/javascripts/event.js +20 -20
  6. data/vendor/assets/javascripts/excanvas.js +1464 -0
  7. data/vendor/assets/javascripts/fabric.js +56 -33
  8. data/vendor/assets/javascripts/fabric/HEADER.js +2 -4
  9. data/vendor/assets/javascripts/fabric/brushes/base_brush.class.js +96 -0
  10. data/vendor/assets/javascripts/fabric/brushes/circle_brush.class.js +99 -0
  11. data/vendor/assets/javascripts/fabric/brushes/pattern_brush.class.js +55 -0
  12. data/vendor/assets/javascripts/fabric/{freedrawing.class.js → brushes/pencil_brush.class.js} +73 -65
  13. data/vendor/assets/javascripts/fabric/brushes/spray_brush.class.js +157 -0
  14. data/vendor/assets/javascripts/fabric/canvas.class.js +154 -135
  15. data/vendor/assets/javascripts/fabric/color.class.js +195 -29
  16. data/vendor/assets/javascripts/fabric/filters/brightness_filter.class.js +70 -0
  17. data/vendor/assets/javascripts/fabric/filters/convolute_filter.class.js +122 -0
  18. data/vendor/assets/javascripts/fabric/filters/gradienttransparency_filter.class.js +69 -0
  19. data/vendor/assets/javascripts/fabric/filters/grayscale_filter.class.js +61 -0
  20. data/vendor/assets/javascripts/fabric/filters/invert_filter.class.js +57 -0
  21. data/vendor/assets/javascripts/fabric/filters/noise_filter.class.js +73 -0
  22. data/vendor/assets/javascripts/fabric/filters/pixelate_filter.class.js +98 -0
  23. data/vendor/assets/javascripts/fabric/filters/removewhite_filter.class.js +86 -0
  24. data/vendor/assets/javascripts/fabric/filters/sepia2_filter.class.js +61 -0
  25. data/vendor/assets/javascripts/fabric/filters/sepia_filter.class.js +58 -0
  26. data/vendor/assets/javascripts/fabric/filters/tint_filter.class.js +80 -0
  27. data/vendor/assets/javascripts/fabric/gradient.class.js +232 -80
  28. data/vendor/assets/javascripts/fabric/intersection.class.js +10 -28
  29. data/vendor/assets/javascripts/fabric/log.js +0 -2
  30. data/vendor/assets/javascripts/fabric/{canvas_animation.mixin.js → mixins/canvas_animation.mixin.js} +3 -6
  31. data/vendor/assets/javascripts/fabric/mixins/canvas_dataurl_exporter.mixin.js +137 -0
  32. data/vendor/assets/javascripts/fabric/{canvas_events.mixin.js → mixins/canvas_events.mixin.js} +97 -144
  33. data/vendor/assets/javascripts/fabric/{canvas_gestures.mixin.js → mixins/canvas_gestures.mixin.js} +4 -8
  34. data/vendor/assets/javascripts/fabric/{canvas_serialization.mixin.js → mixins/canvas_serialization.mixin.js} +19 -14
  35. data/vendor/assets/javascripts/fabric/mixins/collection.mixin.js +137 -0
  36. data/vendor/assets/javascripts/fabric/{object_geometry.mixin.js → mixins/object_geometry.mixin.js} +130 -47
  37. data/vendor/assets/javascripts/fabric/{object_interactivity.mixin.js → mixins/object_interactivity.mixin.js} +21 -102
  38. data/vendor/assets/javascripts/fabric/{object_origin.mixin.js → mixins/object_origin.mixin.js} +36 -26
  39. data/vendor/assets/javascripts/fabric/{object_straightening.mixin.js → mixins/object_straightening.mixin.js} +4 -9
  40. data/vendor/assets/javascripts/fabric/{observable.mixin.js → mixins/observable.mixin.js} +27 -35
  41. data/vendor/assets/javascripts/fabric/mixins/stateful.mixin.js +45 -0
  42. data/vendor/assets/javascripts/fabric/node.js +62 -26
  43. data/vendor/assets/javascripts/fabric/parser.js +181 -58
  44. data/vendor/assets/javascripts/fabric/pattern.class.js +43 -14
  45. data/vendor/assets/javascripts/fabric/point.class.js +4 -43
  46. data/vendor/assets/javascripts/fabric/shadow.class.js +19 -19
  47. data/vendor/assets/javascripts/fabric/{circle.class.js → shapes/circle.class.js} +32 -29
  48. data/vendor/assets/javascripts/fabric/{ellipse.class.js → shapes/ellipse.class.js} +45 -27
  49. data/vendor/assets/javascripts/fabric/{group.class.js → shapes/group.class.js} +67 -169
  50. data/vendor/assets/javascripts/fabric/{image.class.js → shapes/image.class.js} +134 -72
  51. data/vendor/assets/javascripts/fabric/{line.class.js → shapes/line.class.js} +67 -36
  52. data/vendor/assets/javascripts/fabric/{object.class.js → shapes/object.class.js} +394 -252
  53. data/vendor/assets/javascripts/fabric/{path.class.js → shapes/path.class.js} +89 -174
  54. data/vendor/assets/javascripts/fabric/{path_group.class.js → shapes/path_group.class.js} +12 -18
  55. data/vendor/assets/javascripts/fabric/{polygon.class.js → shapes/polygon.class.js} +64 -38
  56. data/vendor/assets/javascripts/fabric/{polyline.class.js → shapes/polyline.class.js} +64 -39
  57. data/vendor/assets/javascripts/fabric/{rect.class.js → shapes/rect.class.js} +78 -112
  58. data/vendor/assets/javascripts/fabric/{text.class.js → shapes/text.class.js} +264 -270
  59. data/vendor/assets/javascripts/fabric/shapes/text.cufon.js +79 -0
  60. data/vendor/assets/javascripts/fabric/{triangle.class.js → shapes/triangle.class.js} +46 -26
  61. data/vendor/assets/javascripts/fabric/static_canvas.class.js +134 -358
  62. data/vendor/assets/javascripts/fabric/util/anim_ease.js +2 -31
  63. data/vendor/assets/javascripts/fabric/util/dom_event.js +21 -7
  64. data/vendor/assets/javascripts/fabric/util/dom_misc.js +49 -39
  65. data/vendor/assets/javascripts/fabric/util/dom_request.js +1 -2
  66. data/vendor/assets/javascripts/fabric/util/dom_style.js +1 -2
  67. data/vendor/assets/javascripts/fabric/util/lang_array.js +19 -13
  68. data/vendor/assets/javascripts/fabric/util/lang_class.js +1 -2
  69. data/vendor/assets/javascripts/fabric/util/lang_function.js +3 -1
  70. data/vendor/assets/javascripts/fabric/util/lang_object.js +5 -5
  71. data/vendor/assets/javascripts/fabric/util/lang_string.js +7 -5
  72. data/vendor/assets/javascripts/fabric/util/misc.js +207 -42
  73. metadata +47 -29
  74. data/vendor/assets/javascripts/fabric/image_filters.js +0 -809
  75. data/vendor/assets/javascripts/fabric/scout.js +0 -45
  76. data/vendor/assets/javascripts/fabric/stateful.js +0 -88
@@ -13,21 +13,35 @@
13
13
 
14
14
  /**
15
15
  * Ellipse class
16
- * @class Ellipse
16
+ * @class fabric.Ellipse
17
17
  * @extends fabric.Object
18
+ * @return {fabric.Ellipse} thisArg
18
19
  */
19
- fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @scope fabric.Ellipse.prototype */ {
20
+ fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @lends fabric.Ellipse.prototype */ {
20
21
 
21
22
  /**
22
23
  * Type of an object
23
- * @property
24
24
  * @type String
25
+ * @default
25
26
  */
26
27
  type: 'ellipse',
27
28
 
29
+ /**
30
+ * Horizontal radius
31
+ * @type Number
32
+ * @default
33
+ */
34
+ rx: 0,
35
+
36
+ /**
37
+ * Vertical radius
38
+ * @type Number
39
+ * @default
40
+ */
41
+ ry: 0,
42
+
28
43
  /**
29
44
  * Constructor
30
- * @method initialize
31
45
  * @param {Object} [options] Options object
32
46
  * @return {fabric.Ellipse} thisArg
33
47
  */
@@ -45,7 +59,6 @@
45
59
 
46
60
  /**
47
61
  * Returns object representation of an instance
48
- * @method toObject
49
62
  * @param {Array} propertiesToInclude
50
63
  * @return {Object} object representation of an instance
51
64
  */
@@ -56,25 +69,36 @@
56
69
  });
57
70
  },
58
71
 
72
+ /* _TO_SVG_START_ */
59
73
  /**
60
74
  * Returns svg representation of an instance
61
- * @method toSVG
62
75
  * @return {String} svg representation of an instance
63
76
  */
64
77
  toSVG: function() {
65
- return [
78
+ var markup = [];
79
+
80
+ if (this.fill && this.fill.toLive) {
81
+ markup.push(this.fill.toSVG(this, false));
82
+ }
83
+ if (this.stroke && this.stroke.toLive) {
84
+ markup.push(this.stroke.toSVG(this, false));
85
+ }
86
+
87
+ markup.push(
66
88
  '<ellipse ',
67
- 'rx="', this.get('rx'), '" ',
68
- 'ry="', this.get('ry'), '" ',
69
- 'style="', this.getSvgStyles(), '" ',
70
- 'transform="', this.getSvgTransform(), '" ',
71
- '/>'
72
- ].join('');
89
+ 'rx="', this.get('rx'),
90
+ '" ry="', this.get('ry'),
91
+ '" style="', this.getSvgStyles(),
92
+ '" transform="', this.getSvgTransform(),
93
+ '"/>'
94
+ );
95
+
96
+ return markup.join('');
73
97
  },
98
+ /* _TO_SVG_END_ */
74
99
 
75
100
  /**
76
101
  * Renders this instance on a given context
77
- * @method render
78
102
  * @param ctx {CanvasRenderingContext2D} context to render on
79
103
  * @param noTransform {Boolean} context is not transformed when set to true
80
104
  */
@@ -86,7 +110,6 @@
86
110
 
87
111
  /**
88
112
  * @private
89
- * @method _render
90
113
  * @param ctx {CanvasRenderingContext2D} context to render on
91
114
  */
92
115
  _render: function(ctx, noTransform) {
@@ -98,19 +121,14 @@
98
121
  }
99
122
  ctx.transform(1, 0, 0, this.ry/this.rx, 0, 0);
100
123
  ctx.arc(noTransform ? this.left : 0, noTransform ? this.top : 0, this.rx, 0, piBy2, false);
101
- if (this.stroke) {
102
- ctx.stroke();
103
- }
104
- this._removeShadow(ctx);
105
- if (this.fill) {
106
- ctx.fill();
107
- }
124
+
125
+ this._renderFill(ctx);
126
+ this._renderStroke(ctx);
108
127
  ctx.restore();
109
128
  },
110
129
 
111
130
  /**
112
131
  * Returns complexity of an instance
113
- * @method complexity
114
132
  * @return {Number} complexity
115
133
  */
116
134
  complexity: function() {
@@ -118,17 +136,17 @@
118
136
  }
119
137
  });
120
138
 
139
+ /* _FROM_SVG_START_ */
121
140
  /**
122
141
  * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement})
123
142
  * @static
124
143
  * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement
125
144
  */
126
- fabric.Ellipse.ATTRIBUTE_NAMES = 'cx cy rx ry fill fill-opacity opacity stroke stroke-width transform'.split(' ');
145
+ fabric.Ellipse.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy rx ry'.split(' '));
127
146
 
128
147
  /**
129
148
  * Returns {@link fabric.Ellipse} instance from an SVG element
130
149
  * @static
131
- * @method fabric.Ellipse.fromElement
132
150
  * @param {SVGElement} element Element to parse
133
151
  * @param {Object} [options] Options object
134
152
  * @return {fabric.Ellipse}
@@ -154,11 +172,11 @@
154
172
 
155
173
  return ellipse;
156
174
  };
175
+ /* _FROM_SVG_END_ */
157
176
 
158
177
  /**
159
178
  * Returns {@link fabric.Ellipse} instance from an object representation
160
179
  * @static
161
- * @method fabric.Ellipse.fromObject
162
180
  * @param {Object} object Object to create an instance from
163
181
  * @return {fabric.Ellipse}
164
182
  */
@@ -166,4 +184,4 @@
166
184
  return new fabric.Ellipse(object);
167
185
  };
168
186
 
169
- })(typeof exports !== 'undefined' ? exports : this);
187
+ })(typeof exports !== 'undefined' ? exports : this);
@@ -6,8 +6,7 @@
6
6
  extend = fabric.util.object.extend,
7
7
  min = fabric.util.array.min,
8
8
  max = fabric.util.array.max,
9
- invoke = fabric.util.array.invoke,
10
- removeFromArray = fabric.util.removeFromArray;
9
+ invoke = fabric.util.array.invoke;
11
10
 
12
11
  if (fabric.Group) {
13
12
  return;
@@ -27,21 +26,21 @@
27
26
 
28
27
  /**
29
28
  * Group class
30
- * @class Group
29
+ * @class fabric.Group
31
30
  * @extends fabric.Object
31
+ * @extends fabric.Collection
32
32
  */
33
- fabric.Group = fabric.util.createClass(fabric.Object, /** @scope fabric.Group.prototype */ {
33
+ fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @lends fabric.Group.prototype */ {
34
34
 
35
35
  /**
36
36
  * Type of an object
37
- * @property
38
37
  * @type String
38
+ * @default
39
39
  */
40
40
  type: 'group',
41
41
 
42
42
  /**
43
43
  * Constructor
44
- * @method initialized
45
44
  * @param {Object} objects Group objects
46
45
  * @param {Object} [options] Options object
47
46
  * @return {Object} thisArg
@@ -49,9 +48,12 @@
49
48
  initialize: function(objects, options) {
50
49
  options = options || { };
51
50
 
52
- this.objects = objects || [];
53
- this.originalState = { };
51
+ this._objects = objects || [];
52
+ for (var i = this._objects.length; i--; ) {
53
+ this._objects[i].group = this;
54
+ }
54
55
 
56
+ this.originalState = { };
55
57
  this.callSuper('initialize');
56
58
 
57
59
  this._calcBounds();
@@ -62,16 +64,12 @@
62
64
  }
63
65
  this._setOpacityIfSame();
64
66
 
65
- // group is active by default
66
67
  this.setCoords(true);
67
68
  this.saveCoords();
68
-
69
- //this.activateAllObjects();
70
69
  },
71
70
 
72
71
  /**
73
72
  * @private
74
- * @method _updateObjectsCoords
75
73
  */
76
74
  _updateObjectsCoords: function() {
77
75
  var groupDeltaX = this.left,
@@ -91,13 +89,13 @@
91
89
  object.setCoords();
92
90
 
93
91
  // do not display corners of objects enclosed in a group
92
+ object.__origHasControls = object.hasControls;
94
93
  object.hasControls = false;
95
94
  }, this);
96
95
  },
97
96
 
98
97
  /**
99
98
  * Returns string represenation of a group
100
- * @method toString
101
99
  * @return {String}
102
100
  */
103
101
  toString: function() {
@@ -106,23 +104,24 @@
106
104
 
107
105
  /**
108
106
  * Returns an array of all objects in this group
109
- * @method getObjects
110
107
  * @return {Array} group objects
111
108
  */
112
109
  getObjects: function() {
113
- return this.objects;
110
+ return this._objects;
114
111
  },
115
112
 
116
113
  /**
117
114
  * Adds an object to a group; Then recalculates group's dimension, position.
118
- * @method addWithUpdate
119
115
  * @param {Object} object
120
116
  * @return {fabric.Group} thisArg
121
117
  * @chainable
122
118
  */
123
119
  addWithUpdate: function(object) {
124
120
  this._restoreObjectsState();
125
- this.objects.push(object);
121
+ this._objects.push(object);
122
+ object.group = this;
123
+ // since _restoreObjectsState set objects inactive
124
+ this.forEachObject(function(o){ o.set('active', true); o.group = this; }, this);
126
125
  this._calcBounds();
127
126
  this._updateObjectsCoords();
128
127
  return this;
@@ -130,53 +129,39 @@
130
129
 
131
130
  /**
132
131
  * Removes an object from a group; Then recalculates group's dimension, position.
133
- * @method removeWithUpdate
134
132
  * @param {Object} object
135
133
  * @return {fabric.Group} thisArg
136
134
  * @chainable
137
135
  */
138
136
  removeWithUpdate: function(object) {
139
137
  this._restoreObjectsState();
140
- removeFromArray(this.objects, object);
141
- object.setActive(false);
138
+ // since _restoreObjectsState set objects inactive
139
+ this.forEachObject(function(o){ o.set('active', true); o.group = this; }, this);
140
+
141
+ this.remove(object);
142
142
  this._calcBounds();
143
143
  this._updateObjectsCoords();
144
144
  return this;
145
145
  },
146
146
 
147
147
  /**
148
- * Adds an object to a group
149
- * @method add
150
- * @param {Object} object
151
- * @return {fabric.Group} thisArg
152
- * @chainable
153
- */
154
- add: function(object) {
155
- this.objects.push(object);
156
- return this;
157
- },
158
-
159
- /**
160
- * Removes an object from a group
161
- * @method remove
162
- * @param {Object} object
163
- * @return {fabric.Group} thisArg
164
- * @chainable
148
+ * @private
165
149
  */
166
- remove: function(object) {
167
- removeFromArray(this.objects, object);
168
- return this;
150
+ _onObjectAdded: function(object) {
151
+ object.group = this;
169
152
  },
170
153
 
171
154
  /**
172
- * Returns a size of a group (i.e: length of an array containing its objects)
173
- * @return {Number} Group size
155
+ * @private
174
156
  */
175
- size: function() {
176
- return this.getObjects().length;
157
+ _onObjectRemoved: function(object) {
158
+ delete object.group;
159
+ object.set('active', false);
177
160
  },
178
161
 
179
162
  /**
163
+ * @param delegatedProperties
164
+ * @type Object
180
165
  * Properties that are delegated to group objects when reading/writing
181
166
  */
182
167
  delegatedProperties: {
@@ -184,9 +169,12 @@
184
169
  opacity: true,
185
170
  fontFamily: true,
186
171
  fontWeight: true,
172
+ fontSize: true,
173
+ fontStyle: true,
187
174
  lineHeight: true,
188
175
  textDecoration: true,
189
176
  textShadow: true,
177
+ textAlign: true,
190
178
  backgroundColor: true
191
179
  },
192
180
 
@@ -195,10 +183,10 @@
195
183
  */
196
184
  _set: function(key, value) {
197
185
  if (key in this.delegatedProperties) {
198
- var i = this.objects.length;
186
+ var i = this._objects.length;
199
187
  this[key] = value;
200
188
  while (i--) {
201
- this.objects[i].set(key, value);
189
+ this._objects[i].set(key, value);
202
190
  }
203
191
  }
204
192
  else {
@@ -206,46 +194,43 @@
206
194
  }
207
195
  },
208
196
 
209
- /**
210
- * Returns true if a group contains an object
211
- * @method contains
212
- * @param {Object} object Object to check against
213
- * @return {Boolean} `true` if group contains an object
214
- */
215
- contains: function(object) {
216
- return this.objects.indexOf(object) > -1;
217
- },
218
-
219
197
  /**
220
198
  * Returns object representation of an instance
221
- * @method toObject
222
199
  * @param {Array} propertiesToInclude
223
200
  * @return {Object} object representation of an instance
224
201
  */
225
202
  toObject: function(propertiesToInclude) {
226
203
  return extend(this.callSuper('toObject', propertiesToInclude), {
227
- objects: invoke(this.objects, 'toObject', propertiesToInclude)
204
+ objects: invoke(this._objects, 'toObject', propertiesToInclude)
228
205
  });
229
206
  },
230
207
 
231
208
  /**
232
209
  * Renders instance on a given context
233
- * @method render
234
210
  * @param {CanvasRenderingContext2D} ctx context to render instance on
211
+ * @param {Boolean} [noTransform] When true, context is not transformed
235
212
  */
236
213
  render: function(ctx, noTransform) {
214
+ // do not render if object is not visible
215
+ if (!this.visible) return;
216
+
237
217
  ctx.save();
238
218
  this.transform(ctx);
239
219
 
240
220
  var groupScaleFactor = Math.max(this.scaleX, this.scaleY);
241
221
 
222
+ this.clipTo && fabric.util.clipContext(this, ctx);
223
+
242
224
  //The array is now sorted in order of highest first, so start from end.
243
- for (var i = this.objects.length; i > 0; i--) {
225
+ for (var i = 0, len = this._objects.length; i < len; i++) {
244
226
 
245
- var object = this.objects[i-1],
227
+ var object = this._objects[i],
246
228
  originalScaleFactor = object.borderScaleFactor,
247
229
  originalHasRotatingPoint = object.hasRotatingPoint;
248
230
 
231
+ // do not render if object is not visible
232
+ if (!object.visible) continue;
233
+
249
234
  object.borderScaleFactor = groupScaleFactor;
250
235
  object.hasRotatingPoint = false;
251
236
 
@@ -254,6 +239,7 @@
254
239
  object.borderScaleFactor = originalScaleFactor;
255
240
  object.hasRotatingPoint = originalHasRotatingPoint;
256
241
  }
242
+ this.clipTo && ctx.restore();
257
243
 
258
244
  if (!noTransform && this.active) {
259
245
  this.drawBorders(ctx);
@@ -263,44 +249,20 @@
263
249
  this.setCoords();
264
250
  },
265
251
 
266
- /**
267
- * Returns object from the group at the specified index
268
- * @method item
269
- * @param index {Number} index of item to get
270
- * @return {fabric.Object}
271
- */
272
- item: function(index) {
273
- return this.getObjects()[index];
274
- },
275
-
276
- /**
277
- * Returns complexity of an instance
278
- * @method complexity
279
- * @return {Number} complexity
280
- */
281
- complexity: function() {
282
- return this.getObjects().reduce(function(total, object) {
283
- total += (typeof object.complexity === 'function') ? object.complexity() : 0;
284
- return total;
285
- }, 0);
286
- },
287
-
288
252
  /**
289
253
  * Retores original state of each of group objects (original state is that which was before group was created).
290
254
  * @private
291
- * @method _restoreObjectsState
292
255
  * @return {fabric.Group} thisArg
293
256
  * @chainable
294
257
  */
295
258
  _restoreObjectsState: function() {
296
- this.objects.forEach(this._restoreObjectState, this);
259
+ this._objects.forEach(this._restoreObjectState, this);
297
260
  return this;
298
261
  },
299
262
 
300
263
  /**
301
264
  * Restores original state of a specified object in group
302
265
  * @private
303
- * @method _restoreObjectState
304
266
  * @param {fabric.Object} object
305
267
  * @return {fabric.Group} thisArg
306
268
  */
@@ -309,28 +271,29 @@
309
271
  var groupLeft = this.get('left'),
310
272
  groupTop = this.get('top'),
311
273
  groupAngle = this.getAngle() * (Math.PI / 180),
312
- rotatedTop = Math.cos(groupAngle) * object.get('top') + Math.sin(groupAngle) * object.get('left'),
313
- rotatedLeft = -Math.sin(groupAngle) * object.get('top') + Math.cos(groupAngle) * object.get('left');
274
+ rotatedTop = Math.cos(groupAngle) * object.get('top') * this.get('scaleY') + Math.sin(groupAngle) * object.get('left') * this.get('scaleX'),
275
+ rotatedLeft = -Math.sin(groupAngle) * object.get('top') * this.get('scaleY') + Math.cos(groupAngle) * object.get('left') * this.get('scaleX');
314
276
 
315
277
  object.setAngle(object.getAngle() + this.getAngle());
316
278
 
317
- object.set('left', groupLeft + rotatedLeft * this.get('scaleX'));
318
- object.set('top', groupTop + rotatedTop * this.get('scaleY'));
279
+ object.set('left', groupLeft + rotatedLeft);
280
+ object.set('top', groupTop + rotatedTop);
319
281
 
320
282
  object.set('scaleX', object.get('scaleX') * this.get('scaleX'));
321
283
  object.set('scaleY', object.get('scaleY') * this.get('scaleY'));
322
284
 
323
285
  object.setCoords();
324
- object.hasControls = true;
325
- object.setActive(false);
286
+ object.hasControls = object.__origHasControls;
287
+ delete object.__origHasControls;
288
+ object.set('active', false);
326
289
  object.setCoords();
290
+ delete object.group;
327
291
 
328
292
  return this;
329
293
  },
330
294
 
331
295
  /**
332
296
  * Destroys a group (restoring state of its objects)
333
- * @method destroy
334
297
  * @return {fabric.Group} thisArg
335
298
  * @chainable
336
299
  */
@@ -352,7 +315,6 @@
352
315
 
353
316
  /**
354
317
  * Checks whether this group was moved (since `saveCoords` was called last)
355
- * @method hasMoved
356
318
  * @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called)
357
319
  */
358
320
  hasMoved: function() {
@@ -362,7 +324,6 @@
362
324
 
363
325
  /**
364
326
  * Sets coordinates of all group objects
365
- * @method setObjectsCoords
366
327
  * @return {fabric.Group} thisArg
367
328
  * @chainable
368
329
  */
@@ -373,39 +334,8 @@
373
334
  return this;
374
335
  },
375
336
 
376
- /**
377
- * Activates (makes active) all group objects
378
- * @method activateAllObjects
379
- * @return {fabric.Group} thisArg
380
- * @chainable
381
- */
382
- activateAllObjects: function() {
383
- this.forEachObject(function(object) {
384
- object.setActive();
385
- });
386
- return this;
387
- },
388
-
389
- /**
390
- * Executes given function for each object in this group
391
- * @method forEachObject
392
- * @param {Function} callback
393
- * Callback invoked with current object as first argument,
394
- * index - as second and an array of all objects - as third.
395
- * Iteration happens in reverse order (for performance reasons).
396
- * Callback is invoked in a context of Global Object (e.g. `window`)
397
- * when no `context` argument is given
398
- *
399
- * @param {Object} context Context (aka thisObject)
400
- *
401
- * @return {fabric.Group} thisArg
402
- * @chainable
403
- */
404
- forEachObject: fabric.StaticCanvas.prototype.forEachObject,
405
-
406
337
  /**
407
338
  * @private
408
- * @method _setOpacityIfSame
409
339
  */
410
340
  _setOpacityIfSame: function() {
411
341
  var objects = this.getObjects(),
@@ -422,17 +352,16 @@
422
352
 
423
353
  /**
424
354
  * @private
425
- * @method _calcBounds
426
355
  */
427
356
  _calcBounds: function() {
428
357
  var aX = [],
429
358
  aY = [],
430
359
  minX, minY, maxX, maxY, o, width, height,
431
360
  i = 0,
432
- len = this.objects.length;
361
+ len = this._objects.length;
433
362
 
434
363
  for (; i < len; ++i) {
435
- o = this.objects[i];
364
+ o = this._objects[i];
436
365
  o.setCoords();
437
366
  for (var prop in o.oCoords) {
438
367
  aX.push(o.oCoords[prop].x);
@@ -455,48 +384,15 @@
455
384
  this.top = (minY + height / 2) || 0;
456
385
  },
457
386
 
458
- /**
459
- * Checks if point is contained within the group
460
- * @method containsPoint
461
- * @param {fabric.Point} point point with `x` and `y` properties
462
- * @return {Boolean} true if point is contained within group
463
- */
464
- containsPoint: function(point) {
465
-
466
- var halfWidth = this.get('width') / 2,
467
- halfHeight = this.get('height') / 2,
468
- centerX = this.get('left'),
469
- centerY = this.get('top');
470
-
471
- return centerX - halfWidth < point.x &&
472
- centerX + halfWidth > point.x &&
473
- centerY - halfHeight < point.y &&
474
- centerY + halfHeight > point.y;
475
- },
476
-
477
- /**
478
- * Makes all of this group's objects grayscale (i.e. calling `toGrayscale` on them)
479
- * @method toGrayscale
480
- * @return {fabric.Group} thisArg
481
- * @chainable
482
- */
483
- toGrayscale: function() {
484
- var i = this.objects.length;
485
- while (i--) {
486
- this.objects[i].toGrayscale();
487
- }
488
- return this;
489
- },
490
-
387
+ /* _TO_SVG_START_ */
491
388
  /**
492
389
  * Returns svg representation of an instance
493
- * @method toSVG
494
390
  * @return {String} svg representation of an instance
495
391
  */
496
392
  toSVG: function() {
497
393
  var objectsMarkup = [ ];
498
- for (var i = this.objects.length; i--; ) {
499
- objectsMarkup.push(this.objects[i].toSVG());
394
+ for (var i = this._objects.length; i--; ) {
395
+ objectsMarkup.push(this._objects[i].toSVG());
500
396
  }
501
397
 
502
398
  return (
@@ -504,10 +400,10 @@
504
400
  objectsMarkup.join('') +
505
401
  '</g>');
506
402
  },
403
+ /* _TO_SVG_END_ */
507
404
 
508
405
  /**
509
406
  * Returns requested property
510
- * @method get
511
407
  * @param {String} prop Property to get
512
408
  * @return {Any}
513
409
  */
@@ -517,8 +413,8 @@
517
413
  return this[prop];
518
414
  }
519
415
  else {
520
- for (var i = 0, len = this.objects.length; i < len; i++) {
521
- if (this.objects[i][prop]) {
416
+ for (var i = 0, len = this._objects.length; i < len; i++) {
417
+ if (this._objects[i][prop]) {
522
418
  return true;
523
419
  }
524
420
  }
@@ -526,6 +422,9 @@
526
422
  }
527
423
  }
528
424
  else {
425
+ if (prop in this.delegatedProperties) {
426
+ return this._objects[0] && this._objects[0].get(prop);
427
+ }
529
428
  return this[prop];
530
429
  }
531
430
  }
@@ -534,7 +433,6 @@
534
433
  /**
535
434
  * Returns {@link fabric.Group} instance from an object representation
536
435
  * @static
537
- * @method fabric.Group.fromObject
538
436
  * @param {Object} object Object to create a group from
539
437
  * @param {Object} [options] Options object
540
438
  * @return {fabric.Group} An instance of fabric.Group