2012-10-15 09:46:04 +08:00
|
|
|
/**
|
|
|
|
* KineticJS JavaScript Library @version
|
|
|
|
* http://www.kineticjs.com/
|
|
|
|
* Copyright 2012, Eric Rowell
|
|
|
|
* Licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
* Date: @date
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 - 2012 by Eric Rowell
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2012-07-04 13:08:59 +08:00
|
|
|
var Kinetic = {};
|
2012-07-15 07:25:56 +08:00
|
|
|
Kinetic.Filters = {};
|
2012-07-28 10:51:18 +08:00
|
|
|
Kinetic.Plugins = {};
|
2012-07-04 13:08:59 +08:00
|
|
|
Kinetic.Global = {
|
2012-08-14 14:06:29 +08:00
|
|
|
BUFFER_WHITELIST: ['fill', 'stroke', 'textFill', 'textStroke'],
|
2012-08-19 13:02:16 +08:00
|
|
|
BUFFER_BLACKLIST: ['shadow'],
|
2012-07-04 13:08:59 +08:00
|
|
|
stages: [],
|
|
|
|
idCounter: 0,
|
2012-08-01 12:35:04 +08:00
|
|
|
tempNodes: {},
|
2012-08-11 13:33:22 +08:00
|
|
|
//shapes hash. rgb keys and shape values
|
|
|
|
shapes: {},
|
2012-07-17 15:32:26 +08:00
|
|
|
warn: function(str) {
|
2012-11-05 00:08:32 +08:00
|
|
|
/*
|
|
|
|
* IE9 on Windows7 64bit will throw a JS error
|
|
|
|
* if we don't use window.console in the conditional
|
|
|
|
*/
|
2012-11-05 00:07:09 +08:00
|
|
|
if(window.console && console.warn) {
|
2012-07-17 15:32:26 +08:00
|
|
|
console.warn('Kinetic warning: ' + str);
|
|
|
|
}
|
|
|
|
},
|
2012-08-23 14:13:09 +08:00
|
|
|
extend: function(c1, c2) {
|
|
|
|
for(var key in c2.prototype) {
|
|
|
|
if(!( key in c1.prototype)) {
|
|
|
|
c1.prototype[key] = c2.prototype[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2012-07-04 13:08:59 +08:00
|
|
|
_pullNodes: function(stage) {
|
|
|
|
var tempNodes = this.tempNodes;
|
2012-08-01 12:35:04 +08:00
|
|
|
for(var key in tempNodes) {
|
|
|
|
var node = tempNodes[key];
|
2012-07-04 13:08:59 +08:00
|
|
|
if(node.getStage() !== undefined && node.getStage()._id === stage._id) {
|
|
|
|
stage._addId(node);
|
|
|
|
stage._addName(node);
|
2012-08-01 12:35:04 +08:00
|
|
|
this._removeTempNode(node);
|
2012-07-04 13:08:59 +08:00
|
|
|
}
|
|
|
|
}
|
2012-08-01 12:35:04 +08:00
|
|
|
},
|
|
|
|
_addTempNode: function(node) {
|
|
|
|
this.tempNodes[node._id] = node;
|
|
|
|
},
|
|
|
|
_removeTempNode: function(node) {
|
|
|
|
delete this.tempNodes[node._id];
|
2012-07-04 13:08:59 +08:00
|
|
|
}
|
|
|
|
};
|