Permalink
Browse files

- Fix unit tests

- Add view.copy()
  • Loading branch information...
koenbok committed Apr 19, 2014
1 parent 449b155 commit 0999d529d14be05f0f50c6e8ea461849ca546dd3
Showing with 37 additions and 6 deletions.
  1. +14 −2 build/framer.js
  2. +8 −2 extras/CactusFramerTest/static/app-cs.coffee
  3. +13 −0 src/views/view.coffee
  4. +2 −2 test/tests/view.coffee
@@ -1,7 +1,7 @@
// Framer 2.0-61-g958bf94 (c) 2013 Koen Bok
// Framer 2.0-62-g449b155 (c) 2013 Koen Bok
// https://github.com/koenbok/Framer
window.FramerVersion = "2.0-61-g958bf94";
window.FramerVersion = "2.0-62-g449b155";
(function(){var require = function (file, cwd) {
@@ -3074,6 +3074,18 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
}
});
View.prototype.copy = function() {
var copiedSubView, subView, view, _i, _len, _ref;
view = new this.constructor(this.properties);
_ref = this.subViews;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
subView = _ref[_i];
copiedSubView = subView.copy();
copiedSubView.superView = view;
}
return view;
};
View.prototype.addListener = function(event, listener) {
View.__super__.addListener.apply(this, arguments);
return this._element.addEventListener(event, listener);
@@ -1,4 +1,10 @@
window.view = new View
viewA = new View x:20, y:20, width:100, height:100
viewB = new View x:0, y:0, width:50, height:50, superView: viewA
viewC = new ImageView x:20, y:20, width:20, height:20, superView: viewB
viewC.image = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/t1.0-1/c9.9.112.112/s50x50/1002105_10201417272264644_314604545_s.jpg"
view.draggable = true
for i in [1..10]
viewACopy = viewA.copy()
viewACopy.x = 25 * i
viewACopy.y = 25 * i
@@ -510,6 +510,19 @@ class View extends Frame
@_draggable ?= new ui.Draggable @
@_draggable
#############################################################################
## Copying
copy: ->
view = new @constructor @properties
for subView in @subViews
copiedSubView = subView.copy()
copiedSubView.superView = view
view
#############################################################################
## Events
@@ -86,8 +86,8 @@ describe "View", ->
view.x.should.equal 0
view.y.should.equal 0
view.width.should.equal 0
view.height.should.equal 0
view.width.should.equal Framer.config.defaultViewWidth
view.height.should.equal Framer.config.defaultViewHeight
it "should set frame", ->
frame = {x: 200, y: 200, width: 200, height: 200}

0 comments on commit 0999d52

Please sign in to comment.