fabric-rails 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## 1.0.11 (19 February 2013)
2
+
3
+ - fabric.js version 1.0.11
4
+
1
5
  ## 1.0.10 (18 February 2013)
2
6
 
3
- - fabric.js version 0.9.8
7
+ - fabric.js version 1.0.10
4
8
 
5
9
  ## 0.0.8 (19 September 2012)
6
10
 
@@ -1,6 +1,6 @@
1
1
  module Fabric
2
2
  module Rails
3
- VERSION = "1.0.10"
4
- FABRIC_VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
+ FABRIC_VERSION = "1.0.11"
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
1
  /* build: `node build.js modules=ALL exclude=gestures` */
2
2
  /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */
3
3
 
4
- var fabric = fabric || { version: "1.0.10" };
4
+ var fabric = fabric || { version: "1.0.11" };
5
5
 
6
6
  if (typeof exports !== 'undefined') {
7
7
  exports.fabric = fabric;
@@ -2207,14 +2207,53 @@ fabric.Observable.trigger = fabric.Observable.fire;
2207
2207
  ctx.restore();
2208
2208
  }
2209
2209
 
2210
- function createCanvasElement() {
2211
- var canvasEl = fabric.document.createElement('canvas');
2210
+ /**
2211
+ * Creates canvas element and initializes it via excanvas if necessary
2212
+ * @static
2213
+ * @memberOf fabric.util
2214
+ * @method createCanvasElement
2215
+ * @param {CanvasElement} [canvasEl] optional canvas element to initialize; when not given, element is created implicitly
2216
+ * @return {CanvasElement} initialized canvas element
2217
+ */
2218
+ function createCanvasElement(canvasEl) {
2219
+ canvasEl || (canvasEl = fabric.document.createElement('canvas'));
2212
2220
  if (!canvasEl.getContext && typeof G_vmlCanvasManager !== 'undefined') {
2213
2221
  G_vmlCanvasManager.initElement(canvasEl);
2214
2222
  }
2215
2223
  return canvasEl;
2216
2224
  }
2217
2225
 
2226
+ /**
2227
+ * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array
2228
+ * @static
2229
+ * @memberOf fabric.util
2230
+ * @method createAccessors
2231
+ * @param {Object} klass "Class" to create accessors for
2232
+ */
2233
+ function createAccessors(klass) {
2234
+ var proto = klass.prototype;
2235
+
2236
+ for (var i = proto.stateProperties.length; i--; ) {
2237
+
2238
+ var propName = proto.stateProperties[i],
2239
+ capitalizedPropName = propName.charAt(0).toUpperCase() + propName.slice(1),
2240
+ setterName = 'set' + capitalizedPropName,
2241
+ getterName = 'get' + capitalizedPropName;
2242
+
2243
+ // using `new Function` for better introspection
2244
+ if (!proto[getterName]) {
2245
+ proto[getterName] = (function(property) {
2246
+ return new Function('return this.get("' + property + '")');
2247
+ })(propName);
2248
+ }
2249
+ if (!proto[setterName]) {
2250
+ proto[setterName] = (function(property) {
2251
+ return new Function('value', 'return this.set("' + property + '", value)');
2252
+ })(propName);
2253
+ }
2254
+ }
2255
+ }
2256
+
2218
2257
  fabric.util.removeFromArray = removeFromArray;
2219
2258
  fabric.util.degreesToRadians = degreesToRadians;
2220
2259
  fabric.util.radiansToDegrees = radiansToDegrees;
@@ -2230,6 +2269,7 @@ fabric.Observable.trigger = fabric.Observable.fire;
2230
2269
  fabric.util.populateWithProperties = populateWithProperties;
2231
2270
  fabric.util.drawDashedLine = drawDashedLine;
2232
2271
  fabric.util.createCanvasElement = createCanvasElement;
2272
+ fabric.util.createAccessors = createAccessors;
2233
2273
 
2234
2274
  })();
2235
2275
  (function() {
@@ -10106,26 +10146,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati
10106
10146
  }
10107
10147
  });
10108
10148
 
10109
- var proto = fabric.Object.prototype;
10110
- for (var i = proto.stateProperties.length; i--; ) {
10111
-
10112
- var propName = proto.stateProperties[i],
10113
- capitalizedPropName = propName.charAt(0).toUpperCase() + propName.slice(1),
10114
- setterName = 'set' + capitalizedPropName,
10115
- getterName = 'get' + capitalizedPropName;
10116
-
10117
- // using `new Function` for better introspection
10118
- if (!proto[getterName]) {
10119
- proto[getterName] = (function(property) {
10120
- return new Function('return this.get("' + property + '")');
10121
- })(propName);
10122
- }
10123
- if (!proto[setterName]) {
10124
- proto[setterName] = (function(property) {
10125
- return new Function('value', 'return this.set("' + property + '", value)');
10126
- })(propName);
10127
- }
10128
- }
10149
+ fabric.util.createAccessors(fabric.Object);
10129
10150
 
10130
10151
  /**
10131
10152
  * Alias for {@link fabric.Object.prototype.setAngle}
@@ -14441,11 +14462,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati
14441
14462
  * @return {fabric.Image}
14442
14463
  */
14443
14464
  fabric.Image.fromElement = function(element, callback, options) {
14444
- options || (options = { });
14445
-
14446
14465
  var parsedAttributes = fabric.parseAttributes(element, fabric.Image.ATTRIBUTE_NAMES);
14447
14466
 
14448
- fabric.Image.fromURL(parsedAttributes['xlink:href'], callback, extend(parsedAttributes, options));
14467
+ fabric.Image.fromURL(parsedAttributes['xlink:href'], callback, extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes));
14449
14468
  };
