Skip to content
Browse files

file upload via drag/drop

  • Loading branch information...
1 parent 042c3ce commit e396be0ba3876e32475d109070d577a455887d17 @collin committed
View
1 src/alpha_simprini/client/application.coffee
@@ -24,6 +24,7 @@ class AS.Application
bind blur change click dblclick focus focusin focusout
keydown keypress keyup load mousedown mousenter mouseleave mousemove
mouseout mouseover mouseup ready resize scroll select submit load unload
+ mousewheel
"""
def applyTo: (element) ->
@el = $(element)
View
71 src/alpha_simprini/client/binding/model.coffee
@@ -1,3 +1,4 @@
+{isArray} = _
class AS.Binding.Model < AS.Binding
def initialize: (@context, @model, @content=$([])) ->
@styles = {}
@@ -11,25 +12,19 @@ class AS.Binding.Model < AS.Binding
# """
def css: (properties) ->
- # for property, options of properties
- # do (property, options) =>
- # if _.isArray(options)
- # options = {
- # path: options
- # fn: =>
- # value = @styles[property]()
- # @content.css property, value
- # }
-
- # @styles[property] = => options.fn(@model)
- # painter = => _.defer => @content.css property, @styles[property]()
-
- # {path} = options
-
- # @context.binds @model, options.path, painter, this
-
- _.defer => @paint()
+ for property, options of properties
+ do (property, options) =>
+ if _.isArray(options)
+ @styles[property] = => @model.readPath(options)
+ painter = => _.defer =>
+ value = @styles[property]()
+ @content.css property, value
+ @context.binds @model, options, painter, this
+ else
+ @styles[property] = => options.fn(@model)
+ painter = => _.defer => @content.css property, @styles[property]()
+ @context.binds @model, options.field, painter, this
# @::css.doc =
# params: [
# []
@@ -39,16 +34,36 @@ class AS.Binding.Model < AS.Binding
# """
def attr: (attrs) ->
- for property, path of attrs
- do (property, path) =>
- @attrs[property] = => @model.readPath(path)
- painter = =>
- value = @attrs[property]()
- @content.attr property, value
-
- @context.binds @model, path, painter, this
-
- _.defer => @paint()
+ for property, options of attrs
+ do (property, options) =>
+ if _.isArray(options)
+ @attrs[property] = =>
+ value = @model.readPath(options)
+ if value
+ "yes"
+ else if value in [false, null, undefined]
+ "no"
+ else
+ value
+ painter = => _.defer =>
+ @content.attr property, @attrs[property]()
+ bindingPath = options
+ @context.binds @model, bindingPath, painter, this
+ else
+ @attrs[property] = =>
+ if options.fn
+ options.fn(@model)
+ else
+ value = @model[options.field].get()
+ if value
+ "yes"
+ else if value in [false, null, undefined]
+ "no"
+ else
+ value
+ painter = => _.defer =>
+ @content.attr property, @attrs[property]()
+ @context.binds @model, options.field, painter, this
# @::attr.doc =
# params: [
View
4 src/alpha_simprini/client/chassis/block.coffee
@@ -8,6 +8,10 @@ class AS.Chassis.Block
@appname = "app"
# window.addEventListener "message", bind(@forwardMessage, this), false
$ =>
+ $(window).on "keydown", (event) ->
+ return if $(event.target).is(":input, [contenteditable]")
+ event.preventDefault() if event.keyCode is 8
+
@viewport = $(document.createElement("section"))
@viewport.addClass("Viewport")
@viewport.appendTo(document.body)
View
7 src/alpha_simprini/client/models/targets.coffee
@@ -23,7 +23,7 @@ class AS.Models.Targets
# """
def gather: ->
- @targets = $(@selector).map (i, el) ->
+ @targets = $(@selector, @application?.el).map (i, el) ->
return el: $(el), rect: el.getBoundingClientRect()
# @::gather.doc =
# params: [
@@ -64,6 +64,7 @@ class AS.Models.Targets
# """
def drop: (event) ->
+ @trigger("drop")
# @::drop.doc =
# params: [
# []
@@ -85,7 +86,9 @@ class AS.Models.Targets
# """
def transitionHit: (hit) ->
- return @dropend() if hit is null
+ if hit is null
+ @currentHit = undefined
+ return @dropend()
@currentHit ?= AS.Models.Targets.Hit.new()
# Nothin' changed, eh?
return if @currentHit.equals(hit) or hit.rect is undefined
View
27 src/alpha_simprini/client/view.coffee
@@ -343,10 +343,35 @@ class AS.View < AS.DOM
# desc: """
#
# """
+
def icon: (name, options={}) ->
if options.class
options.class = "#{options.class} icon-#{name}"
else
options.class = "icon-#{name}"
@i options
-
+ # @::icon.doc =
+ # params: [
+ # ["name", "String", true]
+ # ["options", Object, false]
+ # ]
+ # desc: """
+ # Creates an <i> element with a class "icon-#{name}", such as
+ # <i class="icon-magnifier
+ # """
+
+ def preventDefault: (event) -> event.preventDefault()
+ # @::preventDefault.doc =
+ # params: [
+ # [event, "DOMEvent", true]
+ # ]
+ # desc: """
+ # A useful event handler that prevents the default behavior.
+ # Use it in the events hash like so to prevent navigations on links
+ # with a 'stopped' class.
+ # ```coffee
+ # events:
+ # "click a.stopped": "preventDefault"
+ # ```
+ # """
+
View
2 src/alpha_simprini/core/models/file.coffee
@@ -32,7 +32,7 @@ class AS.Models.File < AS.Model
defs build: (source) ->
if _.isString(source)
@build_from_url(source)
- else if source instanceof @::File
+ else if source.lastModifiedDate?
@build_from_filereader(source)
# else if source instanceof Image
# @build_from_image(source)

0 comments on commit e396be0

Please sign in to comment.
Something went wrong with that request. Please try again.