diff --git a/app/assets/javascripts/app/lib/spine/ajax.coffee b/app/assets/javascripts/app/lib/spine/ajax.coffee old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/app/lib/spine/bindings.coffee b/app/assets/javascripts/app/lib/spine/bindings.coffee old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/app/lib/spine/list.coffee b/app/assets/javascripts/app/lib/spine/list.coffee old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/app/lib/spine/local.coffee b/app/assets/javascripts/app/lib/spine/local.coffee old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/app/lib/spine/manager.coffee b/app/assets/javascripts/app/lib/spine/manager.coffee old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/app/lib/spine/relation.coffee b/app/assets/javascripts/app/lib/spine/relation.coffee old mode 100755 new mode 100644 index 2c506709f..59ec92e93 --- a/app/assets/javascripts/app/lib/spine/relation.coffee +++ b/app/assets/javascripts/app/lib/spine/relation.coffee @@ -1,6 +1,5 @@ Spine = @Spine or require('spine') isArray = Spine.isArray -require = @require or ((value) -> eval(value)) class Collection extends Spine.Module constructor: (options = {}) -> @@ -111,8 +110,14 @@ underscore = (str) -> .replace(/-/g, '_') .toLowerCase() +requireModel = (model) -> + if typeof model is 'string' + require?(model) or eval(model) + else + model + association = (name, model, record, fkey, Ctor) -> - model = require(model) if typeof model is 'string' + model = requireModel(model) if typeof model is 'string' new Ctor(name: name, model: model, record: record, fkey: fkey) Spine.Model.extend diff --git a/app/assets/javascripts/app/lib/spine/route.coffee b/app/assets/javascripts/app/lib/spine/route.coffee old mode 100755 new mode 100644 index faef442fa..58138e9e9 --- a/app/assets/javascripts/app/lib/spine/route.coffee +++ b/app/assets/javascripts/app/lib/spine/route.coffee @@ -71,6 +71,9 @@ class Route extends Spine.Module @change() @unbind: -> + unbindResult = Spine.Events.unbind.apply this, arguments + return unbindResult if arguments.length > 0 + return if @options.shim if @history @@ -80,33 +83,30 @@ class Route extends Spine.Module @navigate: (args...) -> options = {} - lastArg = args[args.length - 1] if typeof lastArg is 'object' options = args.pop() else if typeof lastArg is 'boolean' options.trigger = args.pop() - options = $.extend({}, @options, options) path = args.join('/') return if @path is path @path = path - @trigger('navigate', @path) + if options.trigger + @trigger('navigate', @path) + routes = @matchRoutes(@path, options) + unless routes.length + if typeof options.redirect is 'function' + return options.redirect.apply this, [@path, options] + else + if options.redirect is true + @redirect(@path) - routes = @matchRoutes(@path, options) if options.trigger - - return if options.shim - - unless routes.length - if typeof options.redirect is 'function' - return options.redirect.apply this, [@path, options] - else - if options.redirect is true - @redirect(@path) - - if @history and options.replace + if options.shim + true + else if @history and options.replace history.replaceState({}, document.title, @path) else if @history history.pushState({}, document.title, @path) diff --git a/app/assets/javascripts/app/lib/spine/spine.coffee b/app/assets/javascripts/app/lib/spine/spine.coffee old mode 100755 new mode 100644 index a6a0b8c1a..7065ee5ab --- a/app/assets/javascripts/app/lib/spine/spine.coffee +++ b/app/assets/javascripts/app/lib/spine/spine.coffee @@ -149,13 +149,14 @@ class Model extends Module @toString: -> "#{@className}(#{@attributes.join(", ")})" @find: (id, notFound = @notFound) -> - record = @irecords[id]?.clone() - return record or notFound?(id) + @irecords[id]?.clone() or notFound?(id) - @notFound: (id) -> return null + @findAll: (ids, notFound) -> + (@find(id) for id in ids when @find(id, notFound)) - @exists: (id) -> - return if @irecords[id] then true else false + @notFound: (id) -> null + + @exists: (id) -> Boolean @irecords[id] @addRecord: (record, options = {}) -> if record.id and @irecords[record.id] @@ -321,8 +322,8 @@ class Model extends Module result eql: (rec) -> - !!(rec and rec.constructor is @constructor and - ((rec.cid is @cid) or (rec.id and rec.id is @id))) + rec and rec.constructor is @constructor and + ((rec.cid is @cid) or (rec.id and rec.id is @id)) save: (options = {}) -> unless options.validate is false @@ -634,7 +635,7 @@ makeArray = (args) -> Spine = @Spine = {} module?.exports = Spine -Spine.version = '1.3.1' +Spine.version = '1.3.2' Spine.isArray = isArray Spine.isBlank = isBlank Spine.$ = $