14450
14469
 
14451
14470
  /**
@@ -15374,6 +15393,37 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
15374
15393
  return;
15375
15394
  }
15376
15395
 
15396
+ var dimensionAffectingProps = {
15397
+ fontSize: true,
15398
+ fontWeight: true,
15399
+ fontFamily: true,
15400
+ textDecoration: true,
15401
+ fontStyle: true,
15402
+ lineHeight: true,
15403
+ strokeStyle: true,
15404
+ strokeWidth: true,
15405
+ text: true
15406
+ };
15407
+
15408
+ var stateProperties = fabric.Object.prototype.stateProperties.concat();
15409
+ stateProperties.push(
15410
+ 'fontFamily',
15411
+ 'fontWeight',
15412
+ 'fontSize',
15413
+ 'path',
15414
+ 'text',
15415
+ 'textDecoration',
15416
+ 'textShadow',
15417
+ 'textAlign',
15418
+ 'fontStyle',
15419
+ 'lineHeight',
15420
+ 'strokeStyle',
15421
+ 'strokeWidth',
15422
+ 'backgroundColor',
15423
+ 'textBackgroundColor',
15424
+ 'useNative'
15425
+ );
15426
+
15377
15427
  /**
15378
15428
  * Text class
15379
15429
  * @class Text
@@ -15486,6 +15536,14 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
15486
15536
  */
15487
15537
  useNative: true,
15488
15538
 
15539
+ /**
15540
+ * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged)
15541
+ * as well as for history (undo/redo) purposes
15542
+ * @property
15543
+ * @type Array
15544
+ */
15545
+ stateProperties: stateProperties,
15546
+
15489
15547
  /**
15490
15548
  * Constructor
15491
15549
  * @method initialize
@@ -15496,7 +15554,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
15496
15554
  initialize: function(text, options) {
15497
15555
  options = options || { };
15498
15556
 
15499
- this._initStateProperties();
15500
15557
  this.text = text;
15501
15558
  this.setOptions(options);
15502
15559
  this._initDimensions();
@@ -15510,38 +15567,9 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
15510
15567
  */
15511
15568
  _initDimensions: function() {
15512
15569
  var canvasEl = fabric.util.createCanvasElement();
15513
-
15514
15570
  this._render(canvasEl.getContext('2d'));
15515
15571
  },
15516
15572
 
15517
- /**
15518
- * Creates `stateProperties` list on an instance, and adds `fabric.Text` -specific ones to it
15519
- * (such as "fontFamily", "fontWeight", etc.)
15520
- * @private
15521
- * @method _initStateProperties
15522
- */
15523
- _initStateProperties: function() {
15524
- this.stateProperties = this.stateProperties.concat();
15525
- this.stateProperties.push(
15526
- 'fontFamily',
15527
- 'fontWeight',
15528
- 'fontSize',
15529
- 'path',
15530
- 'text',
15531
- 'textDecoration',
15532
- 'textShadow',
15533
- 'textAlign',
15534
- 'fontStyle',
15535
- 'lineHeight',
15536
- 'strokeStyle',
15537
- 'strokeWidth',
15538
- 'backgroundColor',
15539
- 'textBackgroundColor',
15540
- 'useNative'
15541
- );
15542
- fabric.util.removeFromArray(this.stateProperties, 'width');
15543
- },
15544
-
15545
15573
  /**
15546
15574
  * Returns string representation of an instance
15547
15575
  * @method toString
@@ -16200,20 +16228,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
16200
16228
  return this;
16201
16229
  },
16202
16230
 
16203
- /**
16204
- * Sets fontSize of an instance and updates its coordinates
16205
- * @method setFontsize
16206
- * @param {Number} value
16207
- * @return {fabric.Text} thisArg
16208
- * @chainable
16209
- */
16210
- setFontsize: function(value) {
16211
- this.set('fontSize', value);
16212
- this._initDimensions();
16213
- this.setCoords();
16214
- return this;
16215
- },
16216
-
16217
16231
  /**
16218
16232
  * Returns actual text value of an instance
16219
16233
  * @method getText
@@ -16223,20 +16237,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
16223
16237
  return this.text;
16224
16238
  },
16225
16239
 
16226
- /**
16227
- * Sets text of an instance, and updates its coordinates
16228
- * @method setText
16229
- * @param {String} value
16230
- * @return {fabric.Text} thisArg
16231
- * @chainable
16232
- */
16233
- setText: function(value) {
16234
- this.set('text', value);
16235
- this._initDimensions();
16236
- this.setCoords();
16237
- return this;
16238
- },
16239
-
16240
16240
  /**
16241
16241
  * Sets specified property to a specified value
16242
16242
  * @method set
@@ -16250,6 +16250,11 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
16250
16250
  this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
16251
16251
  }
16252
16252
  this.callSuper('_set', name, value);
16253
+
16254
+ if (name in dimensionAffectingProps) {
16255
+ this._initDimensions();
16256
+ this.setCoords();
16257
+ }
16253
16258
  }
16254
16259
  });
16255
16260
 
@@ -16305,6 +16310,8 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
16305
16310
  return text;
16306
16311
  };
16307
16312
 
16313
+ fabric.util.createAccessors(fabric.Text);
16314
+
16308
16315
  })(typeof exports !== 'undefined' ? exports : this);
16309
16316
  (function() {
16310
16317
 
@@ -16455,4 +16462,3 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
16455
16462
  }
16456
16463
 
16457
16464
  })();
16458
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabric-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem provides fabric.js for your Rails 3 application via the asset
15
15
  pipeline.