mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-21 20:01:52 +00:00
Closes #43. fabric.Text#set can now accept object with property/values.
This commit is contained in:
parent
07d4f7de72
commit
a41fd5dffd
4 changed files with 33 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.5" };
|
||||
var fabric = fabric || { version: "0.5.1" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
|
|||
16
dist/all.js
vendored
16
dist/all.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.5" };
|
||||
var fabric = fabric || { version: "0.5.1" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
@ -1865,6 +1865,7 @@ fabric.Observable = {
|
|||
|
||||
fabric.loadSVGFromURL = loadSVGFromURL;
|
||||
fabric.loadSVGFromString = loadSVGFromString;
|
||||
|
||||
})();
|
||||
|
||||
if (!Array.prototype.indexOf) {
|
||||
|
|
@ -10213,9 +10214,16 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
|
|||
* @chainable
|
||||
*/
|
||||
set: function(name, value) {
|
||||
this[name] = value;
|
||||
if (name === 'fontFamily' && this.path) {
|
||||
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
|
||||
if (typeof name == 'object') {
|
||||
for (var prop in name) {
|
||||
this.set(prop, name[prop]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this[name] = value;
|
||||
if (name === 'fontFamily' && this.path) {
|
||||
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,9 +323,16 @@
|
|||
* @chainable
|
||||
*/
|
||||
set: function(name, value) {
|
||||
this[name] = value;
|
||||
if (name === 'fontFamily' && this.path) {
|
||||
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
|
||||
if (typeof name == 'object') {
|
||||
for (var prop in name) {
|
||||
this.set(prop, name[prop]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this[name] = value;
|
||||
if (name === 'fontFamily' && this.path) {
|
||||
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,16 @@
|
|||
equals(text.set('text', 'bar'), text, 'should be chainable');
|
||||
});
|
||||
|
||||
test('set with "hash"', function() {
|
||||
var text = createTextObject();
|
||||
|
||||
text.set({ opacity: 0.123, fill: 'red', fontFamily: 'blah' });
|
||||
|
||||
equals(0.123, text.getOpacity());
|
||||
equals('red', text.getFill());
|
||||
equals('blah', text.get('fontFamily'));
|
||||
});
|
||||
|
||||
test('setColor', function(){
|
||||
var text = createTextObject();
|
||||
ok(typeof text.setColor == 'function');
|
||||
|
|
|
|||
Loading…
Reference in a new issue