Permalink
Browse files

Coffeescript 1.6.2

  • Loading branch information...
Koen Bok
Koen Bok committed Apr 13, 2013
1 parent 6da090f commit 20c81a183a6eff94e78dcf127ccfd5d896fcca2f
Showing with 265 additions and 119 deletions.
  1. +112 −34 build/framer.js
  2. +1 −1 package.json
  3. +0 −2 src/init.coffee
  4. +7 −11 src/primitives/frame.coffee
  5. +1 −5 src/views/imageview.coffee
  6. +4 −4 src/views/scrollview.coffee
  7. +28 −28 src/views/view.coffee
  8. +112 −34 template/framer.js
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -10,7 +10,7 @@
"dependencies": {
"underscore": "1.x",
"browserify": "1.x",
"coffee-script": "1.4.x",
"coffee-script": "1.6.x",
"coffeelint": "0.5.x"
},
"license": "MIT"
View
@@ -6,9 +6,7 @@ debug = require "./debug"
{View} = require "./views/view"
{ViewList} = require "./views/view"
{ScrollView} = require "./views/scrollview"
# {CollectionView} = require "./views/collectionview"
{ImageView} = require "./views/imageview"
# {TextView} = require "./views/textview"
{Animation} = require "./animation"
{Frame} = require "./primitives/frame"
@@ -1,17 +1,13 @@
utils = require "../utils"
{EventEmitter} = require "../eventemitter"
class Frame extends EventEmitter
constructor: (args) ->
@properties = args
@define "properties"
@define "properties",
get: ->
p = {}
for key, value of Frame.Properties
@@ -26,33 +22,33 @@ class Frame extends EventEmitter
for key, value of Frame.CalculatedProperties
@[key] = args[key] if args[key] not in [null, undefined]
@define "minX"
@define "minX",
get: -> @x
set: (value) -> @x = value
@define "midX"
@define "midX",
get: -> @x + (@width / 2.0)
set: (value) ->
throw Error "Width is zero" if @width is 0
@x = value - (@width / 2.0)
@define "maxX"
@define "maxX",
get: -> @x + @width
set: (value) ->
throw Error "Width is zero" if @width is 0
@x = value - @width
@define "minY"
@define "minY",
get: -> @y
set: (value) -> @y = value
@define "midY"
@define "midY",
get: -> @y + (@height / 2.0)
set: (value) ->
throw Error "Width is zero" if @height is 0
@y = value - (@height / 2.0)
@define "maxY"
@define "maxY",
get: -> @y + @height
set: (value) ->
throw Error "Width is zero" if @height is 0
@@ -11,11 +11,7 @@ class exports.ImageView extends View
@image = args.image
@define "html"
get: -> @_element.innerHTML
set: (value) -> @_element.innerHTML = value
@define "image"
@define "image",
get: ->
return @_image
@@ -23,13 +23,13 @@ class exports.ScrollView extends View
# el.scrollTop = el.scrollHeight - el.offsetHeight - 1
# , false
@define "scrollVertical"
@define "scrollVertical",
get: ->
@style["overflow-y"] != "hidden"
set: (value) ->
@style["overflow-y"] = if value then "scroll" else "hidden"
@define "scrollHorizontal"
@define "scrollHorizontal",
get: ->
@style["overflow-x"] != "hidden"
set: (value) ->
@@ -43,13 +43,13 @@ class exports.ScrollView extends View
@scrollPoint = @_element.scrollHeight - @frame.height
, 0
@define "scrollPoint"
@define "scrollPoint",
get: ->
@_element.scrollTop
set: (value) ->
@_element.scrollTop = value
@define "scrollFrame"
@define "scrollFrame",
get: ->
return new Frame {
x: @_element.scrollLeft
View
@@ -45,15 +45,15 @@ class View extends Frame
# Helpers
@define "name"
@define "name",
get: ->
@_name or @id
set: (value) ->
@_name = value
@_element.setAttribute "name", @_name
@define "properties"
@define "properties",
get: ->
p = {}
for key, value of View.Properties
@@ -72,7 +72,7 @@ class View extends Frame
#############################################################################
## Geometry Utils
@define "frame"
@define "frame",
get: -> new Frame {x:@x, y:@y, width:@width, height:@height}
set: (value) ->
return if not value
@@ -101,7 +101,7 @@ class View extends Frame
#############################################################################
## Geometry
@define "width"
@define "width",
get: ->
parseFloat @style.width
set: (value) ->
@@ -110,7 +110,7 @@ class View extends Frame
@emit "change:width"
@emit "change:frame"
@define "height"
@define "height",
get: ->
parseFloat @style.height
set: (value) ->
@@ -119,7 +119,7 @@ class View extends Frame
@emit "change:height"
@emit "change:frame"
@define "x"
@define "x",
get: -> @_matrix.x
set: (value) ->
@animateStop()
@@ -128,7 +128,7 @@ class View extends Frame
@emit "change:x"
@emit "change:frame"
@define "y"
@define "y",
get: -> @_matrix.y
set: (value) ->
@animateStop()
@@ -137,7 +137,7 @@ class View extends Frame
@emit "change:y"
@emit "change:frame"
@define "z"
@define "z",
get: -> @_matrix.z
set: (value) ->
@animateStop()
@@ -149,7 +149,7 @@ class View extends Frame
#############################################################################
## Scale
@define "scale"
@define "scale",
get: -> @_matrix.scale
set: (value) ->
@animateStop()
@@ -158,7 +158,7 @@ class View extends Frame
@emit "change:scale"
@define "scaleX"
@define "scaleX",
get: -> @_matrix.scaleX
set: (value) ->
@animateStop()
@@ -168,7 +168,7 @@ class View extends Frame
@emit "change:scaleX"
@emit "change:scale"
@define "scaleY"
@define "scaleY",
get: -> @_matrix.scaleY
set: (value) ->
@animateStop()
@@ -178,7 +178,7 @@ class View extends Frame
@emit "change:scaleY"
@emit "change:scale"
@define "scaleZ"
@define "scaleZ",
get: -> @_matrix.scaleZ
set: (value) ->
@animateStop()
@@ -192,7 +192,7 @@ class View extends Frame
#############################################################################
## Rotate
@define "rotate"
@define "rotate",
get: -> @_matrix.rotate
set: (value) ->
@animateStop()
@@ -201,7 +201,7 @@ class View extends Frame
@emit "change:rotate"
@define "rotateX"
@define "rotateX",
get: -> @_matrix.rotateX
set: (value) ->
@animateStop()
@@ -211,7 +211,7 @@ class View extends Frame
@emit "change:rotateX"
@emit "change:rotate"
@define "rotateY"
@define "rotateY",
get: -> @_matrix.rotateY
set: (value) ->
@animateStop()
@@ -221,7 +221,7 @@ class View extends Frame
@emit "change:rotateX"
@emit "change:rotate"
@define "rotateZ"
@define "rotateZ",
get: -> @_matrix.rotateZ
set: (value) ->
@animateStop()
@@ -235,7 +235,7 @@ class View extends Frame
#############################################################################
## Matrix
@define "_matrix"
@define "_matrix",
get: ->
if not @__matrix
@__matrix = new Matrix new WebKitCSSMatrix @_element.style.webkitTransform
@@ -264,15 +264,15 @@ class View extends Frame
#############################################################################
## Visual Properties
@define "opacity"
@define "opacity",
get: ->
parseFloat @style.opacity or 1
set: (value) ->
@animateStop()
@style.opacity = value
@emit "change:opacity"
@define "clip"
@define "clip",
get: ->
@_clip
set: (value) ->
@@ -281,7 +281,7 @@ class View extends Frame
@style.overflow = "visible" if value is false
@emit "change:clip"
@define "visible"
@define "visible",
get: ->
@_visible or true
set: (value) ->
@@ -294,7 +294,7 @@ class View extends Frame
#############################################################################
## Hierarchy
@define "superView"
@define "superView",
get: -> @_superView or null
set: (value) ->
@@ -320,7 +320,7 @@ class View extends Frame
@_superView = value
@emit "change:superView"
@define "subViews"
@define "subViews",
get: -> _.compact @_subViews
addSubView: (view) ->
@@ -336,7 +336,7 @@ class View extends Frame
#############################################################################
## Ordering
@define "index"
@define "index",
get: -> @style['z-index'] or 0
set: (value) ->
@style['z-index'] = value
@@ -371,33 +371,33 @@ class View extends Frame
#############################################################################
## HTML Helpers
@define "html"
@define "html",
get: -> @_element.innerHTML
set: (value) ->
@_element.innerHTML = value
@emit "change:html"
@define "style"
@define "style",
get: -> @_element.style
set: (value) ->
utils.extend @_element.style, value
@emit "change:style"
@define "computedStyle"
@define "computedStyle",
get: -> document.defaultView.getComputedStyle @_element
set: (value) ->
throw Error "computedStyle is readonly"
# Class helpers
@define "class"
@define "class",
get: ->
@_element.className
set: (value) ->
@_element.className = value
@emit "change:class"
@define "classes"
@define "classes",
get: ->
classes = @class.split " "
classes = _(classes).filter (item) -> item not in ["", null]
Oops, something went wrong.

0 comments on commit 20c81a1

Please sign in to comment.