2012-10-15 09:46:04 +08:00
|
|
|
/**
|
2013-01-27 12:42:19 +08:00
|
|
|
* KineticJS JavaScript Framework v{{version}}
|
2012-10-15 09:46:04 +08:00
|
|
|
* http://www.kineticjs.com/
|
2013-01-05 14:21:17 +08:00
|
|
|
* Copyright 2013, Eric Rowell
|
2012-10-15 09:46:04 +08:00
|
|
|
* Licensed under the MIT or GPL Version 2 licenses.
|
2013-01-27 12:42:19 +08:00
|
|
|
* Date: {{date}}
|
2012-10-15 09:46:04 +08:00
|
|
|
*
|
2013-01-05 14:21:17 +08:00
|
|
|
* Copyright (C) 2011 - 2013 by Eric Rowell
|
2012-10-15 09:46:04 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-03-26 16:09:21 +08:00
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
2013-03-24 13:56:22 +08:00
|
|
|
var Kinetic = {};
|
|
|
|
(function() {
|
2013-01-27 12:42:19 +08:00
|
|
|
Kinetic.version = '{{version}}';
|
2013-03-24 13:56:22 +08:00
|
|
|
|
2013-03-26 16:09:21 +08:00
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
2012-12-02 04:04:10 +08:00
|
|
|
Kinetic.Filters = {};
|
2013-03-24 13:56:22 +08:00
|
|
|
Kinetic.DD = {};
|
|
|
|
|
2013-03-26 16:09:21 +08:00
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
2012-12-02 04:04:10 +08:00
|
|
|
Kinetic.Global = {
|
|
|
|
stages: [],
|
|
|
|
idCounter: 0,
|
2013-01-14 03:10:49 +08:00
|
|
|
ids: {},
|
|
|
|
names: {},
|
2012-12-02 04:04:10 +08:00
|
|
|
//shapes hash. rgb keys and shape values
|
|
|
|
shapes: {},
|
2013-03-26 16:09:21 +08:00
|
|
|
/**
|
|
|
|
* @method isDragging returns whether or not drag and drop
|
|
|
|
* is currently active
|
|
|
|
* @methodOf Kinetic.Global
|
|
|
|
*/
|
2013-03-24 13:56:22 +08:00
|
|
|
isDragging: function() {
|
2013-04-03 13:29:56 +08:00
|
|
|
var dd = Kinetic.DD;
|
|
|
|
|
|
|
|
// if DD is not included with the build, then
|
|
|
|
// drag and drop is not even possible
|
|
|
|
if (!dd) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// if DD is included with the build
|
|
|
|
else {
|
|
|
|
return dd.isDragging;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @method isDragReady returns whether or not a drag and drop operation is ready, but may
|
|
|
|
* not necessarily have started
|
|
|
|
* @methodOf Kinetic.Global
|
|
|
|
*/
|
|
|
|
isDragReady: function() {
|
|
|
|
var dd = Kinetic.DD;
|
|
|
|
|
|
|
|
// if DD is not included with the build, then
|
|
|
|
// drag and drop is not even possible
|
|
|
|
if (!dd) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// if DD is included with the build
|
|
|
|
else {
|
|
|
|
return !!dd.node;
|
|
|
|
}
|
2013-03-24 13:56:22 +08:00
|
|
|
},
|
2012-12-02 04:04:10 +08:00
|
|
|
warn: function(str) {
|
|
|
|
/*
|
|
|
|
* IE9 on Windows7 64bit will throw a JS error
|
|
|
|
* if we don't use window.console in the conditional
|
|
|
|
*/
|
|
|
|
if(window.console && console.warn) {
|
|
|
|
console.warn('Kinetic warning: ' + str);
|
2012-08-23 14:13:09 +08:00
|
|
|
}
|
2012-12-02 04:04:10 +08:00
|
|
|
},
|
|
|
|
extend: function(c1, c2) {
|
|
|
|
for(var key in c2.prototype) {
|
|
|
|
if(!( key in c1.prototype)) {
|
|
|
|
c1.prototype[key] = c2.prototype[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-01-14 03:10:49 +08:00
|
|
|
_addId: function(node, id) {
|
|
|
|
if(id !== undefined) {
|
|
|
|
this.ids[id] = node;
|
2012-07-04 13:08:59 +08:00
|
|
|
}
|
2012-12-02 04:04:10 +08:00
|
|
|
},
|
2013-01-14 03:10:49 +08:00
|
|
|
_removeId: function(id) {
|
|
|
|
if(id !== undefined) {
|
|
|
|
delete this.ids[id];
|
|
|
|
}
|
2012-12-02 04:04:10 +08:00
|
|
|
},
|
2013-01-14 03:10:49 +08:00
|
|
|
_addName: function(node, name) {
|
|
|
|
if(name !== undefined) {
|
|
|
|
if(this.names[name] === undefined) {
|
|
|
|
this.names[name] = [];
|
|
|
|
}
|
|
|
|
this.names[name].push(node);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_removeName: function(name, _id) {
|
|
|
|
if(name !== undefined) {
|
|
|
|
var nodes = this.names[name];
|
|
|
|
if(nodes !== undefined) {
|
|
|
|
for(var n = 0; n < nodes.length; n++) {
|
|
|
|
var no = nodes[n];
|
|
|
|
if(no._id === _id) {
|
|
|
|
nodes.splice(n, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(nodes.length === 0) {
|
|
|
|
delete this.names[name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-04 13:08:59 +08:00
|
|
|
}
|
2012-12-02 04:04:10 +08:00
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Uses Node, AMD or browser globals to create a module.
|
|
|
|
|
|
|
|
// If you want something that will work in other stricter CommonJS environments,
|
|
|
|
// or if you need to create a circular dependency, see commonJsStrict.js
|
|
|
|
|
|
|
|
// Defines a module "returnExports" that depends another module called "b".
|
|
|
|
// Note that the name of the module is implied by the file name. It is best
|
|
|
|
// if the file name and the exported global have matching names.
|
|
|
|
|
|
|
|
// If the 'b' module also uses this type of boilerplate, then
|
|
|
|
// in the browser, it will create a global .b that is used below.
|
|
|
|
|
|
|
|
// If you do not want to support the browser global path, then you
|
|
|
|
// can remove the `root` use and the passing `this` as the first arg to
|
|
|
|
// the top function.
|
|
|
|
|
|
|
|
// if the module has no dependencies, the above pattern can be simplified to
|
|
|
|
( function(root, factory) {
|
|
|
|
if( typeof exports === 'object') {
|
|
|
|
// Node. Does not work with strict CommonJS, but
|
|
|
|
// only CommonJS-like enviroments that support module.exports,
|
|
|
|
// like Node.
|
|
|
|
module.exports = factory();
|
|
|
|
}
|
|
|
|
else if( typeof define === 'function' && define.amd) {
|
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
define(factory);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Browser globals (root is window)
|
|
|
|
root.returnExports = factory();
|
2012-07-04 13:08:59 +08:00
|
|
|
}
|
2012-12-02 04:04:10 +08:00
|
|
|
}(this, function() {
|
|
|
|
|
|
|
|
// Just return a value to define the module export.
|
|
|
|
// This example returns an object, but the module
|
|
|
|
// can return a function as the exported value.
|
|
|
|
return Kinetic;
|
|
|
|
}));
|