Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Drawing (id, element) {
- /*
- * Section A: value of 'this' object of type 'Drawing' (expected);
- * Variables I ought to have access to from any point in Drawing's invocation
- */
- { // Preconstruction
- var Drawing = this;
- var SVG = document.createElementNS('http://www.w3.org/2000/svg', "SVG");
- support.dom.Associative.call(Drawing, id, element);
- element = Drawing.$(); // In case element was null
- element.className = "Drawing";
- // Things in or about the drawing
- var shapes = [];
- }
- function add (shape) {
- /*
- * Section B: value of 'this' Window object
- * What gives in this function?
- * Variables I have access to from section A:
- * element: yes, id: no, Drawing: no, SVG: yes
- * ?$@#$%^$#!!!!! Help me!
- */
- if (shape instanceof Shape) {
- shapes.push(shape);
- if(!this.render) SVG.appendChild(shape.toSVG());
- return shape;
- }
- }
- this.modify = function (options) {
- if (options.create) {
- return add(create[options.create](options));
- }
- };
- }
- function Class () {
- // this: an object with a prototype of Class, if 'new'ed, window otherwise
- var that = this;
- function privateMethod () {
- // this: a reference to window. privateMethod still belongs to Class' closure
- var dat = this;
- // that: an object with a prototype of Class, if 'new'ed, window otherwise
- var dis = that;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement