Merge pull request #133 from zhouningyi/master

container selector
This commit is contained in:
Anton Lavrenov
2016-02-26 22:41:38 +08:00
2 changed files with 255 additions and 235 deletions

View File

@@ -3,7 +3,7 @@
* Konva JavaScript Framework v0.11.1
* http://konvajs.github.io/
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Fri Feb 05 2016
* Date: Fri Feb 26 2016
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
@@ -8657,10 +8657,20 @@
* @memberof Konva.Stage.prototype
* @param {DomElement} container can pass in a dom element or id string
*/
setContainer: function(container) {
if( typeof container === STRING) {
var id = container;
container = Konva.document.getElementById(container);
setContainer: function (container) {
if (typeof container === STRING) {
if (container.charAt(0) === '.') {
var className = container.slice(1);
container = Konva.document.getElementsByClassName(className)[0];
} else {
var id;
if (container.charAt(0) !== '#') {
id = container;
} else {
id = container.slice(1);
}
container = Konva.document.getElementById(id);
}
if (!container) {
throw 'Can not find container in document with id ' + id;
}

View File

@@ -95,10 +95,20 @@
* @memberof Konva.Stage.prototype
* @param {DomElement} container can pass in a dom element or id string
*/
setContainer: function(container) {
if( typeof container === STRING) {
var id = container;
container = Konva.document.getElementById(container);
setContainer: function (container) {
if (typeof container === STRING) {
if (container.charAt(0) === '.') {
var className = container.slice(1);
container = Konva.document.getElementsByClassName(className)[0];
} else {
var id;
if (container.charAt(0) !== '#') {
id = container;
} else {
id = container.slice(1);
}
container = Konva.document.getElementById(id);
}
if (!container) {
throw 'Can not find container in document with id ' + id;
}