mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
Doc additions, fixes.
This commit is contained in:
parent
f8f5e0bae1
commit
f0b5329157
17 changed files with 110 additions and 40 deletions
32
lib/cufon.js
32
lib/cufon.js
|
|
@ -5,17 +5,19 @@
|
|||
|
||||
var Cufon = (function() {
|
||||
|
||||
/** @ignore */
|
||||
var api = function() {
|
||||
return api.replace.apply(null, arguments);
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
var DOM = api.DOM = {
|
||||
|
||||
ready: (function() {
|
||||
|
||||
var complete = false, readyStatus = { loaded: 1, complete: 1 };
|
||||
|
||||
var queue = [], perform = function() {
|
||||
var queue = [], /** @ignore */ perform = function() {
|
||||
if (complete) return;
|
||||
complete = true;
|
||||
for (var fn; fn = queue.shift(); fn());
|
||||
|
|
@ -57,27 +59,33 @@ var Cufon = (function() {
|
|||
|
||||
};
|
||||
|
||||
var CSS = api.CSS = {
|
||||
/** @ignore */
|
||||
var CSS = api.CSS = /** @ignore */ {
|
||||
|
||||
/** @ignore */
|
||||
Size: function(value, base) {
|
||||
|
||||
this.value = parseFloat(value);
|
||||
this.unit = String(value).match(/[a-z%]*$/)[0] || 'px';
|
||||
|
||||
/** @ignore */
|
||||
this.convert = function(value) {
|
||||
return value / base * this.value;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
this.convertFrom = function(value) {
|
||||
return value / this.value * base;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
this.toString = function() {
|
||||
return this.value + this.unit;
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
/** @ignore */
|
||||
getStyle: function(el) {
|
||||
return new Style(el.style);
|
||||
/*
|
||||
|
|
@ -129,6 +137,7 @@ var Cufon = (function() {
|
|||
|
||||
})(),
|
||||
|
||||
/** @ignore */
|
||||
supports: function(property, value) {
|
||||
var checker = fabric.document.createElement('span').style;
|
||||
if (checker[property] === undefined) return false;
|
||||
|
|
@ -136,6 +145,7 @@ var Cufon = (function() {
|
|||
return checker[property] === value;
|
||||
},
|
||||
|
||||
/** @ignore */
|
||||
textAlign: function(word, style, position, wordCount) {
|
||||
if (style.get('textAlign') == 'right') {
|
||||
if (position > 0) word = ' ' + word;
|
||||
|
|
@ -144,6 +154,7 @@ var Cufon = (function() {
|
|||
return word;
|
||||
},
|
||||
|
||||
/** @ignore */
|
||||
textDecoration: function(el, style) {
|
||||
if (!style) style = this.getStyle(el);
|
||||
var types = {
|
||||
|
|
@ -193,6 +204,7 @@ var Cufon = (function() {
|
|||
return parsed;
|
||||
}),
|
||||
|
||||
/** @ignore */
|
||||
textTransform: function(text, style) {
|
||||
return text[{
|
||||
uppercase: 'toUpperCase',
|
||||
|
|
@ -223,6 +235,7 @@ var Cufon = (function() {
|
|||
};
|
||||
box.width = box.maxX - box.minX,
|
||||
box.height = box.maxY - box.minY;
|
||||
/** @ignore */
|
||||
box.toString = function() {
|
||||
return [ this.minX, this.minY, this.width, this.height ].join(' ');
|
||||
};
|
||||
|
|
@ -247,6 +260,7 @@ var Cufon = (function() {
|
|||
(styles[font.style] || (styles[font.style] = {}))[font.weight] = font;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
this.get = function(style, weight) {
|
||||
var weights = styles[style] || styles[mapping[style]]
|
||||
|| styles.normal || styles.italic || styles.oblique;
|
||||
|
|
@ -332,6 +346,7 @@ var Cufon = (function() {
|
|||
return el.cufid || (el.cufid = ++at);
|
||||
}
|
||||
|
||||
/** @ignore */
|
||||
this.get = function(el) {
|
||||
var id = identify(el);
|
||||
return map[id] || (map[id] = {});
|
||||
|
|
@ -429,6 +444,7 @@ var Cufon = (function() {
|
|||
return fragment;
|
||||
}
|
||||
|
||||
/** @ignore */
|
||||
function replaceElement(el, options) {
|
||||
var font, style, nextNode, redraw;
|
||||
for (var node = attach(el, options).firstChild; node; node = nextNode) {
|
||||
|
|
@ -497,11 +513,13 @@ var Cufon = (function() {
|
|||
characters: ''
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.now = function() {
|
||||
DOM.ready();
|
||||
return api;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.refresh = function() {
|
||||
var currentHistory = replaceHistory.splice(0, replaceHistory.length);
|
||||
for (var i = 0, l = currentHistory.length; i < l; ++i) {
|
||||
|
|
@ -510,12 +528,14 @@ var Cufon = (function() {
|
|||
return api;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.registerEngine = function(id, engine) {
|
||||
if (!engine) return api;
|
||||
engines[id] = engine;
|
||||
return api.set('engine', id);
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.registerFont = function(data) {
|
||||
var font = new Font(data), family = font.family;
|
||||
if (!fonts[family]) fonts[family] = new FontFamily();
|
||||
|
|
@ -523,6 +543,7 @@ var Cufon = (function() {
|
|||
return api.set('fontFamily', '"' + family + '"');
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.replace = function(elements, options, ignoreHistory) {
|
||||
options = merge(defaultOptions, options);
|
||||
if (!options.engine) return api; // there's no browser support so we'll just stop here
|
||||
|
|
@ -540,6 +561,7 @@ var Cufon = (function() {
|
|||
return api;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.replaceElement = function(el, options) {
|
||||
options = merge(defaultOptions, options);
|
||||
if (typeof options.textShadow == 'string' && options.textShadow)
|
||||
|
|
@ -547,14 +569,14 @@ var Cufon = (function() {
|
|||
return replaceElement(el, options);
|
||||
};
|
||||
|
||||
// ==>
|
||||
api.engines = engines;
|
||||
api.fonts = fonts;
|
||||
/** @ignore */
|
||||
api.getOptions = function() {
|
||||
return merge(defaultOptions);
|
||||
}
|
||||
// <==
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
api.set = function(option, value) {
|
||||
defaultOptions[option] = value;
|
||||
return api;
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ if (!JSON) {
|
|||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
/** @ignore */
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf())
|
||||
|
|
@ -188,6 +189,7 @@ if (!JSON) {
|
|||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
/** @ignore */
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
|
|
@ -357,6 +359,7 @@ if (!JSON) {
|
|||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
/** @ignore */
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
|
|
@ -404,6 +407,7 @@ if (!JSON) {
|
|||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
/** @ignore */
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
|
|
|
|||
|
|
@ -1245,7 +1245,7 @@
|
|||
/**
|
||||
* @class fabric.Element
|
||||
* @alias fabric.Canvas
|
||||
* @deprecated
|
||||
* @deprecated Use {@link fabric.Canvas} instead.
|
||||
* @constructor
|
||||
*/
|
||||
fabric.Element = fabric.Canvas;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
else {
|
||||
obj.path = path;
|
||||
var object = fabric.Text.fromObject(obj);
|
||||
/** @ignore */
|
||||
var onscriptload = function () {
|
||||
// TODO (kangax): find out why Opera refuses to work without this timeout
|
||||
if (Object.prototype.toString.call(fabric.window.opera) === '[object Opera]') {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* @class Color
|
||||
* @memberOf fabric
|
||||
* @param {String} color (optional) in hex or rgb(a) format
|
||||
* @param {String} color optional in hex or rgb(a) format
|
||||
*/
|
||||
function Color(color) {
|
||||
if (!color) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* Returns fabric.Ellipse instance from an object representation
|
||||
* Returns {@link fabric.Ellipse} instance from an object representation
|
||||
* @static
|
||||
* @method fabric.Ellipse.fromObject
|
||||
* @param {Object} object Object to create an instance from
|
||||
|
|
|
|||
|
|
@ -24,11 +24,15 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @class Object
|
||||
* @class Gradient
|
||||
* @memberOf fabric
|
||||
*/
|
||||
fabric.Gradient = fabric.util.createClass(/** @scope fabric.Gradient.prototype */ {
|
||||
|
||||
/**
|
||||
* @method initialize
|
||||
* @param options optional Options with x1, y1, x2, y2 and colorStops
|
||||
*/
|
||||
initialize: function(options) {
|
||||
|
||||
options || (options = { });
|
||||
|
|
@ -41,6 +45,10 @@
|
|||
this.colorStops = options.colorStops;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns object representation of a gradient
|
||||
* @method toObject
|
||||
*/
|
||||
toObject: function() {
|
||||
return {
|
||||
x1: this.x1,
|
||||
|
|
@ -51,6 +59,11 @@
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an instance of CanvasGradient
|
||||
* @method toLiveGradient
|
||||
* @param ctx
|
||||
*/
|
||||
toLiveGradient: function(ctx) {
|
||||
var gradient = ctx.createLinearGradient(
|
||||
this.x1, this.y1, this.x2 || ctx.canvas.width, this.y2);
|
||||
|
|
@ -69,6 +82,7 @@
|
|||
/**
|
||||
* @method fromElement
|
||||
* @static
|
||||
* @memberof fabric.Gradient
|
||||
* @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement
|
||||
*/
|
||||
fromElement: function(el, instance) {
|
||||
|
|
@ -123,6 +137,7 @@
|
|||
/**
|
||||
* @method forObject
|
||||
* @static
|
||||
* @memberof fabric.Gradient
|
||||
*/
|
||||
forObject: function(obj, options) {
|
||||
options || (options = { });
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag
|
|||
type: "Grayscale",
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @memberOf fabric.Image.filters.Grayscale.prototype
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
|
|
@ -43,6 +44,7 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -77,6 +79,7 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -111,6 +114,7 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -139,6 +143,7 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f
|
|||
type: "Invert",
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @memberOf fabric.Image.filters.Invert.prototype
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
|
|
@ -159,6 +164,7 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -183,6 +189,7 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi
|
|||
type: "Sepia",
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @memberOf fabric.Image.filters.Sepia.prototype
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
|
|
@ -204,6 +211,7 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -228,6 +236,7 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f
|
|||
type: "Sepia2",
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @memberOf fabric.Image.filters.Sepia.prototype
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
|
|
@ -253,6 +262,7 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -286,6 +296,7 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -305,6 +316,7 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -321,7 +333,7 @@ fabric.Image.filters.Brightness.fromObject = function(object) {
|
|||
};
|
||||
|
||||
/**
|
||||
* @class fabric.Image.filters.Brightness
|
||||
* @class fabric.Image.filters.Noise
|
||||
* @memberOf fabric.Image.filters
|
||||
*/
|
||||
fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.filters.Noise.prototype */ {
|
||||
|
|
@ -332,7 +344,7 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi
|
|||
type: "Noise",
|
||||
|
||||
/**
|
||||
* @memberOf fabric.Image.filters.Brightness.prototype
|
||||
* @memberOf fabric.Image.filters.Noise.prototype
|
||||
* @param {Object} [options] Options object
|
||||
*/
|
||||
initialize: function(options) {
|
||||
|
|
@ -341,6 +353,7 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -363,6 +376,7 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -379,7 +393,7 @@ fabric.Image.filters.Noise.fromObject = function(object) {
|
|||
};
|
||||
|
||||
/**
|
||||
* @class fabric.Image.filters.Brightness
|
||||
* @class fabric.Image.filters.GradientTransparency
|
||||
* @memberOf fabric.Image.filters
|
||||
*/
|
||||
fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope fabric.Image.filters.GradientTransparency.prototype */ {
|
||||
|
|
@ -390,7 +404,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope
|
|||
type: "GradientTransparency",
|
||||
|
||||
/**
|
||||
* @memberOf fabric.Image.filters.GradientTransparency.prototype
|
||||
* @param {Object} [options] Options object
|
||||
*/
|
||||
initialize: function(options) {
|
||||
|
|
@ -399,6 +412,7 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -417,6 +431,7 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -453,6 +468,7 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -484,6 +500,7 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -500,11 +517,11 @@ fabric.Image.filters.Tint.fromObject = function(object) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Adapted from <a href="http://www.html5rocks.com/en/tutorials/canvas/imagefilters/">html5rocks article</a>
|
||||
* @class fabric.Image.filters.Convolute
|
||||
* @memberOf fabric.Image.filters
|
||||
* Adapted from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/
|
||||
*/
|
||||
fabric.Image.filters.Convolute = fabric.util.createClass({
|
||||
fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image.filters.Convolute.prototype */ {
|
||||
|
||||
/**
|
||||
* @param {String} type
|
||||
|
|
@ -535,6 +552,7 @@ fabric.Image.filters.Convolute = fabric.util.createClass({
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -592,6 +610,7 @@ fabric.Image.filters.Convolute = fabric.util.createClass({
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
@ -611,7 +630,7 @@ fabric.Image.filters.Convolute.fromObject = function(object) {
|
|||
* @class fabric.Image.filters.Pixelate
|
||||
* @memberOf fabric.Image.filters
|
||||
*/
|
||||
fabric.Image.filters.Pixelate = fabric.util.createClass({
|
||||
fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image.filters.Pixelate.prototype */ {
|
||||
|
||||
/**
|
||||
* @param {String} type
|
||||
|
|
@ -628,6 +647,7 @@ fabric.Image.filters.Pixelate = fabric.util.createClass({
|
|||
},
|
||||
|
||||
/**
|
||||
* Applies filter to canvas element
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
|
|
@ -676,6 +696,7 @@ fabric.Image.filters.Pixelate = fabric.util.createClass({
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns json representation of filter
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@
|
|||
});
|
||||
|
||||
/**
|
||||
* List of attribute names to account for when parsing SVG element (used by `fabric.Line.fromElement`)
|
||||
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Line.fromElement})
|
||||
* @static
|
||||
* @see http://www.w3.org/TR/SVG/shapes.html#LineElement
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Wrapper around `console.log` (when available)
|
||||
* @method log
|
||||
* @param {Any} Values to log
|
||||
* @param {Any} values Values to log
|
||||
*/
|
||||
fabric.log = function() { };
|
||||
|
||||
|
|
@ -14,12 +14,12 @@ fabric.warn = function() { };
|
|||
|
||||
if (typeof console !== 'undefined') {
|
||||
if (typeof console.log !== 'undefined' && console.log.apply) {
|
||||
fabric.log = function() {
|
||||
fabric.log = function() {
|
||||
return console.log.apply(console, arguments);
|
||||
};
|
||||
}
|
||||
if (typeof console.warn !== 'undefined' && console.warn.apply) {
|
||||
fabric.warn = function() {
|
||||
fabric.warn = function() {
|
||||
return console.warn.apply(console, arguments);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
fabric.loadSVGFromString = function(string, callback) {
|
||||
var doc = new DOMParser().parseFromString(string);
|
||||
fabric.parseSVGDocument(doc.documentElement, function(results, options) {
|
||||
|
|
|
|||
|
|
@ -71,12 +71,13 @@ fabric.Observable = {
|
|||
/**
|
||||
* Alias for observe
|
||||
* @method observe
|
||||
* @memberOf fabric.Observable
|
||||
* @type function
|
||||
*/
|
||||
fabric.Observable.on = fabric.Observable.observe;
|
||||
|
||||
/**
|
||||
* Alias for stopObserving
|
||||
* @method off
|
||||
* @type function
|
||||
*/
|
||||
fabric.Observable.off = fabric.Observable.stopObserving;
|
||||
|
|
@ -573,6 +573,7 @@
|
|||
/**
|
||||
* Takes url corresponding to an SVG document, and parses it into a set of fabric objects
|
||||
* @method loadSVGFromURL
|
||||
* @memberof fabric
|
||||
* @param {String} url
|
||||
* @param {Function} callback
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
|
|
@ -635,6 +636,7 @@
|
|||
/**
|
||||
* Takes string corresponding to an SVG document, and parses it into a set of fabric objects
|
||||
* @method loadSVGFromString
|
||||
* @memberof fabric
|
||||
* @param {String} string
|
||||
* @param {Function} callback
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@
|
|||
});
|
||||
|
||||
/**
|
||||
* List of attribute names to account for when parsing SVG element (used by `fabric.Polyline.fromElement`)
|
||||
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Polyline.fromElement})
|
||||
* @static
|
||||
* @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@
|
|||
var halfOfVerticalBox = this._getTextHeight(ctx, textLines) / 2;
|
||||
var _this = this;
|
||||
|
||||
/** @ignore */
|
||||
function renderLinesAtOffset(offset) {
|
||||
for (var i = 0, len = textLines.length; i < len; i++) {
|
||||
|
||||
|
|
@ -745,7 +746,7 @@
|
|||
});
|
||||
|
||||
/**
|
||||
* List of attribute names to account for when parsing SVG element (used by `fabric.Text.fromElement`)
|
||||
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Text.fromElement})
|
||||
* @static
|
||||
*/
|
||||
fabric.Text.ATTRIBUTE_NAMES =
|
||||
|
|
|
|||
|
|
@ -132,12 +132,13 @@
|
|||
};
|
||||
}
|
||||
else {
|
||||
/** @ignore */
|
||||
getElementPosition = function (element) {
|
||||
var value = element.style.position;
|
||||
if (!value && element.currentStyle) value = element.currentStyle.position;
|
||||
return value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
var style = fabric.document.documentElement.style;
|
||||
|
|
|
|||
|
|
@ -12,23 +12,24 @@
|
|||
* @param {Any[]} [...] Values to pass to a bound function
|
||||
* @return {Function}
|
||||
*/
|
||||
Function.prototype.bind = function(thisArg) {
|
||||
var fn = this, args = slice.call(arguments, 1), bound;
|
||||
if (args.length) {
|
||||
bound = function() {
|
||||
return apply.call(fn, this instanceof Dummy ? this : thisArg, args.concat(slice.call(arguments)));
|
||||
};
|
||||
}
|
||||
else {
|
||||
bound = function() {
|
||||
return apply.call(fn, this instanceof Dummy ? this : thisArg, arguments);
|
||||
};
|
||||
}
|
||||
Dummy.prototype = this.prototype;
|
||||
bound.prototype = new Dummy();
|
||||
Function.prototype.bind = function(thisArg) {
|
||||
var fn = this, args = slice.call(arguments, 1), bound;
|
||||
if (args.length) {
|
||||
bound = function() {
|
||||
return apply.call(fn, this instanceof Dummy ? this : thisArg, args.concat(slice.call(arguments)));
|
||||
};
|
||||
}
|
||||
else {
|
||||
/** @ignore */
|
||||
bound = function() {
|
||||
return apply.call(fn, this instanceof Dummy ? this : thisArg, arguments);
|
||||
};
|
||||
}
|
||||
Dummy.prototype = this.prototype;
|
||||
bound.prototype = new Dummy();
|
||||
|
||||
return bound;
|
||||
};
|
||||
return bound;
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
Loading…
Reference in a new issue