fabric-rails 1.0.12 → 1.0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/fabric/rails/version.rb +2 -2
- data/vendor/assets/javascripts/event.js +1909 -0
- data/vendor/assets/javascripts/fabric.js +64 -16464
- data/vendor/assets/javascripts/fabric/HEADER.js +31 -0
- data/vendor/assets/javascripts/fabric/canvas.class.js +1007 -0
- data/vendor/assets/javascripts/fabric/canvas_animation.mixin.js +113 -0
- data/vendor/assets/javascripts/fabric/canvas_events.mixin.js +482 -0
- data/vendor/assets/javascripts/fabric/canvas_gestures.mixin.js +79 -0
- data/vendor/assets/javascripts/fabric/canvas_serialization.mixin.js +311 -0
- data/vendor/assets/javascripts/fabric/circle.class.js +182 -0
- data/vendor/assets/javascripts/fabric/color.class.js +284 -0
- data/vendor/assets/javascripts/fabric/ellipse.class.js +169 -0
- data/vendor/assets/javascripts/fabric/freedrawing.class.js +256 -0
- data/vendor/assets/javascripts/fabric/gradient.class.js +211 -0
- data/vendor/assets/javascripts/fabric/group.class.js +556 -0
- data/vendor/assets/javascripts/fabric/image.class.js +418 -0
- data/vendor/assets/javascripts/fabric/image_filters.js +809 -0
- data/vendor/assets/javascripts/fabric/intersection.class.js +178 -0
- data/vendor/assets/javascripts/fabric/line.class.js +188 -0
- data/vendor/assets/javascripts/fabric/log.js +26 -0
- data/vendor/assets/javascripts/fabric/node.js +149 -0
- data/vendor/assets/javascripts/fabric/object.class.js +1068 -0
- data/vendor/assets/javascripts/fabric/object_geometry.mixin.js +308 -0
- data/vendor/assets/javascripts/fabric/object_interactivity.mixin.js +496 -0
- data/vendor/assets/javascripts/fabric/object_origin.mixin.js +207 -0
- data/vendor/assets/javascripts/fabric/object_straightening.mixin.js +94 -0
- data/vendor/assets/javascripts/fabric/observable.mixin.js +91 -0
- data/vendor/assets/javascripts/fabric/parser.js +750 -0
- data/vendor/assets/javascripts/fabric/path.class.js +794 -0
- data/vendor/assets/javascripts/fabric/path_group.class.js +240 -0
- data/vendor/assets/javascripts/fabric/pattern.class.js +69 -0
- data/vendor/assets/javascripts/fabric/point.class.js +327 -0
- data/vendor/assets/javascripts/fabric/polygon.class.js +184 -0
- data/vendor/assets/javascripts/fabric/polyline.class.js +157 -0
- data/vendor/assets/javascripts/fabric/rect.class.js +298 -0
- data/vendor/assets/javascripts/fabric/scout.js +45 -0
- data/vendor/assets/javascripts/fabric/shadow.class.js +70 -0
- data/vendor/assets/javascripts/fabric/stateful.js +88 -0
- data/vendor/assets/javascripts/fabric/static_canvas.class.js +1298 -0
- data/vendor/assets/javascripts/fabric/text.class.js +934 -0
- data/vendor/assets/javascripts/fabric/triangle.class.js +108 -0
- data/vendor/assets/javascripts/fabric/util/anim_ease.js +360 -0
- data/vendor/assets/javascripts/fabric/util/dom_event.js +237 -0
- data/vendor/assets/javascripts/fabric/util/dom_misc.js +245 -0
- data/vendor/assets/javascripts/fabric/util/dom_request.js +72 -0
- data/vendor/assets/javascripts/fabric/util/dom_style.js +71 -0
- data/vendor/assets/javascripts/fabric/util/lang_array.js +250 -0
- data/vendor/assets/javascripts/fabric/util/lang_class.js +97 -0
- data/vendor/assets/javascripts/fabric/util/lang_function.js +35 -0
- data/vendor/assets/javascripts/fabric/util/lang_object.js +34 -0
- data/vendor/assets/javascripts/fabric/util/lang_string.js +60 -0
- data/vendor/assets/javascripts/fabric/util/misc.js +406 -0
- data/vendor/assets/javascripts/json2.js +491 -0
- metadata +53 -2
@@ -0,0 +1,556 @@
|
|
1
|
+
(function(global){
|
2
|
+
|
3
|
+
"use strict";
|
4
|
+
|
5
|
+
var fabric = global.fabric || (global.fabric = { }),
|
6
|
+
extend = fabric.util.object.extend,
|
7
|
+
min = fabric.util.array.min,
|
8
|
+
max = fabric.util.array.max,
|
9
|
+
invoke = fabric.util.array.invoke,
|
10
|
+
removeFromArray = fabric.util.removeFromArray;
|
11
|
+
|
12
|
+
if (fabric.Group) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
|
16
|
+
// lock-related properties, for use in fabric.Group#get
|
17
|
+
// to enable locking behavior on group
|
18
|
+
// when one of its objects has lock-related properties set
|
19
|
+
var _lockProperties = {
|
20
|
+
lockMovementX: true,
|
21
|
+
lockMovementY: true,
|
22
|
+
lockRotation: true,
|
23
|
+
lockScalingX: true,
|
24
|
+
lockScalingY: true,
|
25
|
+
lockUniScaling: true
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Group class
|
30
|
+
* @class Group
|
31
|
+
* @extends fabric.Object
|
32
|
+
*/
|
33
|
+
fabric.Group = fabric.util.createClass(fabric.Object, /** @scope fabric.Group.prototype */ {
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Type of an object
|
37
|
+
* @property
|
38
|
+
* @type String
|
39
|
+
*/
|
40
|
+
type: 'group',
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Constructor
|
44
|
+
* @method initialized
|
45
|
+
* @param {Object} objects Group objects
|
46
|
+
* @param {Object} [options] Options object
|
47
|
+
* @return {Object} thisArg
|
48
|
+
*/
|
49
|
+
initialize: function(objects, options) {
|
50
|
+
options = options || { };
|
51
|
+
|
52
|
+
this.objects = objects || [];
|
53
|
+
this.originalState = { };
|
54
|
+
|
55
|
+
this.callSuper('initialize');
|
56
|
+
|
57
|
+
this._calcBounds();
|
58
|
+
this._updateObjectsCoords();
|
59
|
+
|
60
|
+
if (options) {
|
61
|
+
extend(this, options);
|
62
|
+
}
|
63
|
+
this._setOpacityIfSame();
|
64
|
+
|
65
|
+
// group is active by default
|
66
|
+
this.setCoords(true);
|
67
|
+
this.saveCoords();
|
68
|
+
|
69
|
+
//this.activateAllObjects();
|
70
|
+
},
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @private
|
74
|
+
* @method _updateObjectsCoords
|
75
|
+
*/
|
76
|
+
_updateObjectsCoords: function() {
|
77
|
+
var groupDeltaX = this.left,
|
78
|
+
groupDeltaY = this.top;
|
79
|
+
|
80
|
+
this.forEachObject(function(object) {
|
81
|
+
|
82
|
+
var objectLeft = object.get('left'),
|
83
|
+
objectTop = object.get('top');
|
84
|
+
|
85
|
+
object.set('originalLeft', objectLeft);
|
86
|
+
object.set('originalTop', objectTop);
|
87
|
+
|
88
|
+
object.set('left', objectLeft - groupDeltaX);
|
89
|
+
object.set('top', objectTop - groupDeltaY);
|
90
|
+
|
91
|
+
object.setCoords();
|
92
|
+
|
93
|
+
// do not display corners of objects enclosed in a group
|
94
|
+
object.hasControls = false;
|
95
|
+
}, this);
|
96
|
+
},
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Returns string represenation of a group
|
100
|
+
* @method toString
|
101
|
+
* @return {String}
|
102
|
+
*/
|
103
|
+
toString: function() {
|
104
|
+
return '#<fabric.Group: (' + this.complexity() + ')>';
|
105
|
+
},
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Returns an array of all objects in this group
|
109
|
+
* @method getObjects
|
110
|
+
* @return {Array} group objects
|
111
|
+
*/
|
112
|
+
getObjects: function() {
|
113
|
+
return this.objects;
|
114
|
+
},
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Adds an object to a group; Then recalculates group's dimension, position.
|
118
|
+
* @method addWithUpdate
|
119
|
+
* @param {Object} object
|
120
|
+
* @return {fabric.Group} thisArg
|
121
|
+
* @chainable
|
122
|
+
*/
|
123
|
+
addWithUpdate: function(object) {
|
124
|
+
this._restoreObjectsState();
|
125
|
+
this.objects.push(object);
|
126
|
+
this._calcBounds();
|
127
|
+
this._updateObjectsCoords();
|
128
|
+
return this;
|
129
|
+
},
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Removes an object from a group; Then recalculates group's dimension, position.
|
133
|
+
* @method removeWithUpdate
|
134
|
+
* @param {Object} object
|
135
|
+
* @return {fabric.Group} thisArg
|
136
|
+
* @chainable
|
137
|
+
*/
|
138
|
+
removeWithUpdate: function(object) {
|
139
|
+
this._restoreObjectsState();
|
140
|
+
removeFromArray(this.objects, object);
|
141
|
+
object.setActive(false);
|
142
|
+
this._calcBounds();
|
143
|
+
this._updateObjectsCoords();
|
144
|
+
return this;
|
145
|
+
},
|
146
|
+
|
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
|
165
|
+
*/
|
166
|
+
remove: function(object) {
|
167
|
+
removeFromArray(this.objects, object);
|
168
|
+
return this;
|
169
|
+
},
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Returns a size of a group (i.e: length of an array containing its objects)
|
173
|
+
* @return {Number} Group size
|
174
|
+
*/
|
175
|
+
size: function() {
|
176
|
+
return this.getObjects().length;
|
177
|
+
},
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Properties that are delegated to group objects when reading/writing
|
181
|
+
*/
|
182
|
+
delegatedProperties: {
|
183
|
+
fill: true,
|
184
|
+
opacity: true,
|
185
|
+
fontFamily: true,
|
186
|
+
fontWeight: true,
|
187
|
+
lineHeight: true,
|
188
|
+
textDecoration: true,
|
189
|
+
textShadow: true,
|
190
|
+
backgroundColor: true
|
191
|
+
},
|
192
|
+
|
193
|
+
/**
|
194
|
+
* @private
|
195
|
+
*/
|
196
|
+
_set: function(key, value) {
|
197
|
+
if (key in this.delegatedProperties) {
|
198
|
+
var i = this.objects.length;
|
199
|
+
this[key] = value;
|
200
|
+
while (i--) {
|
201
|
+
this.objects[i].set(key, value);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
else {
|
205
|
+
this[key] = value;
|
206
|
+
}
|
207
|
+
},
|
208
|
+
|
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
|
+
/**
|
220
|
+
* Returns object representation of an instance
|
221
|
+
* @method toObject
|
222
|
+
* @param {Array} propertiesToInclude
|
223
|
+
* @return {Object} object representation of an instance
|
224
|
+
*/
|
225
|
+
toObject: function(propertiesToInclude) {
|
226
|
+
return extend(this.callSuper('toObject', propertiesToInclude), {
|
227
|
+
objects: invoke(this.objects, 'toObject', propertiesToInclude)
|
228
|
+
});
|
229
|
+
},
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Renders instance on a given context
|
233
|
+
* @method render
|
234
|
+
* @param {CanvasRenderingContext2D} ctx context to render instance on
|
235
|
+
*/
|
236
|
+
render: function(ctx, noTransform) {
|
237
|
+
ctx.save();
|
238
|
+
this.transform(ctx);
|
239
|
+
|
240
|
+
var groupScaleFactor = Math.max(this.scaleX, this.scaleY);
|
241
|
+
|
242
|
+
//The array is now sorted in order of highest first, so start from end.
|
243
|
+
for (var i = this.objects.length; i > 0; i--) {
|
244
|
+
|
245
|
+
var object = this.objects[i-1],
|
246
|
+
originalScaleFactor = object.borderScaleFactor,
|
247
|
+
originalHasRotatingPoint = object.hasRotatingPoint;
|
248
|
+
|
249
|
+
object.borderScaleFactor = groupScaleFactor;
|
250
|
+
object.hasRotatingPoint = false;
|
251
|
+
|
252
|
+
object.render(ctx);
|
253
|
+
|
254
|
+
object.borderScaleFactor = originalScaleFactor;
|
255
|
+
object.hasRotatingPoint = originalHasRotatingPoint;
|
256
|
+
}
|
257
|
+
|
258
|
+
if (!noTransform && this.active) {
|
259
|
+
this.drawBorders(ctx);
|
260
|
+
this.drawControls(ctx);
|
261
|
+
}
|
262
|
+
ctx.restore();
|
263
|
+
this.setCoords();
|
264
|
+
},
|
265
|
+
|
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
|
+
/**
|
289
|
+
* Retores original state of each of group objects (original state is that which was before group was created).
|
290
|
+
* @private
|
291
|
+
* @method _restoreObjectsState
|
292
|
+
* @return {fabric.Group} thisArg
|
293
|
+
* @chainable
|
294
|
+
*/
|
295
|
+
_restoreObjectsState: function() {
|
296
|
+
this.objects.forEach(this._restoreObjectState, this);
|
297
|
+
return this;
|
298
|
+
},
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Restores original state of a specified object in group
|
302
|
+
* @private
|
303
|
+
* @method _restoreObjectState
|
304
|
+
* @param {fabric.Object} object
|
305
|
+
* @return {fabric.Group} thisArg
|
306
|
+
*/
|
307
|
+
_restoreObjectState: function(object) {
|
308
|
+
|
309
|
+
var groupLeft = this.get('left'),
|
310
|
+
groupTop = this.get('top'),
|
311
|
+
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');
|
314
|
+
|
315
|
+
object.setAngle(object.getAngle() + this.getAngle());
|
316
|
+
|
317
|
+
object.set('left', groupLeft + rotatedLeft * this.get('scaleX'));
|
318
|
+
object.set('top', groupTop + rotatedTop * this.get('scaleY'));
|
319
|
+
|
320
|
+
object.set('scaleX', object.get('scaleX') * this.get('scaleX'));
|
321
|
+
object.set('scaleY', object.get('scaleY') * this.get('scaleY'));
|
322
|
+
|
323
|
+
object.setCoords();
|
324
|
+
object.hasControls = true;
|
325
|
+
object.setActive(false);
|
326
|
+
object.setCoords();
|
327
|
+
|
328
|
+
return this;
|
329
|
+
},
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Destroys a group (restoring state of its objects)
|
333
|
+
* @method destroy
|
334
|
+
* @return {fabric.Group} thisArg
|
335
|
+
* @chainable
|
336
|
+
*/
|
337
|
+
destroy: function() {
|
338
|
+
return this._restoreObjectsState();
|
339
|
+
},
|
340
|
+
|
341
|
+
/**
|
342
|
+
* Saves coordinates of this instance (to be used together with `hasMoved`)
|
343
|
+
* @saveCoords
|
344
|
+
* @return {fabric.Group} thisArg
|
345
|
+
* @chainable
|
346
|
+
*/
|
347
|
+
saveCoords: function() {
|
348
|
+
this._originalLeft = this.get('left');
|
349
|
+
this._originalTop = this.get('top');
|
350
|
+
return this;
|
351
|
+
},
|
352
|
+
|
353
|
+
/**
|
354
|
+
* Checks whether this group was moved (since `saveCoords` was called last)
|
355
|
+
* @method hasMoved
|
356
|
+
* @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called)
|
357
|
+
*/
|
358
|
+
hasMoved: function() {
|
359
|
+
return this._originalLeft !== this.get('left') ||
|
360
|
+
this._originalTop !== this.get('top');
|
361
|
+
},
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Sets coordinates of all group objects
|
365
|
+
* @method setObjectsCoords
|
366
|
+
* @return {fabric.Group} thisArg
|
367
|
+
* @chainable
|
368
|
+
*/
|
369
|
+
setObjectsCoords: function() {
|
370
|
+
this.forEachObject(function(object) {
|
371
|
+
object.setCoords();
|
372
|
+
});
|
373
|
+
return this;
|
374
|
+
},
|
375
|
+
|
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
|
+
/**
|
407
|
+
* @private
|
408
|
+
* @method _setOpacityIfSame
|
409
|
+
*/
|
410
|
+
_setOpacityIfSame: function() {
|
411
|
+
var objects = this.getObjects(),
|
412
|
+
firstValue = objects[0] ? objects[0].get('opacity') : 1;
|
413
|
+
|
414
|
+
var isSameOpacity = objects.every(function(o) {
|
415
|
+
return o.get('opacity') === firstValue;
|
416
|
+
});
|
417
|
+
|
418
|
+
if (isSameOpacity) {
|
419
|
+
this.opacity = firstValue;
|
420
|
+
}
|
421
|
+
},
|
422
|
+
|
423
|
+
/**
|
424
|
+
* @private
|
425
|
+
* @method _calcBounds
|
426
|
+
*/
|
427
|
+
_calcBounds: function() {
|
428
|
+
var aX = [],
|
429
|
+
aY = [],
|
430
|
+
minX, minY, maxX, maxY, o, width, height,
|
431
|
+
i = 0,
|
432
|
+
len = this.objects.length;
|
433
|
+
|
434
|
+
for (; i < len; ++i) {
|
435
|
+
o = this.objects[i];
|
436
|
+
o.setCoords();
|
437
|
+
for (var prop in o.oCoords) {
|
438
|
+
aX.push(o.oCoords[prop].x);
|
439
|
+
aY.push(o.oCoords[prop].y);
|
440
|
+
}
|
441
|
+
}
|
442
|
+
|
443
|
+
minX = min(aX);
|
444
|
+
maxX = max(aX);
|
445
|
+
minY = min(aY);
|
446
|
+
maxY = max(aY);
|
447
|
+
|
448
|
+
width = (maxX - minX) || 0;
|
449
|
+
height = (maxY - minY) || 0;
|
450
|
+
|
451
|
+
this.width = width;
|
452
|
+
this.height = height;
|
453
|
+
|
454
|
+
this.left = (minX + width / 2) || 0;
|
455
|
+
this.top = (minY + height / 2) || 0;
|
456
|
+
},
|
457
|
+
|
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
|
+
|
491
|
+
/**
|
492
|
+
* Returns svg representation of an instance
|
493
|
+
* @method toSVG
|
494
|
+
* @return {String} svg representation of an instance
|
495
|
+
*/
|
496
|
+
toSVG: function() {
|
497
|
+
var objectsMarkup = [ ];
|
498
|
+
for (var i = this.objects.length; i--; ) {
|
499
|
+
objectsMarkup.push(this.objects[i].toSVG());
|
500
|
+
}
|
501
|
+
|
502
|
+
return (
|
503
|
+
'<g transform="' + this.getSvgTransform() + '">' +
|
504
|
+
objectsMarkup.join('') +
|
505
|
+
'</g>');
|
506
|
+
},
|
507
|
+
|
508
|
+
/**
|
509
|
+
* Returns requested property
|
510
|
+
* @method get
|
511
|
+
* @param {String} prop Property to get
|
512
|
+
* @return {Any}
|
513
|
+
*/
|
514
|
+
get: function(prop) {
|
515
|
+
if (prop in _lockProperties) {
|
516
|
+
if (this[prop]) {
|
517
|
+
return this[prop];
|
518
|
+
}
|
519
|
+
else {
|
520
|
+
for (var i = 0, len = this.objects.length; i < len; i++) {
|
521
|
+
if (this.objects[i][prop]) {
|
522
|
+
return true;
|
523
|
+
}
|
524
|
+
}
|
525
|
+
return false;
|
526
|
+
}
|
527
|
+
}
|
528
|
+
else {
|
529
|
+
return this[prop];
|
530
|
+
}
|
531
|
+
}
|
532
|
+
});
|
533
|
+
|
534
|
+
/**
|
535
|
+
* Returns {@link fabric.Group} instance from an object representation
|
536
|
+
* @static
|
537
|
+
* @method fabric.Group.fromObject
|
538
|
+
* @param {Object} object Object to create a group from
|
539
|
+
* @param {Object} [options] Options object
|
540
|
+
* @return {fabric.Group} An instance of fabric.Group
|
541
|
+
*/
|
542
|
+
fabric.Group.fromObject = function(object, callback) {
|
543
|
+
fabric.util.enlivenObjects(object.objects, function(enlivenedObjects) {
|
544
|
+
delete object.objects;
|
545
|
+
callback && callback(new fabric.Group(enlivenedObjects, object));
|
546
|
+
});
|
547
|
+
};
|
548
|
+
|
549
|
+
/**
|
550
|
+
* Indicates that instances of this type are async
|
551
|
+
* @static
|
552
|
+
* @type Boolean
|
553
|
+
*/
|
554
|
+
fabric.Group.async = true;
|
555
|
+
|
556
|
+
})(typeof exports !== 'undefined' ? exports : this);
|