diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index bbe01ac67..db112f866 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -40,13 +40,13 @@ class App.ControllerGenericNew extends App.ControllerModal # save object ui = @ object.save( - success: -> + done: -> if ui.callback item = App[ ui.genericObject ].retrieve(@id) ui.callback( item ) ui.modalHide() - error: -> + fail: -> ui.log 'errors' ui.modalHide() ) @@ -87,13 +87,13 @@ class App.ControllerGenericEdit extends App.ControllerModal # save object ui = @ @item.save( - success: -> + done: -> if ui.callback item = App[ ui.genericObject ].retrieve(@id) ui.callback( item ) ui.modalHide() - error: => + fail: => ui.log 'errors' ui.modalHide() ) @@ -170,6 +170,7 @@ class App.ControllerGenericIndex extends App.Controller objects: objects overview: overview attributes: attributes + groupBy: 'state' ) binds = {} diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index 75e94cf4c..9a99eb4e8 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -125,9 +125,9 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal # save object object.save( - success: => + done: => @modalHide() - error: => + fail: => @modalHide() ) @@ -214,9 +214,9 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal # save object object.save( - success: => + done: => @modalHide() - error: => + fail: => @modalHide() ) @@ -301,9 +301,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal # save object object.save( - success: => + done: => @modalHide() - error: => + fail: => @modalHide() ) @@ -425,9 +425,9 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal # save object object.save( - success: => + done: => @modalHide() - error: => + fail: => @modalHide() ) diff --git a/app/assets/javascripts/app/controllers/_dashboard/ticket.js.coffee b/app/assets/javascripts/app/controllers/_dashboard/ticket.js.coffee index 4d8c3c186..8b374cc3d 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/ticket.js.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/ticket.js.coffee @@ -260,7 +260,7 @@ class Settings extends App.ControllerModal @overview.view['d'] = params['attributes'] @overview.save( - success: => + done: => if @reload_needed @overview.trigger('local:refetch') else diff --git a/app/assets/javascripts/app/controllers/_settings/area.js.coffee b/app/assets/javascripts/app/controllers/_settings/area.js.coffee index 04bbf6352..05ecd00e1 100644 --- a/app/assets/javascripts/app/controllers/_settings/area.js.coffee +++ b/app/assets/javascripts/app/controllers/_settings/area.js.coffee @@ -75,7 +75,7 @@ class App.SettingsAreaItem extends App.Controller @setting['state'] = state ui = @ @setting.save( - success: => + done: => App.Event.trigger 'notify', { type: 'success' diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index 297d847ac..5660252df 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -282,7 +282,7 @@ class App.TicketCreate extends App.Controller @formDisable(e) ui = @ object.save( - success: -> + done: -> # notify UI ui.notify @@ -306,8 +306,7 @@ class App.TicketCreate extends App.Controller # if not, show start screen ui.navigate "#" - - error: -> + fail: -> ui.log 'save failed!' ui.formEnable(e) ) @@ -357,7 +356,7 @@ class UserNew extends App.ControllerModal # save user ui = @ user.save( - success: -> + done: -> # force to reload object callbackReload = (user) -> @@ -370,7 +369,7 @@ class UserNew extends App.ControllerModal ui.modalHide() App.User.retrieve( @id, callbackReload , true ) - error: -> + fail: -> ui.modalHide() ) diff --git a/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee index c21be26be..2d6296cdf 100644 --- a/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee @@ -178,12 +178,12 @@ class Index extends App.ControllerContent @formDisable(e) ui = @ object.save( - success: -> + done: -> # redirect to zoom ui.navigate '#ticket/zoom/' + this.id - error: -> + fail: -> ui.log 'CustomerTicketCreate', 'error', 'can not create' ui.formEnable(e) ) diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index 8a80fbd27..e0d61a29e 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -94,7 +94,7 @@ class Index extends App.ControllerContent # save user user.save( - success: (r) => + done: (r) => if @master_user @master_user = false @@ -123,7 +123,7 @@ class Index extends App.ControllerContent # rerender page @render() - error: (data) -> + fail: (data) -> App.Event.trigger 'notify', { type: 'error' diff --git a/app/assets/javascripts/app/controllers/signup.js.coffee b/app/assets/javascripts/app/controllers/signup.js.coffee index fc5c54032..a3da92107 100644 --- a/app/assets/javascripts/app/controllers/signup.js.coffee +++ b/app/assets/javascripts/app/controllers/signup.js.coffee @@ -62,7 +62,7 @@ class Index extends App.ControllerContent # save user user.save( - success: (r) => + done: (r) => App.Auth.login( data: username: @params.login @@ -70,7 +70,7 @@ class Index extends App.ControllerContent success: @success error: @error ) -# error: => +# fail: => # @modalHide() ) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee index 93a85ed2d..fc7536993 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee @@ -311,7 +311,7 @@ class Table extends App.ControllerContent ticket.load(ticket_update) ticket.save( - success: (r) => + done: (r) => @bulk_count_index++ # refresh view after all tickets are proceeded @@ -501,7 +501,7 @@ class Settings extends App.ControllerModal @overview.view[@view_mode] = params['attributes'] @overview.save( - success: => + done: => if @reload_needed @overview.trigger('local:refetch') else diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index e098ced86..756461082 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -530,17 +530,17 @@ class Edit extends App.Controller return ticket.save( - success: (r) => + done: (r) => # reset form after save if article article.save( - success: (r) => + done: (r) => @ui.fetch( ticket.id, true ) # reset form after save App.TaskManager.update( @task_key, { 'state': {} }) - error: (r) => + fail: (r) => @log 'error', 'update article', r ) else diff --git a/app/assets/javascripts/app/controllers/widget/template.js.coffee b/app/assets/javascripts/app/controllers/widget/template.js.coffee index c2da4003e..9367285ea 100644 --- a/app/assets/javascripts/app/controllers/widget/template.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/template.js.coffee @@ -80,10 +80,10 @@ class App.WidgetTemplate extends App.ControllerDrox else ui = @ template.save( - success: -> + done: -> ui.template_id = @.id ui.render() - error: => + fail: => @log 'error', 'save failed!' ) diff --git a/app/assets/javascripts/app/controllers/widget/text_module.js.coffee b/app/assets/javascripts/app/controllers/widget/text_module.js.coffee index 43e7b893e..e1807e060 100644 --- a/app/assets/javascripts/app/controllers/widget/text_module.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/text_module.js.coffee @@ -295,12 +295,12 @@ class App.WidgetTextModuleOld extends App.Controller else ui = @ text_module.save( - success: -> + done: -> ui.el.find('#text_module_name').val('') ui.renderTable() ui.log 'save success!' - error: -> + fail: -> ui.log 'save failed!' ) diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 042161e74..f866853e9 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -138,7 +138,7 @@ class _taskManagerSingleton extends App.Controller # save new task and update task collection ui = @ task.save( - success: -> + done: -> for taskPosition of ui.allTasks if ui.allTasks[taskPosition] && ui.allTasks[taskPosition]['key'] is @key task = @attributes() @@ -338,10 +338,10 @@ class _taskManagerSingleton extends App.Controller if taskUpdate.isOnline() ui = @ taskUpdate.save( - success: -> + done: -> if ui.tasksToUpdate[ @key ] is 'inProgress' delete ui.tasksToUpdate[ @key ] - error: -> + fail: -> ui.log 'error', "can't update task", @ if ui.tasksToUpdate[ @key ] is 'inProgress' delete ui.tasksToUpdate[ @key ] diff --git a/app/assets/javascripts/app/lib/spine/ajax.coffee b/app/assets/javascripts/app/lib/spine/ajax.coffee new file mode 100755 index 000000000..2007f0ae6 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/ajax.coffee @@ -0,0 +1,275 @@ +Spine = @Spine or require('spine') +$ = Spine.$ +Model = Spine.Model +Queue = $({}) + +Ajax = + getURL: (object) -> + if object.className? + @generateURL(object) + else + @generateURL(object, encodeURIComponent(object.id)) + + getCollectionURL: (object) -> + @generateURL(object) + + getScope: (object) -> + object.scope?() or object.scope + + getCollection: (object) -> + if object.url isnt object.generateURL + if typeof object.url is 'function' + object.url() + else + object.url + else if object.className? + object.className.toLowerCase() + 's' + + generateURL: (object, args...) -> + collection = Ajax.getCollection(object) or Ajax.getCollection(object.constructor) + scope = Ajax.getScope(object) or Ajax.getScope(object.constructor) + args.unshift(collection) + args.unshift(scope) + # construct and clean url + path = args.join('/') + path = path.replace /(\/\/)/g, "/" + path = path.replace /^\/|\/$/g, "" + # handle relative urls vs those that use a host + if path.indexOf("../") isnt 0 + Model.host + "/" + path + else + path + + enabled: true + + disable: (callback) -> + if @enabled + @enabled = false + try + do callback + catch e + throw e + finally + @enabled = true + else + do callback + + queue: (request) -> + if request then Queue.queue(request) else Queue.queue() + + clearQueue: -> + @queue [] + +class Base + defaults: + dataType: 'json' + processData: false + headers: {'X-Requested-With': 'XMLHttpRequest'} + + queue: Ajax.queue + + ajax: (params, defaults) -> + $.ajax @ajaxSettings(params, defaults) + + ajaxQueue: (params, defaults, record) -> + jqXHR = null + deferred = $.Deferred() + promise = deferred.promise() + return promise unless Ajax.enabled + settings = @ajaxSettings(params, defaults) + # prefer setting if exists else default is to parallelize 'GET' requests + parallel = if settings.parallel isnt undefined then settings.parallel else (settings.type is 'GET') + request = (next) -> + if record?.id? + # for existing singleton, model id may have been updated + # after request has been queued + settings.url ?= Ajax.getURL(record) + settings.data?.id = record.id + # 2 reasons not to stringify: if already a string, or if intend to have ajax processData + if typeof settings.data isnt 'string' and settings.processData isnt true + settings.data = JSON.stringify(settings.data) + jqXHR = $.ajax(settings) + .done(deferred.resolve) + .fail(deferred.reject) + .then(next, next) + if parallel + Queue.dequeue() + + promise.abort = (statusText) -> + return jqXHR.abort(statusText) if jqXHR + index = $.inArray(request, @queue()) + @queue().splice(index, 1) if index > -1 + deferred.rejectWith( + settings.context or settings, + [promise, statusText, ''] + ) + promise + + @queue request + promise + + ajaxSettings: (params, defaults) -> + $.extend({}, @defaults, defaults, params) + +class Collection extends Base + constructor: (@model) -> + + find: (id, params, options = {}) -> + record = new @model(id: id) + @ajaxQueue( + params, { + type: 'GET' + url: options.url or Ajax.getURL(record) + parallel: options.parallel + } + ).done(@recordsResponse) + .fail(@failResponse) + + all: (params, options = {}) -> + @ajaxQueue( + params, { + type: 'GET' + url: options.url or Ajax.getURL(@model) + parallel: options.parallel + } + ).done(@recordsResponse) + .fail(@failResponse) + + fetch: (params = {}, options = {}) -> + if id = params.id + delete params.id + @find(id, params, options).done (record) => + @model.refresh(record, options) + else + @all(params, options).done (records) => + @model.refresh(records, options) + + # Private + + recordsResponse: (data, status, xhr) => + @model.trigger('ajaxSuccess', null, status, xhr) + + failResponse: (xhr, statusText, error) => + @model.trigger('ajaxError', null, xhr, statusText, error) + +class Singleton extends Base + constructor: (@record) -> + @model = @record.constructor + + reload: (params, options = {}) -> + @ajaxQueue( + params, { + type: 'GET' + url: options.url + parallel: options.parallel + }, @record + ).done(@recordResponse(options)) + .fail(@failResponse(options)) + + create: (params, options = {}) -> + @ajaxQueue( + params, { + type: 'POST' + contentType: 'application/json' + data: @record.toJSON() + url: options.url or Ajax.getCollectionURL(@record) + parallel: options.parallel + } + ).done(@recordResponse(options)) + .fail(@failResponse(options)) + + update: (params, options = {}) -> + @ajaxQueue( + params, { + type: 'PUT' + contentType: 'application/json' + data: @record.toJSON() + url: options.url + parallel: options.parallel + }, @record + ).done(@recordResponse(options)) + .fail(@failResponse(options)) + + destroy: (params, options = {}) -> + @ajaxQueue( + params, { + type: 'DELETE' + url: options.url + parallel: options.parallel + }, @record + ).done(@recordResponse(options)) + .fail(@failResponse(options)) + + # Private + + recordResponse: (options = {}) => + (data, status, xhr) => + + Ajax.disable => + unless Spine.isBlank(data) or @record.destroyed + # ID change, need to do some shifting + if data.id and @record.id isnt data.id + @record.changeID(data.id) + # Update with latest data + @record.refresh(data) + + @record.trigger('ajaxSuccess', data, status, xhr) + options.done?.apply(@record) + + failResponse: (options = {}) => + (xhr, statusText, error) => + @record.trigger('ajaxError', xhr, statusText, error) + options.fail?.apply(@record) + +# Ajax endpoint +Model.host = '' + +GenerateURL = + include: (args...) -> + args.unshift(encodeURIComponent(@id)) + Ajax.generateURL(@, args...) + extend: (args...) -> + Ajax.generateURL(@, args...) + +Include = + ajax: -> new Singleton(this) + + generateURL: GenerateURL.include + + url: GenerateURL.include + +Extend = + ajax: -> new Collection(this) + + generateURL: GenerateURL.extend + + url: GenerateURL.extend + +Model.Ajax = + extended: -> + @fetch @ajaxFetch + @change @ajaxChange + @extend Extend + @include Include + + # Private + + ajaxFetch: -> + @ajax().fetch(arguments...) + + ajaxChange: (record, type, options = {}) -> + return if options.ajax is false + record.ajax()[type](options.ajax, options) + +Model.Ajax.Methods = + extended: -> + @extend Extend + @include Include + +# Globals +Ajax.defaults = Base::defaults +Ajax.Base = Base +Ajax.Singleton = Singleton +Ajax.Collection = Collection +Spine.Ajax = Ajax +module?.exports = Ajax diff --git a/app/assets/javascripts/app/lib/spine/ajax.js b/app/assets/javascripts/app/lib/spine/ajax.js deleted file mode 100755 index 5926b1284..000000000 --- a/app/assets/javascripts/app/lib/spine/ajax.js +++ /dev/null @@ -1,386 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var $, Ajax, Base, Collection, Extend, Include, Model, Queue, Singleton, Spine, - __slice = [].slice, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - Spine = this.Spine || require('spine'); - - $ = Spine.$; - - Model = Spine.Model; - - Queue = $({}); - - Ajax = { - getURL: function(object) { - return (typeof object.url === "function" ? object.url() : void 0) || object.url; - }, - getCollectionURL: function(object) { - if (object) { - if (typeof object.url === "function") { - return this.generateURL(object); - } else { - return object.url; - } - } - }, - getScope: function(object) { - return (typeof object.scope === "function" ? object.scope() : void 0) || object.scope; - }, - generateURL: function() { - var args, collection, object, path, scope; - object = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - if (object.className) { - collection = object.className.toLowerCase() + 's'; - scope = Ajax.getScope(object); - } else { - if (typeof object.constructor.url === 'string') { - collection = object.constructor.url; - } else { - collection = object.constructor.className.toLowerCase() + 's'; - } - scope = Ajax.getScope(object) || Ajax.getScope(object.constructor); - } - args.unshift(collection); - args.unshift(scope); - path = args.join('/'); - path = path.replace(/(\/\/)/g, "/"); - path = path.replace(/^\/|\/$/g, ""); - if (path.indexOf("../") !== 0) { - return Model.host + "/" + path; - } else { - return path; - } - }, - enabled: true, - disable: function(callback) { - var e; - if (this.enabled) { - this.enabled = false; - try { - return callback(); - } catch (_error) { - e = _error; - throw e; - } finally { - this.enabled = true; - } - } else { - return callback(); - } - }, - queue: function(request) { - if (request) { - return Queue.queue(request); - } else { - return Queue.queue(); - } - }, - clearQueue: function() { - return this.queue([]); - } - }; - - Base = (function() { - function Base() {} - - Base.prototype.defaults = { - dataType: 'json', - processData: false, - headers: { - 'X-Requested-With': 'XMLHttpRequest' - } - }; - - Base.prototype.queue = Ajax.queue; - - Base.prototype.ajax = function(params, defaults) { - return $.ajax(this.ajaxSettings(params, defaults)); - }; - - Base.prototype.ajaxQueue = function(params, defaults, record) { - var deferred, jqXHR, promise, request, settings; - jqXHR = null; - deferred = $.Deferred(); - promise = deferred.promise(); - if (!Ajax.enabled) { - return promise; - } - settings = this.ajaxSettings(params, defaults); - request = function(next) { - var _ref; - if ((record != null ? record.id : void 0) != null) { - if (settings.url == null) { - settings.url = Ajax.getURL(record); - } - if ((_ref = settings.data) != null) { - _ref.id = record.id; - } - } - if (typeof settings.data !== 'string' && settings.processData !== true) { - settings.data = JSON.stringify(settings.data); - } - return jqXHR = $.ajax(settings).done(deferred.resolve).fail(deferred.reject).then(next, next); - }; - promise.abort = function(statusText) { - var index; - if (jqXHR) { - return jqXHR.abort(statusText); - } - index = $.inArray(request, this.queue()); - if (index > -1) { - this.queue().splice(index, 1); - } - deferred.rejectWith(settings.context || settings, [promise, statusText, '']); - return promise; - }; - this.queue(request); - return promise; - }; - - Base.prototype.ajaxSettings = function(params, defaults) { - return $.extend({}, this.defaults, defaults, params); - }; - - return Base; - - })(); - - Collection = (function(_super) { - __extends(Collection, _super); - - function Collection(model) { - this.model = model; - this.failResponse = __bind(this.failResponse, this); - this.recordsResponse = __bind(this.recordsResponse, this); - } - - Collection.prototype.find = function(id, params, options) { - var record; - if (options == null) { - options = {}; - } - record = new this.model({ - id: id - }); - return this.ajaxQueue(params, { - type: 'GET', - url: options.url || Ajax.getURL(record) - }).done(this.recordsResponse).fail(this.failResponse); - }; - - Collection.prototype.all = function(params, options) { - if (options == null) { - options = {}; - } - return this.ajaxQueue(params, { - type: 'GET', - url: options.url || Ajax.getURL(this.model) - }).done(this.recordsResponse).fail(this.failResponse); - }; - - Collection.prototype.fetch = function(params, options) { - var id, - _this = this; - if (params == null) { - params = {}; - } - if (options == null) { - options = {}; - } - if (id = params.id) { - delete params.id; - return this.find(id, params, options).done(function(record) { - return _this.model.refresh(record, options); - }); - } else { - return this.all(params, options).done(function(records) { - return _this.model.refresh(records, options); - }); - } - }; - - Collection.prototype.recordsResponse = function(data, status, xhr) { - return this.model.trigger('ajaxSuccess', null, status, xhr); - }; - - Collection.prototype.failResponse = function(xhr, statusText, error) { - return this.model.trigger('ajaxError', null, xhr, statusText, error); - }; - - return Collection; - - })(Base); - - Singleton = (function(_super) { - __extends(Singleton, _super); - - function Singleton(record) { - this.record = record; - this.failResponse = __bind(this.failResponse, this); - this.recordResponse = __bind(this.recordResponse, this); - this.model = this.record.constructor; - } - - Singleton.prototype.reload = function(params, options) { - if (options == null) { - options = {}; - } - return this.ajaxQueue(params, { - type: 'GET', - url: options.url - }, this.record).done(this.recordResponse(options)).fail(this.failResponse(options)); - }; - - Singleton.prototype.create = function(params, options) { - if (options == null) { - options = {}; - } - return this.ajaxQueue(params, { - type: 'POST', - contentType: 'application/json', - data: this.record.toJSON(), - url: options.url || Ajax.getCollectionURL(this.record) - }).done(this.recordResponse(options)).fail(this.failResponse(options)); - }; - - Singleton.prototype.update = function(params, options) { - if (options == null) { - options = {}; - } - return this.ajaxQueue(params, { - type: 'PUT', - contentType: 'application/json', - data: this.record.toJSON(), - url: options.url - }, this.record).done(this.recordResponse(options)).fail(this.failResponse(options)); - }; - - Singleton.prototype.destroy = function(params, options) { - if (options == null) { - options = {}; - } - return this.ajaxQueue(params, { - type: 'DELETE', - url: options.url - }, this.record).done(this.recordResponse(options)).fail(this.failResponse(options)); - }; - - Singleton.prototype.recordResponse = function(options) { - var _this = this; - if (options == null) { - options = {}; - } - return function(data, status, xhr) { - var _ref, _ref1; - Ajax.disable(function() { - if (!(Spine.isBlank(data) || _this.record.destroyed)) { - if (data.id && _this.record.id !== data.id) { - _this.record.changeID(data.id); - } - return _this.record.refresh(data); - } - }); - _this.record.trigger('ajaxSuccess', data, status, xhr); - if ((_ref = options.success) != null) { - _ref.apply(_this.record); - } - return (_ref1 = options.done) != null ? _ref1.apply(_this.record) : void 0; - }; - }; - - Singleton.prototype.failResponse = function(options) { - var _this = this; - if (options == null) { - options = {}; - } - return function(xhr, statusText, error) { - var _ref, _ref1; - _this.record.trigger('ajaxError', xhr, statusText, error); - if ((_ref = options.error) != null) { - _ref.apply(_this.record); - } - return (_ref1 = options.fail) != null ? _ref1.apply(_this.record) : void 0; - }; - }; - - return Singleton; - - })(Base); - - Model.host = ''; - - Include = { - ajax: function() { - return new Singleton(this); - }, - url: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - args.unshift(encodeURIComponent(this.id)); - return Ajax.generateURL.apply(Ajax, [this].concat(__slice.call(args))); - } - }; - - Extend = { - ajax: function() { - return new Collection(this); - }, - url: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return Ajax.generateURL.apply(Ajax, [this].concat(__slice.call(args))); - } - }; - - Model.Ajax = { - extended: function() { - this.fetch(this.ajaxFetch); - this.change(this.ajaxChange); - this.extend(Extend); - return this.include(Include); - }, - ajaxFetch: function() { - var _ref; - return (_ref = this.ajax()).fetch.apply(_ref, arguments); - }, - ajaxChange: function(record, type, options) { - if (options == null) { - options = {}; - } - if (options.ajax === false) { - return; - } - return record.ajax()[type](options.ajax, options); - } - }; - - Model.Ajax.Methods = { - extended: function() { - this.extend(Extend); - return this.include(Include); - } - }; - - Ajax.defaults = Base.prototype.defaults; - - Ajax.Base = Base; - - Ajax.Singleton = Singleton; - - Ajax.Collection = Collection; - - Spine.Ajax = Ajax; - - if (typeof module !== "undefined" && module !== null) { - module.exports = Ajax; - } - -}).call(this); - -/* -//@ sourceMappingURL=ajax.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/ajax.map b/app/assets/javascripts/app/lib/spine/ajax.map deleted file mode 100755 index eccd61cf8..000000000 --- a/app/assets/javascripts/app/lib/spine/ajax.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "ajax.js", - "sourceRoot": "..", - "sources": [ - "src/ajax.coffee" - ], - "names": [], - "mapp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AAJ;;CA5PA,CA6PA,CAAkB,CAAd,MAAJ;;CA7PA,CA8PA,CAAkB,CAAlB,CAAK;;;CACG,EAAU,CAAlB,EAAM,CAAN;IA/PA;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/bindings.coffee b/app/assets/javascripts/app/lib/spine/bindings.coffee new file mode 100755 index 000000000..6b77143c5 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/bindings.coffee @@ -0,0 +1,95 @@ +BindingsClass = + + model: 'model' + + bindings: {} + + +class ValueSetter + + constructor: (@context) -> + + setValue: (element, value, setter) -> + if typeof setter is 'string' + setter = @context.proxy(@context[setter]) + setter = setter || (e, v) => @_standardSetter e, v + setter element, value + + getValue: (element, getter) -> + if typeof getter is 'string' + getter = @context.proxy(@context[getter]) + getter = getter || (e, v) => @_standardGetter e, v + getter element + + _standardGetter: (element) -> + self = @ + self["_#{element.attr("type")}Get"]?(element) || element.val() + + _standardSetter: (element, value) -> + self = @ + element.each -> + el = $(this) + self["_#{el.attr("type")}Set"]?(el, value) || el.val(value) + + _checkboxSet: (element, value) -> + if value + element.prop("checked", "checked") + else + element.prop("checked", "") + + _checkboxGet: (element) -> + element.is(":checked") + +BindingsInstance = + + getModel: -> + @[@modelVar] + + setModel: (model) -> + @[@modelVar] = model + + walkBindings: (fn) -> + for selector, field of @bindings + fn selector, field + + applyBindings: -> + @valueSetter = new ValueSetter @ + @walkBindings (selector, field) => + if not field.direction or field.direction is 'model' + @_bindModelToEl @getModel(), field, selector + if not field.direction or field.direction is 'element' + @_bindElToModel @getModel(), field, selector + + _getField: (value) -> + if typeof value is 'string' + value + else + value.field + + _forceModelBindings: (model) -> + @walkBindings (selector, field) => + @valueSetter.setValue @$(selector), model[@_getField(field)], field.setter + + changeBindingSource: (model) -> + @getModel().unbind 'change' + @walkBindings (selector) => + selector = false if selector is 'self' + @el.off 'change', selector + @setModel model + @_forceModelBindings model + do @applyBindings + + _bindModelToEl: (model, field, selector) -> + self = @ + selector = false if selector is 'self' + @el.on 'change', selector, -> + model[self._getField(field)] = self.valueSetter.getValue $(this), field.getter + + _bindElToModel: (model, field, selector) -> + model.bind 'change', => + @valueSetter.setValue @$(selector), model[@_getField(field)], field.setter + +Spine.Bindings = + extended: -> + @extend BindingsClass + @include BindingsInstance diff --git a/app/assets/javascripts/app/lib/spine/list.coffee b/app/assets/javascripts/app/lib/spine/list.coffee new file mode 100755 index 000000000..7c2f97a73 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/list.coffee @@ -0,0 +1,47 @@ +Spine = @Spine or require('spine') +$ = Spine.$ + +class Spine.List extends Spine.Controller + events: + 'click .item': 'click' + + selectFirst: false + + constructor: -> + super + @bind 'change', @change + + template: -> + throw Error 'Override template' + + change: (item) => + @current = item + + unless @current + @children().removeClass('active') + return + + @children().removeClass('active') + for item, idx in @items when item is @current + index = idx + break + + $(@children().get(index)).addClass('active') + + render: (items) -> + @items = items if items + @html @template(@items) + @change @current + if @selectFirst + unless @children('.active').length + @children(':first').click() + + children: (sel) -> + @el.children(sel) + + click: (e) -> + item = @items[$(e.currentTarget).index()] + @trigger('change', item) + true + +module?.exports = Spine.List diff --git a/app/assets/javascripts/app/lib/spine/list.js b/app/assets/javascripts/app/lib/spine/list.js deleted file mode 100755 index 3e7f821b9..000000000 --- a/app/assets/javascripts/app/lib/spine/list.js +++ /dev/null @@ -1,77 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var $, Spine, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - Spine = this.Spine || require('spine'); - - $ = Spine.$; - - Spine.List = (function(_super) { - __extends(List, _super); - - List.prototype.events = { - 'click .item': 'click' - }; - - List.prototype.selectFirst = false; - - function List() { - this.change = __bind(this.change, this); - List.__super__.constructor.apply(this, arguments); - this.bind('change', this.change); - } - - List.prototype.template = function() { - throw 'Override template'; - }; - - List.prototype.change = function(item) { - this.current = item; - if (!this.current) { - this.children().removeClass('active'); - return; - } - this.children().removeClass('active'); - return $(this.children().get(this.items.indexOf(this.current))).addClass('active'); - }; - - List.prototype.render = function(items) { - if (items) { - this.items = items; - } - this.html(this.template(this.items)); - this.change(this.current); - if (this.selectFirst) { - if (!this.children('.active').length) { - return this.children(':first').click(); - } - } - }; - - List.prototype.children = function(sel) { - return this.el.children(sel); - }; - - List.prototype.click = function(e) { - var item; - item = this.items[$(e.currentTarget).index()]; - this.trigger('change', item); - return true; - }; - - return List; - - })(Spine.Controller); - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine.List; - } - -}).call(this); - -/* -//@ sourceMappingURL=list.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/list.map b/app/assets/javascripts/app/lib/spine/list.map deleted file mode 100755 index 44f03b886..000000000 --- a/app/assets/javascripts/app/lib/spine/list.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "list.js", - "sourceRoot": "..", - "sources": [ - "src/list.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,EAAA;KAAA;;oSAAA;;CAAA,CAAA,CAAS,CAAC,CAAV,EAAmB;;CAAnB,CACA,CAAS,EAAK;;CADd,CAGM,GAAK;CACT;;CAAA,EACE,GADF;CACE,CAAe,IAAf,CAAA,MAAA;CADF,KAAA;;CAAA,EAGa,EAHb,MAGA;;CAEa,EAAA,CAAA,UAAA;CACX,sCAAA;CAAA,KAAA,GAAA,8BAAA;CAAA,CACgB,EAAf,EAAD,EAAA;CAPF,IAKa;;CALb,EASU,KAAV,CAAU;CACR,WAAM,OAAN;CAVF,IASU;;CATV,EAYQ,CAAA,EAAR,GAAS;CACP,EAAW,CAAV,EAAD,CAAA;AAEO,CAAP,GAAA,EAAA,CAAA;CACE,GAAC,IAAD,GAAA;CACA,aAAA;QAJF;CAAA,GAMC,EAAD,EAAA,GAAA;CACA,EAAE,CAAC,CAAqB,EAAN,CAAhB,KAAF;CApBF,IAYQ;;CAZR,EAsBQ,EAAA,CAAR,GAAS;CACP,GAAkB,CAAlB,CAAA;CAAA,EAAS,CAAR,CAAD,GAAA;QAAA;CAAA,GACC,CAAK,CAAN,EAAM;CADN,GAEC,EAAD,CAAA;CACA,GAAG,EAAH,KAAA;AACS,CAAP,GAAA,EAAA,EAAA,CAAO;CACJ,GAAA,CAAD,GAAA,SAAA;UAFJ;QAJM;CAtBR,IAsBQ;;CAtBR,EA8BU,KAAV,CAAW;CACR,CAAE,CAAH,CAAC,IAAD,KAAA;CA/BF,IA8BU;;CA9BV,EAiCO,EAAP,IAAQ;CACN,GAAA,MAAA;CAAA,EAAO,CAAP,CAAc,CAAd,OAAc;CAAd,CACmB,EAAlB,EAAD,CAAA,CAAA;CAFK,YAGL;CApCF,IAiCO;;CAjCP;;CADuB,IAAK;;;CAuCtB,EAAU,CAAlB,CAAuB,CAAjB,CAAN;IA1CA;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/local.coffee b/app/assets/javascripts/app/lib/spine/local.coffee new file mode 100755 index 000000000..ff3b688fe --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/local.coffee @@ -0,0 +1,17 @@ +Spine = @Spine or require('spine') + +Spine.Model.Local = + extended: -> + @change @saveLocal + @fetch @loadLocal + + saveLocal: -> + result = JSON.stringify(@) + localStorage[@className] = result + + loadLocal: (options = {})-> + options.clear = true unless options.hasOwnProperty('clear') + result = localStorage[@className] + @refresh(result or [], options) + +module?.exports = Spine.Model.Local \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/local.js b/app/assets/javascripts/app/lib/spine/local.js deleted file mode 100755 index 3ae68d976..000000000 --- a/app/assets/javascripts/app/lib/spine/local.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var Spine; - - Spine = this.Spine || require('spine'); - - Spine.Model.Local = { - extended: function() { - this.change(this.saveLocal); - return this.fetch(this.loadLocal); - }, - saveLocal: function() { - var result; - result = JSON.stringify(this); - return localStorage[this.className] = result; - }, - loadLocal: function(options) { - var result; - if (options == null) { - options = {}; - } - if (!options.hasOwnProperty('clear')) { - options.clear = true; - } - result = localStorage[this.className]; - return this.refresh(result || [], options); - } - }; - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine.Model.Local; - } - -}).call(this); - -/* -//@ sourceMappingURL=local.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/local.map b/app/assets/javascripts/app/lib/spine/local.map deleted file mode 100755 index 538c8dd13..000000000 --- a/app/assets/javascripts/app/lib/spine/local.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "local.js", - "sourceRoot": "..", - "sources": [ - "src/local.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,IAAA,CAAA;;CAAA,CAAA,CAAQ,CAAC,CAAT,EAAkB;;CAAlB,CAEA,CACE,EADG;CACH,CAAU,CAAA,CAAV,IAAA,CAAU;CACR,GAAC,EAAD,GAAA;CACC,GAAA,CAAD,IAAA,IAAA;CAFF,IAAU;CAAV,CAIW,CAAA,CAAX,KAAA;CACE,KAAA,IAAA;CAAA,EAAS,CAAI,EAAb,GAAS;CACI,EAAc,CAAb,KAAD,GAAA,CAAb;CANF,IAIW;CAJX,CAQW,CAAA,CAAX,GAAW,EAAX;CACE,KAAA,IAAA;;GADoB,KAAV;QACV;AAA4B,CAA5B,GAAA,EAAA,CAAmC,OAAP;CAA5B,EAAgB,CAAhB,CAAA,EAAO,CAAP;QAAA;CAAA,EACS,CAAc,EAAvB,GAAsB,GAAA;CACrB,CAAD,EAAC,EAAQ,CAAT,MAAA;CAXF,IAQW;CAXb,GAAA;;;CAgBQ,EAAU,CAAlB,CAAuB,CAAjB,CAAN;IAhBA;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/manager.coffee b/app/assets/javascripts/app/lib/spine/manager.coffee new file mode 100755 index 000000000..3d44e39b0 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/manager.coffee @@ -0,0 +1,83 @@ +Spine = @Spine or require('spine') +$ = Spine.$ + +class Spine.Manager extends Spine.Module + @include Spine.Events + + constructor: -> + @controllers = [] + @bind 'change', @change + @add(arguments...) + + add: (controllers...) -> + @addOne(cont) for cont in controllers + + addOne: (controller) -> + controller.bind 'active', (args...) => + @trigger('change', controller, args...) + controller.bind 'release', => + @controllers = (c for c in @controllers when c isnt controller) + + @controllers.push(controller) + + deactivate: -> + @trigger('change', false, arguments...) + + # Private + + change: (current, args...) -> + for cont in @controllers when cont isnt current + cont.deactivate(args...) + + current.activate(args...) if current + +Spine.Controller.include + active: (args...) -> + if typeof args[0] is 'function' + @bind('active', args[0]) + else + args.unshift('active') + @trigger(args...) + @ + + isActive: -> + @el.hasClass('active') + + activate: -> + @el.addClass('active') + @ + + deactivate: -> + @el.removeClass('active') + @ + +class Spine.Stack extends Spine.Controller + controllers: {} + routes: {} + + className: 'spine stack' + + constructor: -> + super + + @manager = new Spine.Manager + + for key, value of @controllers + throw Error "'@#{ key }' already assigned - choose a different name" if @[key]? + @[key] = new value(stack: @) + @add(@[key]) + + for key, value of @routes + do (key, value) => + callback = value if typeof value is 'function' + callback or= => @[value].active(arguments...) + @route(key, callback) + + @[@default].active() if @default + + add: (controller) -> + @manager.add(controller) + @append(controller) + +module?.exports = Spine.Manager +module?.exports.Stack = Spine.Stack diff --git a/app/assets/javascripts/app/lib/spine/manager.js b/app/assets/javascripts/app/lib/spine/manager.js deleted file mode 100755 index 9ce90e97f..000000000 --- a/app/assets/javascripts/app/lib/spine/manager.js +++ /dev/null @@ -1,162 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var $, Spine, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __slice = [].slice; - - Spine = this.Spine || require('spine'); - - $ = Spine.$; - - Spine.Manager = (function(_super) { - __extends(Manager, _super); - - Manager.include(Spine.Events); - - function Manager() { - this.controllers = []; - this.bind('change', this.change); - this.add.apply(this, arguments); - } - - Manager.prototype.add = function() { - var cont, controllers, _i, _len, _results; - controllers = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - _results = []; - for (_i = 0, _len = controllers.length; _i < _len; _i++) { - cont = controllers[_i]; - _results.push(this.addOne(cont)); - } - return _results; - }; - - Manager.prototype.addOne = function(controller) { - var _this = this; - controller.bind('active', function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return _this.trigger.apply(_this, ['change', controller].concat(__slice.call(args))); - }); - controller.bind('release', function() { - return _this.controllers.splice(_this.controllers.indexOf(controller), 1); - }); - return this.controllers.push(controller); - }; - - Manager.prototype.deactivate = function() { - return this.trigger.apply(this, ['change', false].concat(__slice.call(arguments))); - }; - - Manager.prototype.change = function() { - var args, cont, current, _i, _len, _ref; - current = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - _ref = this.controllers; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - cont = _ref[_i]; - if (cont !== current) { - cont.deactivate.apply(cont, args); - } - } - if (current) { - return current.activate.apply(current, args); - } - }; - - return Manager; - - })(Spine.Module); - - Spine.Controller.include({ - active: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - if (typeof args[0] === 'function') { - this.bind('active', args[0]); - } else { - args.unshift('active'); - this.trigger.apply(this, args); - } - return this; - }, - isActive: function() { - return this.el.hasClass('active'); - }, - activate: function() { - this.el.addClass('active'); - return this; - }, - deactivate: function() { - this.el.removeClass('active'); - return this; - } - }); - - Spine.Stack = (function(_super) { - __extends(Stack, _super); - - Stack.prototype.controllers = {}; - - Stack.prototype.routes = {}; - - Stack.prototype.className = 'spine stack'; - - function Stack() { - var key, value, _fn, _ref, _ref1, - _this = this; - Stack.__super__.constructor.apply(this, arguments); - this.manager = new Spine.Manager; - _ref = this.controllers; - for (key in _ref) { - value = _ref[key]; - if (this[key] != null) { - throw Error("'@" + key + "' already assigned - choose a different name"); - } - this[key] = new value({ - stack: this - }); - this.add(this[key]); - } - _ref1 = this.routes; - _fn = function(key, value) { - var callback; - if (typeof value === 'function') { - callback = value; - } - callback || (callback = function() { - var _ref2; - return (_ref2 = _this[value]).active.apply(_ref2, arguments); - }); - return _this.route(key, callback); - }; - for (key in _ref1) { - value = _ref1[key]; - _fn(key, value); - } - if (this["default"]) { - this[this["default"]].active(); - } - } - - Stack.prototype.add = function(controller) { - this.manager.add(controller); - return this.append(controller); - }; - - return Stack; - - })(Spine.Controller); - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine.Manager; - } - - if (typeof module !== "undefined" && module !== null) { - module.exports.Stack = Spine.Stack; - } - -}).call(this); - -/* -//@ sourceMappingURL=manager.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/manager.map b/app/assets/javascripts/app/lib/spine/manager.map deleted file mode 100755 index 6a10eb252..000000000 --- a/app/assets/javascripts/app/lib/spine/manager.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "manager.js", - "sourceRoot": "..", - "sources": [ - "src/manager.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,EAAA;KAAA;;uBAAA;;CAAA,CAAA,CAAS,CAAC,CAAV,EAAmB;;CAAnB,CACA,CAAS,EAAK;;CADd,CAGM,GAAK;CACT;;CAAA,GAAA,CAAc,CAAd,CAAC;;CAEY,EAAA,CAAA,aAAA;CACX,CAAA,CAAe,CAAd,EAAD,KAAA;CAAA,CACgB,EAAf,EAAD,EAAA;CADA,EAEA,CAAC,EAAD,GAAA,IAAK;CALP,IAEa;;CAFb,EAOA,MAAK;CACH,SAAA,2BAAA;CAAA,KADI,iDACJ;AAAA,CAAA;YAAA,sCAAA;gCAAA;CAAA,GAAC,EAAD;CAAA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CAAG,EAAF,EAAD,EAAA,GAAA;CADU,YAEV;CAjBF,IAeY;CAjDd,GAiCA;;CAjCA,CAqDM,GAAK;CACT;;CAAA,CAAA,CAAa,QAAb;;CAAA,CAAA,CACQ,GAAR;;CADA,EAGW,MAAX,IAHA;;CAKa,EAAA,CAAA,WAAA;CACX,SAAA,kBAAA;SAAA,GAAA;CAAA,KAAA,GAAA,+BAAA;AAEW,CAFX,EAEW,CAAV,CAAmB,CAApB,CAAA;CAEA;CAAA,UAAA;2BAAA;CACE,GAAwE,IAAxE,SAAA;CAAA,EAAL,CAAkB,CAAP,WAAA,8BAAA;UAAN;CAAA,EACE,CAAA,CAAW,GAAb;CAAmB,CAAO,EAAP,CAAA,KAAA;CADnB,SACa;CADb,EAEA,CAAC,IAAD;CAHF,MAJA;CASA;CAAA,CACW,CAAN,EAAA,IAAC;CACF,OAAA,IAAA;AAAoB,CAApB,GAAoB,CAAA,CAAA,EAApB,EAAA;CAAA,EAAW,EAAX,GAAA,EAAA;UAAA;CAAA,EACa,KAAb,CAAa;CAAG,IAAA,SAAA;CAAE,IAAA,CAAF,GAAA,KAAgB,GAAhB;CADhB,QACa;CACZ,CAAW,CAAZ,EAAC,GAAD,OAAA;CAJJ,MACK;CADL,UAAA,CAAA;4BAAA;CACE,CAAS;CADX,MATA;CAeA,GAAwB,EAAxB,GAAyB;CAAzB,GAAE,EAAF,EAAA,CAAG;QAhBQ;CALb,IAKa;;CALb,EAuBA,MAAM,CAAD;CACH,EAAA,CAAC,EAAD,CAAQ,GAAR;CACC,GAAA,EAAD,IAAA,GAAA;CAzBF,IAuBK;;CAvBL;;CADwB,IAAK;;;CA4BvB,EAAU,CAAlB,CAAuB,CAAjB,CAAN;IAjFA;;;CAkFQ,EAAgB,CAAxB,CAAA,CAAM,CAAS;IAlFf;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/relation.coffee b/app/assets/javascripts/app/lib/spine/relation.coffee new file mode 100755 index 000000000..2c506709f --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/relation.coffee @@ -0,0 +1,137 @@ +Spine = @Spine or require('spine') +isArray = Spine.isArray +require = @require or ((value) -> eval(value)) + +class Collection extends Spine.Module + constructor: (options = {}) -> + for key, value of options + @[key] = value + + all: -> + @model.select (rec) => @associated(rec) + + first: -> + @all()[0] + + last: -> + values = @all() + values[values.length - 1] + + count: -> + @all().length + + find: (id, notFound = @model.notFound) -> + records = @select (rec) => + "#{rec.id}" is "#{id}" + return records[0] or notFound?(id) + + findAllByAttribute: (name, value) -> + @model.select (rec) => + @associated(rec) and rec[name] is value + + findByAttribute: (name, value) -> + @findAllByAttribute(name, value)[0] + + select: (cb) -> + @model.select (rec) => + @associated(rec) and cb(rec) + + refresh: (values) -> + return this unless values? + for record in @all() + delete @model.irecords[record.id] + for match, i in @model.records when match.id is record.id + @model.records.splice(i, 1) + break + values = [values] unless isArray(values) + for record in values + record.newRecord = false + record[@fkey] = @record.id + @model.refresh values + this + + create: (record, options) -> + record[@fkey] = @record.id + @model.create(record, options) + + add: (record, options) -> + record.updateAttribute @fkey, @record.id, options + + remove: (record, options) -> + record.updateAttribute @fkey, null, options + + # Private + + associated: (record) -> + record[@fkey] is @record.id + +class Instance extends Spine.Module + constructor: (options = {}) -> + for key, value of options + @[key] = value + + exists: -> + return if @record[@fkey] then @model.exists(@record[@fkey]) else false + + find: -> + return @model.find(@record[@fkey]) + + update: (value) -> + return this unless value? + unless value instanceof @model + value = new @model(value) + value.save() if value.isNew() + @record[@fkey] = value and value.id + this + +class Singleton extends Spine.Module + constructor: (options = {}) -> + for key, value of options + @[key] = value + + find: -> + @record.id and @model.findByAttribute(@fkey, @record.id) + + update: (value) -> + return this unless value? + unless value instanceof @model + value = @model.fromJSON(value) + + value[@fkey] = @record.id + value.save() + this + +singularize = (str) -> + str.replace(/s$/, '') + +underscore = (str) -> + str.replace(/::/g, '/') + .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') + .replace(/([a-z\d])([A-Z])/g, '$1_$2') + .replace(/-/g, '_') + .toLowerCase() + +association = (name, model, record, fkey, Ctor) -> + model = require(model) if typeof model is 'string' + new Ctor(name: name, model: model, record: record, fkey: fkey) + +Spine.Model.extend + hasMany: (name, model, fkey) -> + fkey ?= "#{underscore(this.className)}_id" + @::[name] = (value) -> + association(name, model, @, fkey, Collection).refresh(value) + + belongsTo: (name, model, fkey) -> + fkey ?= "#{underscore(singularize(name))}_id" + @::[name] = (value) -> + association(name, model, @, fkey, Instance).update(value).find() + @attributes.push(fkey) + + hasOne: (name, model, fkey) -> + fkey ?= "#{underscore(@className)}_id" + @::[name] = (value) -> + association(name, model, @, fkey, Singleton).update(value).find() + +Spine.Collection = Collection +Spine.Singleton = Singleton +Spine.Instance = Instance diff --git a/app/assets/javascripts/app/lib/spine/relation.js b/app/assets/javascripts/app/lib/spine/relation.js deleted file mode 100755 index 0afb8d4f1..000000000 --- a/app/assets/javascripts/app/lib/spine/relation.js +++ /dev/null @@ -1,264 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var Collection, Instance, Singleton, Spine, association, isArray, require, singularize, underscore, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - Spine = this.Spine || require('spine'); - - isArray = Spine.isArray; - - require = this.require || (function(value) { - return eval(value); - }); - - Collection = (function(_super) { - __extends(Collection, _super); - - function Collection(options) { - var key, value; - if (options == null) { - options = {}; - } - for (key in options) { - value = options[key]; - this[key] = value; - } - } - - Collection.prototype.all = function() { - var _this = this; - return this.model.select(function(rec) { - return _this.associated(rec); - }); - }; - - Collection.prototype.first = function() { - return this.all()[0]; - }; - - Collection.prototype.last = function() { - var values; - values = this.all(); - return values[values.length - 1]; - }; - - Collection.prototype.count = function() { - return this.all().length; - }; - - Collection.prototype.find = function(id) { - var records, - _this = this; - records = this.select(function(rec) { - return ("" + rec.id) === ("" + id); - }); - if (!records[0]) { - throw new Error("\"" + this.model.className + "\" model could not find a record for the ID \"" + id + "\""); - } - return records[0]; - }; - - Collection.prototype.findAllByAttribute = function(name, value) { - var _this = this; - return this.model.select(function(rec) { - return _this.associated(rec) && rec[name] === value; - }); - }; - - Collection.prototype.findByAttribute = function(name, value) { - return this.findAllByAttribute(name, value)[0]; - }; - - Collection.prototype.select = function(cb) { - var _this = this; - return this.model.select(function(rec) { - return _this.associated(rec) && cb(rec); - }); - }; - - Collection.prototype.refresh = function(values) { - var i, match, record, _i, _j, _k, _len, _len1, _len2, _ref, _ref1; - if (values == null) { - return this; - } - _ref = this.all(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - record = _ref[_i]; - delete this.model.irecords[record.id]; - _ref1 = this.model.records; - for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) { - match = _ref1[i]; - if (!(match.id === record.id)) { - continue; - } - this.model.records.splice(i, 1); - break; - } - } - if (!isArray(values)) { - values = [values]; - } - for (_k = 0, _len2 = values.length; _k < _len2; _k++) { - record = values[_k]; - record.newRecord = false; - record[this.fkey] = this.record.id; - } - this.model.refresh(values); - return this; - }; - - Collection.prototype.create = function(record, options) { - record[this.fkey] = this.record.id; - return this.model.create(record, options); - }; - - Collection.prototype.add = function(record, options) { - return record.updateAttribute(this.fkey, this.record.id, options); - }; - - Collection.prototype.remove = function(record, options) { - return record.updateAttribute(this.fkey, null, options); - }; - - Collection.prototype.associated = function(record) { - return record[this.fkey] === this.record.id; - }; - - return Collection; - - })(Spine.Module); - - Instance = (function(_super) { - __extends(Instance, _super); - - function Instance(options) { - var key, value; - if (options == null) { - options = {}; - } - for (key in options) { - value = options[key]; - this[key] = value; - } - } - - Instance.prototype.exists = function() { - if (this.record[this.fkey]) { - return this.model.exists(this.record[this.fkey]); - } else { - return false; - } - }; - - Instance.prototype.update = function(value) { - if (value == null) { - return this; - } - if (!(value instanceof this.model)) { - value = new this.model(value); - } - if (value.isNew()) { - value.save(); - } - this.record[this.fkey] = value && value.id; - return this; - }; - - return Instance; - - })(Spine.Module); - - Singleton = (function(_super) { - __extends(Singleton, _super); - - function Singleton(options) { - var key, value; - if (options == null) { - options = {}; - } - for (key in options) { - value = options[key]; - this[key] = value; - } - } - - Singleton.prototype.find = function() { - return this.record.id && this.model.findByAttribute(this.fkey, this.record.id); - }; - - Singleton.prototype.update = function(value) { - if (value == null) { - return this; - } - if (!(value instanceof this.model)) { - value = this.model.fromJSON(value); - } - value[this.fkey] = this.record.id; - value.save(); - return this; - }; - - return Singleton; - - })(Spine.Module); - - singularize = function(str) { - return str.replace(/s$/, ''); - }; - - underscore = function(str) { - return str.replace(/::/g, '/').replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2').replace(/([a-z\d])([A-Z])/g, '$1_$2').replace(/-/g, '_').toLowerCase(); - }; - - association = function(name, model, record, fkey, Ctor) { - if (typeof model === 'string') { - model = require(model); - } - return new Ctor({ - name: name, - model: model, - record: record, - fkey: fkey - }); - }; - - Spine.Model.extend({ - hasMany: function(name, model, fkey) { - if (fkey == null) { - fkey = "" + (underscore(this.className)) + "_id"; - } - return this.prototype[name] = function(value) { - return association(name, model, this, fkey, Collection).refresh(value); - }; - }, - belongsTo: function(name, model, fkey) { - if (fkey == null) { - fkey = "" + (underscore(singularize(name))) + "_id"; - } - this.prototype[name] = function(value) { - return association(name, model, this, fkey, Instance).update(value).exists(); - }; - return this.attributes.push(fkey); - }, - hasOne: function(name, model, fkey) { - if (fkey == null) { - fkey = "" + (underscore(this.className)) + "_id"; - } - return this.prototype[name] = function(value) { - return association(name, model, this, fkey, Singleton).update(value).find(); - }; - } - }); - - Spine.Collection = Collection; - - Spine.Singleton = Singleton; - - Spine.Instance = Instance; - -}).call(this); - -/* -//@ sourceMappingURL=relation.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/relation.map b/app/assets/javascripts/app/lib/spine/relation.map deleted file mode 100755 index adc49d975..000000000 --- a/app/assets/javascripts/app/lib/spine/relation.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "relation.js", - "sourceRoot": "..", - "sources": [ - "src/relation.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,wFAAA;KAAA;oSAAA;;CAAA,CAAA,CAAU,CAAC,CAAX,EAAoB;;CAApB,CACA,CAAU,EAAK,EAAf;;CADA,CAEA,CAAU,CAAC,CAAY,EAAvB,EAAwB;CAAe,GAAL,CAAA,MAAA;CAAZ,EAAC;;CAFvB,CAIM;CACJ;;CAAa,EAAA,CAAA,GAAA,aAAC;CACZ,SAAA;;GADsB,KAAV;QACZ;AAAA,CAAA,UAAA,GAAA;8BAAA;CACE,EAAE,CAAA,CAAF,GAAA;CADF,MADW;CAAb,IAAa;;CAAb,EAIA,MAAK;CACH,SAAA,EAAA;CAAC,EAAa,CAAb,CAAK,CAAN,GAAe,IAAf;CAAwB,EAAD,EAAC,KAAD,KAAA;CAAvB,MAAc;CALhB,IAIK;;CAJL,EAOO,EAAP,IAAO;CACJ,EAAD,CAAC,SAAD;CARF,IAOO;;CAPP,EAUM,CAAN,KAAM;CACJ,KAAA,IAAA;CAAA,EAAS,CAAC,EAAV;CACO,EAAgB,GAAhB,OAAP;CAZF,IAUM;;CAVN,EAcO,EAAP,IAAO;CACJ,EAAD,CAAC,SAAD;CAfF,IAcO;;CAdP,CAiBM,CAAA,CAAN,KAAO;CACL,MAAA,GAAA;SAAA,GAAA;CAAA,EAAU,CAAC,EAAX,CAAA,EAAmB;CACjB,CAAA,CAAE,EAAa,UAAf;CADQ,MAAQ;AAEmF,CAArG,GAAA,EAAA,CAA6G;CAA7G,CAAiB,CAAG,CAAV,CAAA,IAAO,KAAP,kCAAO;QAFjB;CAGQ,MAAA,MAAR;CArBF,IAiBM;;CAjBN,CAuB2B,CAAP,CAAA,CAAA,IAAC,SAArB;CACE,SAAA,EAAA;CAAC,EAAa,CAAb,CAAK,CAAN,GAAe,IAAf;CACG,EAAD,CAA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new file mode 100755 index 000000000..0ecb63275 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/route.coffee @@ -0,0 +1,159 @@ +Spine = @Spine or require('spine') +$ = Spine.$ + +hashStrip = /^#*/ +namedParam = /:([\w\d]+)/g +splatParam = /\*([\w\d]+)/g +escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g + +class Spine.Route extends Spine.Module + @extend Spine.Events + + @historySupport: window.history?.pushState? + + @routes: [] + + @options: + trigger: true + history: false + shim: false + replace: false + redirect: false + + @add: (path, callback) -> + if (typeof path is 'object' and path not instanceof RegExp) + @add(key, value) for key, value of path + else + @routes.push(new @(path, callback)) + + @setup: (options = {}) -> + @options = $.extend({}, @options, options) + + if (@options.history) + @history = @historySupport and @options.history + + return if @options.shim + + if @history + $(window).bind('popstate', @change) + else + $(window).bind('hashchange', @change) + @change() + + @unbind: -> + return if @options.shim + + if @history + $(window).unbind('popstate', @change) + else + $(window).unbind('hashchange', @change) + + @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) + + route = @matchRoute(@path, options) if options.trigger + + return if options.shim + + if !route + 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 + history.replaceState({}, document.title, @path) + else if @history + history.pushState({}, document.title, @path) + else + window.location.hash = @path + + # Private + + @getPath: -> + if @history + path = window.location.pathname + path = '/' + path if path.substr(0,1) isnt '/' + else + path = window.location.hash + path = path.replace(hashStrip, '') + path + + @getHost: -> + "#{window.location.protocol}//#{window.location.host}" + + @change: -> + path = @getPath() + return if path is @path + @path = path + @matchRoute(@path) + + @matchRoute: (path, options) -> + for route in @routes when route.match(path, options) + @trigger('change', route, path) + return route + + @redirect: (path) -> + window.location = path + + constructor: (@path, @callback) -> + @names = [] + + if typeof path is 'string' + namedParam.lastIndex = 0 + while (match = namedParam.exec(path)) != null + @names.push(match[1]) + + splatParam.lastIndex = 0 + while (match = splatParam.exec(path)) != null + @names.push(match[1]) + + path = path.replace(escapeRegExp, '\\$&') + .replace(namedParam, '([^\/]*)') + .replace(splatParam, '(.*?)') + + @route = new RegExp("^#{path}$") + else + @route = path + + match: (path, options = {}) -> + match = @route.exec(path) + return false unless match + options.match = match + params = match.slice(1) + + if @names.length + for param, i in params + options[@names[i]] = param + @.constructor.trigger('before', @) + @callback.call(null, options) isnt false + +# Coffee-script bug +Spine.Route.change = Spine.Route.proxy(Spine.Route.change) + +Spine.Controller.include + route: (path, callback) -> + Spine.Route.add(path, @proxy(callback)) + + routes: (routes) -> + @route(key, value) for key, value of routes + + navigate: -> + Spine.Route.navigate.apply(Spine.Route, arguments) + +module?.exports = Spine.Route diff --git a/app/assets/javascripts/app/lib/spine/route.js b/app/assets/javascripts/app/lib/spine/route.js deleted file mode 100755 index 4f2a81bb0..000000000 --- a/app/assets/javascripts/app/lib/spine/route.js +++ /dev/null @@ -1,242 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var $, Spine, escapeRegExp, hashStrip, namedParam, splatParam, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __slice = [].slice; - - Spine = this.Spine || require('spine'); - - $ = Spine.$; - - hashStrip = /^#*/; - - namedParam = /:([\w\d]+)/g; - - splatParam = /\*([\w\d]+)/g; - - escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g; - - Spine.Route = (function(_super) { - var _ref; - - __extends(Route, _super); - - Route.extend(Spine.Events); - - Route.historySupport = ((_ref = window.history) != null ? _ref.pushState : void 0) != null; - - Route.routes = []; - - Route.options = { - trigger: true, - history: false, - shim: false, - replace: false, - redirect: false - }; - - Route.add = function(path, callback) { - var key, value, _results; - if (typeof path === 'object' && !(path instanceof RegExp)) { - _results = []; - for (key in path) { - value = path[key]; - _results.push(this.add(key, value)); - } - return _results; - } else { - return this.routes.push(new this(path, callback)); - } - }; - - Route.setup = function(options) { - if (options == null) { - options = {}; - } - this.options = $.extend({}, this.options, options); - if (this.options.history) { - this.history = this.historySupport && this.options.history; - } - if (this.options.shim) { - return; - } - if (this.history) { - $(window).bind('popstate', this.change); - } else { - $(window).bind('hashchange', this.change); - } - return this.change(); - }; - - Route.unbind = function() { - if (this.options.shim) { - return; - } - if (this.history) { - return $(window).unbind('popstate', this.change); - } else { - return $(window).unbind('hashchange', this.change); - } - }; - - Route.navigate = function() { - var args, lastArg, options, path, route; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - options = {}; - lastArg = args[args.length - 1]; - if (typeof lastArg === 'object') { - options = args.pop(); - } else if (typeof lastArg === 'boolean') { - options.trigger = args.pop(); - } - options = $.extend({}, this.options, options); - path = args.join('/'); - if (this.path === path) { - return; - } - this.path = path; - this.trigger('navigate', this.path); - if (options.trigger) { - route = this.matchRoute(this.path, options); - } - if (options.shim) { - return; - } - if (!route) { - if (typeof options.redirect === 'function') { - return options.redirect.apply(this, [this.path, options]); - } else { - if (options.redirect === true) { - this.redirect(this.path); - } - } - } - if (this.history && options.replace) { - return history.replaceState({}, document.title, this.path); - } else if (this.history) { - return history.pushState({}, document.title, this.path); - } else { - return window.location.hash = this.path; - } - }; - - Route.getPath = function() { - var path; - if (this.history) { - path = window.location.pathname; - if (path.substr(0, 1) !== '/') { - path = '/' + path; - } - } else { - path = window.location.hash; - path = path.replace(hashStrip, ''); - } - return path; - }; - - Route.getHost = function() { - return "" + window.location.protocol + "//" + window.location.host; - }; - - Route.change = function() { - var path; - path = this.getPath(); - if (path === this.path) { - return; - } - this.path = path; - return this.matchRoute(this.path); - }; - - Route.matchRoute = function(path, options) { - var route, _i, _len, _ref1; - _ref1 = this.routes; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - route = _ref1[_i]; - if (!(route.match(path, options))) { - continue; - } - this.trigger('change', route, path); - return route; - } - }; - - Route.redirect = function(path) { - return window.location = path; - }; - - function Route(path, callback) { - var match; - this.path = path; - this.callback = callback; - this.names = []; - if (typeof path === 'string') { - namedParam.lastIndex = 0; - while ((match = namedParam.exec(path)) !== null) { - this.names.push(match[1]); - } - splatParam.lastIndex = 0; - while ((match = splatParam.exec(path)) !== null) { - this.names.push(match[1]); - } - path = path.replace(escapeRegExp, '\\$&').replace(namedParam, '([^\/]*)').replace(splatParam, '(.*?)'); - this.route = new RegExp("^" + path + "$"); - } else { - this.route = path; - } - } - - Route.prototype.match = function(path, options) { - var i, match, param, params, _i, _len; - if (options == null) { - options = {}; - } - match = this.route.exec(path); - if (!match) { - return false; - } - options.match = match; - params = match.slice(1); - if (this.names.length) { - for (i = _i = 0, _len = params.length; _i < _len; i = ++_i) { - param = params[i]; - options[this.names[i]] = param; - } - } - return this.callback.call(null, options) !== false; - }; - - return Route; - - })(Spine.Module); - - Spine.Route.change = Spine.Route.proxy(Spine.Route.change); - - Spine.Controller.include({ - route: function(path, callback) { - return Spine.Route.add(path, this.proxy(callback)); - }, - routes: function(routes) { - var key, value, _results; - _results = []; - for (key in routes) { - value = routes[key]; - _results.push(this.route(key, value)); - } - return _results; - }, - navigate: function() { - return Spine.Route.navigate.apply(Spine.Route, arguments); - } - }); - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine.Route; - } - -}).call(this); - -/* -//@ sourceMappingURL=route.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/route.map b/app/assets/javascripts/app/lib/spine/route.map deleted file mode 100755 index 27453dd8e..000000000 --- a/app/assets/javascripts/app/lib/spine/route.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "route.js", - "sourceRoot": "..", - "sources": [ - "src/route.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,mDAAA;KAAA;;uBAAA;;CAAA,CAAA,CAAQ,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AO,EAAA;CARP,EAYa,CAAZ,CAAD,CAAa,EAAb;MAbF,EAAA;CAeE,EAAS,CAAR,CAAD,GAAA;QAlBS;CAxGb,IAwGa;;CAxGb,CA4Hc,CAAP,CAAA,CAAP,EAAO,EAAC;CACN,SAAA,uBAAA;;GADsB,KAAV;QACZ;CAAA,EAAQ,CAAC,CAAT,CAAA;AACoB,CAApB,GAAA,CAAA,CAAA;CAAA,IAAA,UAAO;QADP;CAAA,EAEgB,EAAhB,CAAA,CAAO;CAFP,EAGS,EAAK,CAAd;CAEA,GAAG,CAAM,CAAT;AACE,CAAA,YAAA,wCAAA;6BAAA;CACE,EAAqB,CAAZ,CAAM,EAAP,GAAR;CADF,QADF;QALA;CASC,CAAoB,EAApB,CAAkC,EAAnC,CAAS,KAAT;CAtIF,IA4HO;;CA5HP;;CADwB,IAAK;;CAR/B,CAkJA,CAAqB,EAAhB,CAAL;;CAlJA,CAoJA,GAAK,EAAL,GAAgB;CACd,CAAO,CAAA,CAAP,CAAA,GAAO,CAAC;CACA,CAAgB,CAAtB,CAAA,CAAK,GAAiB,KAAtB;CADF,IAAO;CAAP,CAGQ,CAAA,CAAR,EAAA,GAAS;CACP,SAAA,UAAA;AAAA,CAAA;YAAA,CAAA;6BAAA;CAAA,CAAY,CAAZ,CAAC,CAAD;CAAA;uBADM;CAHR,IAGQ;CAHR,CAMU,CAAA,CAAV,IAAA,CAAU;CACF,CAAkC,GAAnC,GAAe,CAApB,IAAA;CAPF,IAMU;CA3JZ,GAoJA;;;CAUQ,EAAU,CAAlB,CAAuB,CAAjB,CAAN;IA9JA;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/spine.coffee b/app/assets/javascripts/app/lib/spine/spine.coffee new file mode 100755 index 000000000..7c898f181 --- /dev/null +++ b/app/assets/javascripts/app/lib/spine/spine.coffee @@ -0,0 +1,659 @@ +### +Spine.js MVC library +Released under the MIT License +### + +Events = + bind: (ev, callback) -> + evs = ev.split(' ') + @_callbacks = {} unless @hasOwnProperty('_callbacks') and @_callbacks + for name in evs + @_callbacks[name] or= [] + @_callbacks[name].push(callback) + this + + one: (ev, callback) -> + @bind ev, handler = -> + @unbind(ev, handler) + callback.apply(this, arguments) + + trigger: (args...) -> + ev = args.shift() + list = @hasOwnProperty('_callbacks') and @_callbacks?[ev] + return unless list + for callback in list + if callback.apply(this, args) is false + break + true + + listenTo: (obj, ev, callback) -> + obj.bind(ev, callback) + @listeningTo or= [] + @listeningTo.push {obj, ev, callback} + this + + listenToOnce: (obj, ev, callback) -> + listeningToOnce = @listeningToOnce or= [] + obj.bind ev, handler = -> + idx = -1 + for lt, i in listeningToOnce when lt.obj is obj + idx = i if lt.ev is ev and lt.callback is callback + obj.unbind(ev, handler) + listeningToOnce.splice(idx, 1) unless idx is -1 + callback.apply(this, arguments) + listeningToOnce.push {obj, ev, callback, handler} + this + + stopListening: (obj, events, callback) -> + if arguments.length is 0 + for listeningTo in [@listeningTo, @listeningToOnce] + continue unless listeningTo + for lt in listeningTo + lt.obj.unbind(lt.ev, lt.handler or lt.callback) + @listeningTo = undefined + @listeningToOnce = undefined + + else if obj + for listeningTo in [@listeningTo, @listeningToOnce] + continue unless listeningTo + events = if events then events.split(' ') else [undefined] + for ev in events + for idx in [listeningTo.length-1..0] + lt = listeningTo[idx] + continue if callback and (lt.handler or lt.callback) isnt callback + if (not ev) or (ev is lt.ev) + lt.obj.unbind(lt.ev, lt.handler or lt.callback) + listeningTo.splice(idx, 1) unless idx is -1 + else if ev + evts = lt.ev.split(' ') + if ev in evts + evts = (e for e in evts when e isnt ev) + lt.ev = $.trim(evts.join(' ')) + lt.obj.unbind(ev, lt.handler or lt.callback) + + unbind: (ev, callback) -> + if arguments.length is 0 + @_callbacks = {} + return this + return this unless ev + evs = ev.split(' ') + for name in evs + list = @_callbacks?[name] + continue unless list + unless callback + delete @_callbacks[name] + continue + for cb, i in list when (cb is callback) + list = list.slice() + list.splice(i, 1) + @_callbacks[name] = list + break + this + +Events.on = Events.bind +Events.off = Events.unbind + +Log = + trace: true + + logPrefix: '(App)' + + log: (args...) -> + return unless @trace + if @logPrefix then args.unshift(@logPrefix) + console?.log?(args...) + this + +moduleKeywords = ['included', 'extended'] + +class Module + @include: (obj) -> + throw new Error('include(obj) requires obj') unless obj + for key, value of obj when key not in moduleKeywords + @::[key] = value + obj.included?.apply(this) + this + + @extend: (obj) -> + throw new Error('extend(obj) requires obj') unless obj + for key, value of obj when key not in moduleKeywords + @[key] = value + obj.extended?.apply(this) + this + + @proxy: (func) -> + => func.apply(this, arguments) + + proxy: (func) -> + => func.apply(this, arguments) + + constructor: -> + @init?(arguments...) + +class Model extends Module + @extend Events + + @records : [] + @irecords : {} + @attributes : [] + + @configure: (name, attributes...) -> + @className = name + @deleteAll() + @attributes = attributes if attributes.length + @attributes and= makeArray(@attributes) + @attributes or= [] + @unbind() + this + + @toString: -> "#{@className}(#{@attributes.join(", ")})" + + @find: (id, notFound = @notFound) -> + record = @irecords[id]?.clone() + return record or notFound?(id) + + @notFound: (id) -> return null + + @exists: (id) -> + return if @irecords[id] then true else false + + @addRecord: (record) -> + if record.id and @irecords[record.id] + @irecords[record.id].remove() + + record.id or= record.cid + @records.push(record) + @irecords[record.id] = record + @irecords[record.cid] = record + + @refresh: (values, options = {}) -> + @deleteAll() if options.clear + + records = @fromJSON(values) + records = [records] unless isArray(records) + @addRecord(record) for record in records + @sort() + + result = @cloneArray(records) + @trigger('refresh', result, options) + result + + @select: (callback) -> + (record.clone() for record in @records when callback(record)) + + @findByAttribute: (name, value) -> + for record in @records + if record[name] is value + return record.clone() + null + + @findAllByAttribute: (name, value) -> + @select (item) -> + item[name] is value + + @each: (callback) -> + callback(record.clone()) for record in @records + + @all: -> + @cloneArray(@records) + + @slice: (begin = 0, end)-> + @cloneArray(@records.slice(begin, end)) + + @first: (end = 1)-> + if end > 1 + @cloneArray(@records.slice(0, end)) + else + @records[0]?.clone() + + @last: (begin)-> + if typeof begin is 'number' + @cloneArray(@records.slice(-begin)) + else + @records[@records.length - 1]?.clone() + + @count: -> + @records.length + + @deleteAll: -> + @records = [] + @irecords = {} + + @destroyAll: (options) -> + record.destroy(options) for record in @records + + @update: (id, atts, options) -> + @find(id).updateAttributes(atts, options) + + @create: (atts, options) -> + record = new @(atts) + record.save(options) + + @destroy: (id, options) -> + @find(id).destroy(options) + + @change: (callbackOrParams) -> + if typeof callbackOrParams is 'function' + @bind('change', callbackOrParams) + else + @trigger('change', arguments...) + + @fetch: (callbackOrParams) -> + if typeof callbackOrParams is 'function' + @bind('fetch', callbackOrParams) + else + @trigger('fetch', arguments...) + + @toJSON: -> + @records + + @fromJSON: (objects) -> + return unless objects + if typeof objects is 'string' + objects = JSON.parse(objects) + if isArray(objects) + (new @(value) for value in objects) + else + new @(objects) + + @fromForm: -> + (new this).fromForm(arguments...) + + @sort: -> + if @comparator + @records.sort @comparator + this + + # Private + + @cloneArray: (array) -> + (value.clone() for value in array) + + @idCounter: 0 + + @uid: (prefix = '') -> + uid = prefix + @idCounter++ + uid = @uid(prefix) if @exists(uid) + uid + + # Instance + + constructor: (atts) -> + super + if @constructor.uuid? and typeof @constructor.uuid is 'function' + @cid = @constructor.uuid() + @id = @cid unless @id + else + @cid = atts?.cid or @constructor.uid('c-') + @load atts if atts + + isNew: -> + not @exists() + + isValid: -> + not @validate() + + validate: -> + + load: (atts) -> + if atts.id then @id = atts.id + for key, value of atts + if atts.hasOwnProperty(key) and typeof @[key] is 'function' + @[key](value) + else + @[key] = value + this + + attributes: -> + result = {} + for key in @constructor.attributes when key of this + if typeof @[key] is 'function' + result[key] = @[key]() + else + result[key] = @[key] + result.id = @id if @id + result + + eql: (rec) -> + !!(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 + error = @validate() + if error + @trigger('error', error) + return false + + @trigger('beforeSave', options) + record = if @isNew() then @create(options) else @update(options) + @stripCloneAttrs() + @trigger('save', options) + record + + stripCloneAttrs: -> + return if @hasOwnProperty 'cid' # Make sure it's not the raw object + for own key, value of this + delete @[key] if key in @constructor.attributes + this + + updateAttribute: (name, value, options) -> + atts = {} + atts[name] = value + @updateAttributes(atts, options) + + updateAttributes: (atts, options) -> + @load(atts) + @save(options) + + changeID: (id) -> + return if id is @id + records = @constructor.irecords + records[id] = records[@id] + delete records[@id] unless @cid is @id + @id = id + @save() + + remove: -> + # Remove record from model + records = @constructor.records.slice(0) + for record, i in records when @eql(record) + records.splice(i, 1) + break + @constructor.records = records + # Remove the ID and CID + delete @constructor.irecords[@id] + delete @constructor.irecords[@cid] + + destroy: (options = {}) -> + @trigger('beforeDestroy', options) + @remove() + @destroyed = true + # handle events + @trigger('destroy', options) + @trigger('change', 'destroy', options) + if @listeningTo + @stopListening() + @unbind() + this + + dup: (newRecord = true) -> + atts = @attributes() + if newRecord + delete atts.id + else + atts.cid = @cid + new @constructor(atts) + + clone: -> + createObject(this) + + reload: -> + return this if @isNew() + original = @constructor.find(@id) + @load(original.attributes()) + original + + refresh: (data) -> + # go to the source and load attributes + root = @constructor.irecords[@id] + root.load(data) + @trigger('refresh') + @ + + toJSON: -> + @attributes() + + toString: -> + "<#{@constructor.className} (#{JSON.stringify(this)})>" + + fromForm: (form) -> + result = {} + + for checkbox in $(form).find('[type=checkbox]:not([value])') + result[checkbox.name] = $(checkbox).prop('checked') + + for checkbox in $(form).find('[type=checkbox][name$="[]"]') + name = checkbox.name.replace(/\[\]$/, '') + result[name] or= [] + result[name].push checkbox.value if $(checkbox).prop('checked') + + for key in $(form).serializeArray() + result[key.name] or= key.value + + @load(result) + + exists: -> + @constructor.exists(@id) + + # Private + + update: (options) -> + @trigger('beforeUpdate', options) + + records = @constructor.irecords + records[@id].load @attributes() + + @constructor.sort() + + clone = records[@id].clone() + clone.trigger('update', options) + clone.trigger('change', 'update', options) + clone + + create: (options) -> + @trigger('beforeCreate', options) + @id or= @cid + + record = @dup(false) + @constructor.addRecord(record) + @constructor.sort() + + clone = record.clone() + clone.trigger('create', options) + clone.trigger('change', 'create', options) + clone + + bind: (events, callback) -> + @constructor.bind events, binder = (record) => + if record && @eql(record) + callback.apply(this, arguments) + # create a wrapper function to be called with 'unbind' for each event + for singleEvent in events.split(' ') + do (singleEvent) => + @constructor.bind "unbind", unbinder = (record, event, cb) => + if record && @eql(record) + return if event and event isnt singleEvent + return if cb and cb isnt callback + @constructor.unbind(singleEvent, binder) + @constructor.unbind("unbind", unbinder) + this + + one: (events, callback) -> + @bind events, handler = => + @unbind(events, handler) + callback.apply(this, arguments) + + trigger: (args...) -> + args.splice(1, 0, this) + @constructor.trigger(args...) + + listenTo: -> Events.listenTo.apply @, arguments + listenToOnce: -> Events.listenToOnce.apply @, arguments + stopListening: -> Events.stopListening.apply @, arguments + + unbind: (events, callback) -> + if arguments.length is 0 + @trigger('unbind') + else if events + for event in events.split(' ') + @trigger('unbind', event, callback) + +Model::on = Model::bind +Model::off = Model::unbind + +class Controller extends Module + @include Events + @include Log + + eventSplitter: /^(\S+)\s*(.*)$/ + tag: 'div' + + constructor: (options) -> + @options = options + + for key, value of @options + @[key] = value + + @el = document.createElement(@tag) unless @el + @el = $(@el) + @$el = @el + + @el.addClass(@className) if @className + @el.attr(@attributes) if @attributes + + @events = @constructor.events unless @events + @elements = @constructor.elements unless @elements + + context = @ + while parent_prototype = context.constructor.__super__ + @events = $.extend({}, parent_prototype.events, @events) if parent_prototype.events + @elements = $.extend({}, parent_prototype.elements, @elements) if parent_prototype.elements + context = parent_prototype + + @delegateEvents(@events) if @events + @refreshElements() if @elements + + super + + release: => + @trigger 'release', this + # no need to unDelegateEvents since remove will end up handling that + @el.remove() + @unbind() + @stopListening() + + $: (selector) -> $(selector, @el) + + delegateEvents: (events) -> + for key, method of events + + if typeof(method) is 'function' + # Always return true from event handlers + method = do (method) => => + method.apply(this, arguments) + true + else + unless @[method] + throw new Error("#{method} doesn't exist") + + method = do (method) => => + @[method].apply(this, arguments) + true + + match = key.match(@eventSplitter) + eventName = match[1] + selector = match[2] + + if selector is '' + @el.bind(eventName, method) + else + @el.on(eventName, selector, method) + + refreshElements: -> + for key, value of @elements + @[value] = @$(key) + + delay: (func, timeout) -> + setTimeout(@proxy(func), timeout || 0) + + # keep controllers elements obj in sync with it contents + + html: (element) -> + @el.html(element.el or element) + @refreshElements() + @el + + append: (elements...) -> + elements = (e.el or e for e in elements) + @el.append(elements...) + @refreshElements() + @el + + appendTo: (element) -> + @el.appendTo(element.el or element) + @refreshElements() + @el + + prepend: (elements...) -> + elements = (e.el or e for e in elements) + @el.prepend(elements...) + @refreshElements() + @el + + replace: (element) -> + element = element.el or element + element = $.trim(element) if typeof element is "string" + # parseHTML is incompatible with Zepto + [previous, @el] = [@el, $($.parseHTML(element)?[0] or element)] + previous.replaceWith(@el) + @delegateEvents(@events) + @refreshElements() + @el + +# Utilities & Shims + +$ = window?.jQuery or window?.Zepto or (element) -> element + +createObject = Object.create or (o) -> + Func = -> + Func.prototype = o + new Func() + +isArray = (value) -> + Object::toString.call(value) is '[object Array]' + +isBlank = (value) -> + return true unless value + return false for key of value + true + +makeArray = (args) -> + Array::slice.call(args, 0) + +# Globals + +Spine = @Spine = {} +module?.exports = Spine + +Spine.version = '1.3.0' +Spine.isArray = isArray +Spine.isBlank = isBlank +Spine.$ = $ +Spine.Events = Events +Spine.Log = Log +Spine.Module = Module +Spine.Controller = Controller +Spine.Model = Model + +# Global events + +Module.extend.call(Spine, Events) + +# JavaScript compatability + +Module.create = Module.sub = + Controller.create = Controller.sub = + Model.sub = (instances, statics) -> + class Result extends this + Result.include(instances) if instances + Result.extend(statics) if statics + Result.unbind?() + Result + +Model.setup = (name, attributes = []) -> + class Instance extends this + Instance.configure(name, attributes...) + Instance + +Spine.Class = Module diff --git a/app/assets/javascripts/app/lib/spine/spine.js b/app/assets/javascripts/app/lib/spine/spine.js deleted file mode 100755 index 2bc6a54ed..000000000 --- a/app/assets/javascripts/app/lib/spine/spine.js +++ /dev/null @@ -1,1151 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -/* -Spine.js MVC library -Released under the MIT License -*/ - - -(function() { - var $, Controller, Events, Log, Model, Module, Spine, createObject, isArray, isBlank, makeArray, moduleKeywords, - __slice = [].slice, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - Events = { - bind: function(ev, callback) { - var calls, evs, name, _i, _len; - evs = ev.split(' '); - calls = this.hasOwnProperty('_callbacks') && this._callbacks || (this._callbacks = {}); - for (_i = 0, _len = evs.length; _i < _len; _i++) { - name = evs[_i]; - calls[name] || (calls[name] = []); - calls[name].push(callback); - } - return this; - }, - one: function(ev, callback) { - var handler; - return this.bind(ev, handler = function() { - this.unbind(ev, handler); - return callback.apply(this, arguments); - }); - }, - trigger: function() { - var args, callback, ev, list, _i, _len, _ref; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - ev = args.shift(); - list = this.hasOwnProperty('_callbacks') && ((_ref = this._callbacks) != null ? _ref[ev] : void 0); - if (!list) { - return; - } - for (_i = 0, _len = list.length; _i < _len; _i++) { - callback = list[_i]; - if (callback.apply(this, args) === false) { - break; - } - } - return true; - }, - listenTo: function(obj, ev, callback) { - obj.bind(ev, callback); - this.listeningTo || (this.listeningTo = []); - this.listeningTo.push({ - obj: obj, - ev: ev, - callback: callback - }); - return this; - }, - listenToOnce: function(obj, ev, callback) { - var handler, listeningToOnce; - listeningToOnce = this.listeningToOnce || (this.listeningToOnce = []); - obj.bind(ev, handler = function() { - var i, idx, lt, _i, _len; - idx = -1; - for (i = _i = 0, _len = listeningToOnce.length; _i < _len; i = ++_i) { - lt = listeningToOnce[i]; - if (lt.obj === obj) { - if (lt.ev === ev && lt.callback === callback) { - idx = i; - } - } - } - obj.unbind(ev, handler); - if (idx !== -1) { - listeningToOnce.splice(idx, 1); - } - return callback.apply(this, arguments); - }); - listeningToOnce.push({ - obj: obj, - ev: ev, - callback: callback, - handler: handler - }); - return this; - }, - stopListening: function(obj, events, callback) { - var ev, evts, i, idx, listeningTo, lt, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _results; - if (arguments.length === 0) { - _ref = [this.listeningTo, this.listeningToOnce]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - listeningTo = _ref[_i]; - if (!listeningTo) { - continue; - } - for (_j = 0, _len1 = listeningTo.length; _j < _len1; _j++) { - lt = listeningTo[_j]; - lt.obj.unbind(lt.ev, lt.handler || lt.callback); - } - } - this.listeningTo = void 0; - return this.listeningToOnce = void 0; - } else if (obj) { - _ref1 = [this.listeningTo, this.listeningToOnce]; - _results = []; - for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { - listeningTo = _ref1[_k]; - if (!listeningTo) { - continue; - } - events = events ? events.split(' ') : [void 0]; - _results.push((function() { - var _l, _len3, _results1; - _results1 = []; - for (_l = 0, _len3 = events.length; _l < _len3; _l++) { - ev = events[_l]; - _results1.push((function() { - var _m, _ref2, _results2; - _results2 = []; - for (idx = _m = _ref2 = listeningTo.length - 1; _ref2 <= 0 ? _m <= 0 : _m >= 0; idx = _ref2 <= 0 ? ++_m : --_m) { - lt = listeningTo[idx]; - if ((!ev) || (ev === lt.ev)) { - lt.obj.unbind(lt.ev, lt.handler || lt.callback); - if (idx !== -1) { - _results2.push(listeningTo.splice(idx, 1)); - } else { - _results2.push(void 0); - } - } else if (ev) { - evts = lt.ev.split(' '); - if (~(i = evts.indexOf(ev))) { - evts.splice(i, 1); - lt.ev = $.trim(evts.join(' ')); - _results2.push(lt.obj.unbind(ev, lt.handler || lt.callback)); - } else { - _results2.push(void 0); - } - } else { - _results2.push(void 0); - } - } - return _results2; - })()); - } - return _results1; - })()); - } - return _results; - } - }, - unbind: function(ev, callback) { - var cb, evs, i, list, name, _i, _j, _len, _len1, _ref; - if (arguments.length === 0) { - this._callbacks = {}; - return this; - } - if (!ev) { - return this; - } - evs = ev.split(' '); - for (_i = 0, _len = evs.length; _i < _len; _i++) { - name = evs[_i]; - list = (_ref = this._callbacks) != null ? _ref[name] : void 0; - if (!list) { - continue; - } - if (!callback) { - delete this._callbacks[name]; - continue; - } - for (i = _j = 0, _len1 = list.length; _j < _len1; i = ++_j) { - cb = list[i]; - if (!(cb === callback)) { - continue; - } - list = list.slice(); - list.splice(i, 1); - this._callbacks[name] = list; - break; - } - } - return this; - } - }; - - Events.on = Events.bind; - - Events.off = Events.unbind; - - Log = { - trace: true, - logPrefix: '(App)', - log: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - if (!this.trace) { - return; - } - if (this.logPrefix) { - args.unshift(this.logPrefix); - } - if (typeof console !== "undefined" && console !== null) { - if (typeof console.log === "function") { - console.log.apply(console, args); - } - } - return this; - } - }; - - moduleKeywords = ['included', 'extended']; - - Module = (function() { - Module.include = function(obj) { - var key, value, _ref; - if (!obj) { - throw new Error('include(obj) requires obj'); - } - for (key in obj) { - value = obj[key]; - if (__indexOf.call(moduleKeywords, key) < 0) { - this.prototype[key] = value; - } - } - if ((_ref = obj.included) != null) { - _ref.apply(this); - } - return this; - }; - - Module.extend = function(obj) { - var key, value, _ref; - if (!obj) { - throw new Error('extend(obj) requires obj'); - } - for (key in obj) { - value = obj[key]; - if (__indexOf.call(moduleKeywords, key) < 0) { - this[key] = value; - } - } - if ((_ref = obj.extended) != null) { - _ref.apply(this); - } - return this; - }; - - Module.proxy = function(func) { - var _this = this; - return function() { - return func.apply(_this, arguments); - }; - }; - - Module.prototype.proxy = function(func) { - var _this = this; - return function() { - return func.apply(_this, arguments); - }; - }; - - function Module() { - if (typeof this.init === "function") { - this.init.apply(this, arguments); - } - } - - return Module; - - })(); - - Model = (function(_super) { - __extends(Model, _super); - - Model.extend(Events); - - Model.records = []; - - Model.irecords = {}; - - Model.attributes = []; - - Model.configure = function() { - var attributes, name; - name = arguments[0], attributes = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - this.className = name; - this.deleteAll(); - if (attributes.length) { - this.attributes = attributes; - } - this.attributes && (this.attributes = makeArray(this.attributes)); - this.attributes || (this.attributes = []); - this.unbind(); - return this; - }; - - Model.toString = function() { - return "" + this.className + "(" + (this.attributes.join(", ")) + ")"; - }; - - Model.find = function(id) { - var record; - record = this.exists(id); - if (!record) { - throw new Error("\"" + this.className + "\" model could not find a record for the ID \"" + id + "\""); - } - return record; - }; - - Model.exists = function(id) { - var _ref; - return (_ref = this.irecords[id]) != null ? _ref.clone() : void 0; - }; - - Model.addRecord = function(record) { - if (record.id && this.irecords[record.id]) { - this.irecords[record.id].remove(); - } - record.id || (record.id = record.cid); - this.records.push(record); - this.irecords[record.id] = record; - return this.irecords[record.cid] = record; - }; - - Model.refresh = function(values, options) { - var record, records, result, _i, _len; - if (options == null) { - options = {}; - } - if (options.clear) { - this.deleteAll(); - } - records = this.fromJSON(values); - if (!isArray(records)) { - records = [records]; - } - for (_i = 0, _len = records.length; _i < _len; _i++) { - record = records[_i]; - this.addRecord(record); - } - this.sort(); - result = this.cloneArray(records); - this.trigger('refresh', result, options); - return result; - }; - - Model.select = function(callback) { - var record, _i, _len, _ref, _results; - _ref = this.records; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - record = _ref[_i]; - if (callback(record)) { - _results.push(record.clone()); - } - } - return _results; - }; - - Model.findByAttribute = function(name, value) { - var record, _i, _len, _ref; - _ref = this.records; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - record = _ref[_i]; - if (record[name] === value) { - return record.clone(); - } - } - return null; - }; - - Model.findAllByAttribute = function(name, value) { - return this.select(function(item) { - return item[name] === value; - }); - }; - - Model.each = function(callback) { - var record, _i, _len, _ref, _results; - _ref = this.records; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - record = _ref[_i]; - _results.push(callback(record.clone())); - } - return _results; - }; - - Model.all = function() { - return this.cloneArray(this.records); - }; - - Model.slice = function(begin, end) { - if (begin == null) { - begin = 0; - } - return this.cloneArray(this.records.slice(begin, end)); - }; - - Model.first = function(end) { - var _ref; - if (end == null) { - end = 1; - } - if (end > 1) { - return this.cloneArray(this.records.slice(0, end)); - } else { - return (_ref = this.records[0]) != null ? _ref.clone() : void 0; - } - }; - - Model.last = function(begin) { - var _ref; - if (typeof begin === 'number') { - return this.cloneArray(this.records.slice(-begin)); - } else { - return (_ref = this.records[this.records.length - 1]) != null ? _ref.clone() : void 0; - } - }; - - Model.count = function() { - return this.records.length; - }; - - Model.deleteAll = function() { - this.records = []; - return this.irecords = {}; - }; - - Model.destroyAll = function(options) { - var record, _i, _len, _ref, _results; - _ref = this.records; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - record = _ref[_i]; - _results.push(record.destroy(options)); - } - return _results; - }; - - Model.update = function(id, atts, options) { - return this.find(id).updateAttributes(atts, options); - }; - - Model.create = function(atts, options) { - var record; - record = new this(atts); - return record.save(options); - }; - - Model.destroy = function(id, options) { - return this.find(id).destroy(options); - }; - - Model.change = function(callbackOrParams) { - if (typeof callbackOrParams === 'function') { - return this.bind('change', callbackOrParams); - } else { - return this.trigger.apply(this, ['change'].concat(__slice.call(arguments))); - } - }; - - Model.fetch = function(callbackOrParams) { - if (typeof callbackOrParams === 'function') { - return this.bind('fetch', callbackOrParams); - } else { - return this.trigger.apply(this, ['fetch'].concat(__slice.call(arguments))); - } - }; - - Model.toJSON = function() { - return this.records; - }; - - Model.fromJSON = function(objects) { - var value, _i, _len, _results; - if (!objects) { - return; - } - if (typeof objects === 'string') { - objects = JSON.parse(objects); - } - if (isArray(objects)) { - _results = []; - for (_i = 0, _len = objects.length; _i < _len; _i++) { - value = objects[_i]; - _results.push(new this(value)); - } - return _results; - } else { - return new this(objects); - } - }; - - Model.fromForm = function() { - var _ref; - return (_ref = new this).fromForm.apply(_ref, arguments); - }; - - Model.sort = function() { - if (this.comparator) { - this.records.sort(this.comparator); - } - return this; - }; - - Model.cloneArray = function(array) { - var value, _i, _len, _results; - _results = []; - for (_i = 0, _len = array.length; _i < _len; _i++) { - value = array[_i]; - _results.push(value.clone()); - } - return _results; - }; - - Model.idCounter = 0; - - Model.uid = function(prefix) { - var uid; - if (prefix == null) { - prefix = ''; - } - uid = prefix + this.idCounter++; - if (this.exists(uid)) { - uid = this.uid(prefix); - } - return uid; - }; - - function Model(atts) { - Model.__super__.constructor.apply(this, arguments); - if (atts) { - this.load(atts); - } - this.cid = (atts != null ? atts.cid : void 0) || this.constructor.uid('c-'); - } - - Model.prototype.isNew = function() { - return !this.exists(); - }; - - Model.prototype.isValid = function() { - return !this.validate(); - }; - - Model.prototype.validate = function() {}; - - Model.prototype.load = function(atts) { - var key, value; - if (atts.id) { - this.id = atts.id; - } - for (key in atts) { - value = atts[key]; - if (atts.hasOwnProperty(key) && typeof this[key] === 'function') { - this[key](value); - } else { - this[key] = value; - } - } - return this; - }; - - Model.prototype.attributes = function() { - var key, result, _i, _len, _ref; - result = {}; - _ref = this.constructor.attributes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - key = _ref[_i]; - if (key in this) { - if (typeof this[key] === 'function') { - result[key] = this[key](); - } else { - result[key] = this[key]; - } - } - } - if (this.id) { - result.id = this.id; - } - return result; - }; - - Model.prototype.eql = function(rec) { - return !!(rec && rec.constructor === this.constructor && ((rec.cid === this.cid) || (rec.id && rec.id === this.id))); - }; - - Model.prototype.save = function(options) { - var error, record; - if (options == null) { - options = {}; - } - if (options.validate !== false) { - error = this.validate(); - if (error) { - this.trigger('error', error); - return false; - } - } - this.trigger('beforeSave', options); - record = this.isNew() ? this.create(options) : this.update(options); - this.stripCloneAttrs(); - this.trigger('save', options); - return record; - }; - - Model.prototype.stripCloneAttrs = function() { - var key, value; - if (this.hasOwnProperty('cid')) { - return; - } - for (key in this) { - if (!__hasProp.call(this, key)) continue; - value = this[key]; - if (this.constructor.attributes.indexOf(key) > -1) { - delete this[key]; - } - } - return this; - }; - - Model.prototype.updateAttribute = function(name, value, options) { - var atts; - atts = {}; - atts[name] = value; - return this.updateAttributes(atts, options); - }; - - Model.prototype.updateAttributes = function(atts, options) { - this.load(atts); - return this.save(options); - }; - - Model.prototype.changeID = function(id) { - var records; - if (id === this.id) { - return; - } - records = this.constructor.irecords; - records[id] = records[this.id]; - if (this.cid !== this.id) { - delete records[this.id]; - } - this.id = id; - return this.save(); - }; - - Model.prototype.remove = function() { - var i, record, records, _i, _len; - records = this.constructor.records.slice(0); - for (i = _i = 0, _len = records.length; _i < _len; i = ++_i) { - record = records[i]; - if (!(this.eql(record))) { - continue; - } - records.splice(i, 1); - break; - } - this.constructor.records = records; - delete this.constructor.irecords[this.id]; - return delete this.constructor.irecords[this.cid]; - }; - - Model.prototype.destroy = function(options) { - if (options == null) { - options = {}; - } - this.trigger('beforeDestroy', options); - this.remove(); - this.destroyed = true; - this.trigger('destroy', options); - this.trigger('change', 'destroy', options); - if (this.listeningTo) { - this.stopListening(); - } - this.unbind(); - return this; - }; - - Model.prototype.dup = function(newRecord) { - var atts; - if (newRecord == null) { - newRecord = true; - } - atts = this.attributes(); - if (newRecord) { - delete atts.id; - } else { - atts.cid = this.cid; - } - return new this.constructor(atts); - }; - - Model.prototype.clone = function() { - return createObject(this); - }; - - Model.prototype.reload = function() { - var original; - if (this.isNew()) { - return this; - } - original = this.constructor.find(this.id); - this.load(original.attributes()); - return original; - }; - - Model.prototype.refresh = function(data) { - var root; - root = this.constructor.irecords[this.id]; - root.load(data); - this.trigger('refresh'); - return this; - }; - - Model.prototype.toJSON = function() { - return this.attributes(); - }; - - Model.prototype.toString = function() { - return "<" + this.constructor.className + " (" + (JSON.stringify(this)) + ")>"; - }; - - Model.prototype.fromForm = function(form) { - var checkbox, key, name, result, _i, _j, _k, _len, _len1, _len2, _name, _ref, _ref1, _ref2; - result = {}; - _ref = $(form).find('[type=checkbox]:not([value])'); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - checkbox = _ref[_i]; - result[checkbox.name] = $(checkbox).prop('checked'); - } - _ref1 = $(form).find('[type=checkbox][name$="[]"]'); - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - checkbox = _ref1[_j]; - name = checkbox.name.replace(/\[\]$/, ''); - result[name] || (result[name] = []); - if ($(checkbox).prop('checked')) { - result[name].push(checkbox.value); - } - } - _ref2 = $(form).serializeArray(); - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - key = _ref2[_k]; - result[_name = key.name] || (result[_name] = key.value); - } - return this.load(result); - }; - - Model.prototype.exists = function() { - return this.constructor.exists(this.id); - }; - - Model.prototype.update = function(options) { - var clone, records; - this.trigger('beforeUpdate', options); - records = this.constructor.irecords; - records[this.id].load(this.attributes()); - this.constructor.sort(); - clone = records[this.id].clone(); - clone.trigger('update', options); - clone.trigger('change', 'update', options); - return clone; - }; - - Model.prototype.create = function(options) { - var clone, record; - this.trigger('beforeCreate', options); - this.id || (this.id = this.cid); - record = this.dup(false); - this.constructor.addRecord(record); - this.constructor.sort(); - clone = record.clone(); - clone.trigger('create', options); - clone.trigger('change', 'create', options); - return clone; - }; - - Model.prototype.bind = function(events, callback) { - var binder, singleEvent, _fn, _i, _len, _ref, - _this = this; - this.constructor.bind(events, binder = function(record) { - if (record && _this.eql(record)) { - return callback.apply(_this, arguments); - } - }); - _ref = events.split(' '); - _fn = function(singleEvent) { - var unbinder; - return _this.constructor.bind("unbind", unbinder = function(record, event, cb) { - if (record && _this.eql(record)) { - if (event && event !== singleEvent) { - return; - } - if (cb && cb !== callback) { - return; - } - _this.constructor.unbind(singleEvent, binder); - return _this.constructor.unbind("unbind", unbinder); - } - }); - }; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - singleEvent = _ref[_i]; - _fn(singleEvent); - } - return this; - }; - - Model.prototype.one = function(events, callback) { - var handler, - _this = this; - return this.bind(events, handler = function() { - _this.unbind(events, handler); - return callback.apply(_this, arguments); - }); - }; - - Model.prototype.trigger = function() { - var args, _ref; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - args.splice(1, 0, this); - return (_ref = this.constructor).trigger.apply(_ref, args); - }; - - Model.prototype.listenTo = function() { - return Events.listenTo.apply(this, arguments); - }; - - Model.prototype.listenToOnce = function() { - return Events.listenToOnce.apply(this, arguments); - }; - - Model.prototype.stopListening = function() { - return Events.stopListening.apply(this, arguments); - }; - - Model.prototype.unbind = function(events, callback) { - var event, _i, _len, _ref, _results; - if (arguments.length === 0) { - return this.trigger('unbind'); - } else if (events) { - _ref = events.split(' '); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - event = _ref[_i]; - _results.push(this.trigger('unbind', event, callback)); - } - return _results; - } - }; - - return Model; - - })(Module); - - Model.prototype.on = Model.prototype.bind; - - Model.prototype.off = Model.prototype.unbind; - - Controller = (function(_super) { - __extends(Controller, _super); - - Controller.include(Events); - - Controller.include(Log); - - Controller.prototype.eventSplitter = /^(\S+)\s*(.*)$/; - - Controller.prototype.tag = 'div'; - - function Controller(options) { - this.release = __bind(this.release, this); - var context, key, parent_prototype, value, _ref; - this.options = options; - _ref = this.options; - for (key in _ref) { - value = _ref[key]; - this[key] = value; - } - if (!this.el) { - this.el = document.createElement(this.tag); - } - this.el = $(this.el); - this.$el = this.el; - if (this.className) { - this.el.addClass(this.className); - } - if (this.attributes) { - this.el.attr(this.attributes); - } - if (!this.events) { - this.events = this.constructor.events; - } - if (!this.elements) { - this.elements = this.constructor.elements; - } - context = this; - while (parent_prototype = context.constructor.__super__) { - if (parent_prototype.events) { - this.events = $.extend({}, parent_prototype.events, this.events); - } - if (parent_prototype.elements) { - this.elements = $.extend({}, parent_prototype.elements, this.elements); - } - context = parent_prototype; - } - if (this.events) { - this.delegateEvents(this.events); - } - if (this.elements) { - this.refreshElements(); - } - Controller.__super__.constructor.apply(this, arguments); - } - - Controller.prototype.release = function() { - this.trigger('release', this); - this.el.remove(); - this.unbind(); - return this.stopListening(); - }; - - Controller.prototype.$ = function(selector) { - return $(selector, this.el); - }; - - Controller.prototype.delegateEvents = function(events) { - var eventName, key, match, method, selector, _results, - _this = this; - _results = []; - for (key in events) { - method = events[key]; - if (typeof method === 'function') { - method = (function(method) { - return function() { - method.apply(_this, arguments); - return true; - }; - })(method); - } else { - if (!this[method]) { - throw new Error("" + method + " doesn't exist"); - } - method = (function(method) { - return function() { - _this[method].apply(_this, arguments); - return true; - }; - })(method); - } - match = key.match(this.eventSplitter); - eventName = match[1]; - selector = match[2]; - if (selector === '') { - _results.push(this.el.bind(eventName, method)); - } else { - _results.push(this.el.on(eventName, selector, method)); - } - } - return _results; - }; - - Controller.prototype.refreshElements = function() { - var key, value, _ref, _results; - _ref = this.elements; - _results = []; - for (key in _ref) { - value = _ref[key]; - _results.push(this[value] = this.$(key)); - } - return _results; - }; - - Controller.prototype.delay = function(func, timeout) { - return setTimeout(this.proxy(func), timeout || 0); - }; - - Controller.prototype.html = function(element) { - this.el.html(element.el || element); - this.refreshElements(); - return this.el; - }; - - Controller.prototype.append = function() { - var e, elements, _ref; - elements = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - elements = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = elements.length; _i < _len; _i++) { - e = elements[_i]; - _results.push(e.el || e); - } - return _results; - })(); - (_ref = this.el).append.apply(_ref, elements); - this.refreshElements(); - return this.el; - }; - - Controller.prototype.appendTo = function(element) { - this.el.appendTo(element.el || element); - this.refreshElements(); - return this.el; - }; - - Controller.prototype.prepend = function() { - var e, elements, _ref; - elements = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - elements = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = elements.length; _i < _len; _i++) { - e = elements[_i]; - _results.push(e.el || e); - } - return _results; - })(); - (_ref = this.el).prepend.apply(_ref, elements); - this.refreshElements(); - return this.el; - }; - - Controller.prototype.replace = function(element) { - var previous, _ref, _ref1; - element = element.el || element; - if (typeof element === "string") { - element = $.trim(element); - } - _ref1 = [this.el, $(((_ref = $.parseHTML(element)) != null ? _ref[0] : void 0) || element)], previous = _ref1[0], this.el = _ref1[1]; - previous.replaceWith(this.el); - this.delegateEvents(this.events); - this.refreshElements(); - return this.el; - }; - - return Controller; - - })(Module); - - $ = (typeof window !== "undefined" && window !== null ? window.jQuery : void 0) || (typeof window !== "undefined" && window !== null ? window.Zepto : void 0) || function(element) { - return element; - }; - - createObject = Object.create || function(o) { - var Func; - Func = function() {}; - Func.prototype = o; - return new Func(); - }; - - isArray = function(value) { - return Object.prototype.toString.call(value) === '[object Array]'; - }; - - isBlank = function(value) { - var key; - if (!value) { - return true; - } - for (key in value) { - return false; - } - return true; - }; - - makeArray = function(args) { - return Array.prototype.slice.call(args, 0); - }; - - Spine = this.Spine = {}; - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine; - } - - Spine.version = '1.2.2'; - - Spine.isArray = isArray; - - Spine.isBlank = isBlank; - - Spine.$ = $; - - Spine.Events = Events; - - Spine.Log = Log; - - Spine.Module = Module; - - Spine.Controller = Controller; - - Spine.Model = Model; - - Module.extend.call(Spine, Events); - - Module.create = Module.sub = Controller.create = Controller.sub = Model.sub = function(instances, statics) { - var Result, _ref; - Result = (function(_super) { - __extends(Result, _super); - - function Result() { - _ref = Result.__super__.constructor.apply(this, arguments); - return _ref; - } - - return Result; - - })(this); - if (instances) { - Result.include(instances); - } - if (statics) { - Result.extend(statics); - } - if (typeof Result.unbind === "function") { - Result.unbind(); - } - return Result; - }; - - Model.setup = function(name, attributes) { - var Instance, _ref; - if (attributes == null) { - attributes = []; - } - Instance = (function(_super) { - __extends(Instance, _super); - - function Instance() { - _ref = Instance.__super__.constructor.apply(this, arguments); - return _ref; - } - - return Instance; - - })(this); - Instance.configure.apply(Instance, [name].concat(__slice.call(attributes))); - return Instance; - }; - - Spine.Class = Module; - -}).call(this); - -/* -//@ sourceMappingURL=spine.map -*/ diff --git a/app/assets/javascripts/app/lib/spine/spine.map b/app/assets/javascripts/app/lib/spine/spine.map deleted file mode 100755 index b65cb7cb4..000000000 --- a/app/assets/javascripts/app/lib/spine/spine.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "spine.js", - "sourceRoot": "..", - "sources": [ - "src/spine.coffee" - ], - "names": [], - "mappings": ";AAAA;;;;CAAA;CAAA;CAAA;CAAA,KAAA,qGAAA;KAAA;;;;uFAAA;;CAAA,CAKA,CACE,GADF;CACE,CAAM,CAAA,CAAN,IAAM,CAAC;CACL,SAAA,gBAAA;CAAA,CAAU,CAAV,EAAQ,CAAR;CAAA,EACQ,CAAC,CAAT,CAAA,MAAQ,EAAA;AACR,CAAA,UAAA,+BAAA;wBAAA;CACE,EAAgB,CAAV,CAAA,GAAN;CAAA,GACM,CAAA,GAAN;CAFF,MAFA;CADI,YAMJ;CANF,IAAM;CAAN,CAQK,CAAL,CAAA,IAAK,CAAC;CACJ,MAAA,GAAA;CAAC,CAAD,CAAoB,CAAnB,GAAS,EAAU,IAApB;CACE,CAAA,EAAC,EAAD,CAAA,CAAA;CACS,CAAY,EAArB,CAAA,GAAQ,CAAR,MAAA;CAFF,MAAoB;CATtB,IAQK;CARL,CAaS,CAAA,CAAT,GAAA,EAAS;CACP,SAAA,8BAAA;CAAA,KADQ,iDACR;CAAA,CAAA,CAAK,CAAI,CAAJ,CAAL;CAAA,CACsD,CAA/C,CAAP,EAAA,MAAO,EAAA;AACO,CAAd,GAAA,EAAA;CAAA,aAAA;QAFA;AAGA,CAAA,UAAA,gCAAA;6BAAA;CACE,CAAwB,EAArB,CAAA,GAAH;CACE,eADF;UADF;CAAA,MAHA;CADO,YAOP;CApBF,IAaS;CAbT,CAsBU,CAAA,CAAV,IAAA,CAAW;CACT,CAAA,CAAG,CAAH,EAAA,EAAA;CAAA,EACiB,CAAhB,EAAD;CADA,GAEC,EAAD,KAAY;CAAM,CAAC,CAAD,KAAC;CAAD,CAAM,MAAA;CAAN,CAAU,MAAA;CAF5B,OAEA;CAHQ,YAIR;CA1BF,IAsBU;CAtBV,CA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;MAFA;;CAGO,KAAP;MAHA;CADU,UAKV;CAroBN,EAgoBgB;;CAhoBhB,CAuoBA,CAAc,CAAA,CAAT,IAAU,CAAD;CACZ,OAAA,MAAA;;GADgC,GAAb;MACnB;CAAA,GAAM;CAAN;;;;;CAAA;;CAAA;;CAAuB;CAAvB,GACA,IAAQ,CAAR,CAAyB,GAAA,IAAN;CAFP,UAGZ;CA1oBF,EAuoBc;;CAvoBd,CA4oBA,CAAc,EAAT,CA5oBL;CAAA" -} \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/spine/tabs.js b/app/assets/javascripts/app/lib/spine/tabs.js deleted file mode 100755 index 13179ba43..000000000 --- a/app/assets/javascripts/app/lib/spine/tabs.js +++ /dev/null @@ -1,66 +0,0 @@ -(function() { - var $, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = Object.prototype.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; - - if (typeof Spine === "undefined" || Spine === null) Spine = require('spine'); - - $ = Spine.$; - - Spine.Tabs = (function(_super) { - - __extends(Tabs, _super); - - Tabs.prototype.events = { - 'click [data-name]': 'click' - }; - - function Tabs() { - this.change = __bind(this.change, this); Tabs.__super__.constructor.apply(this, arguments); - this.bind('change', this.change); - } - - Tabs.prototype.change = function(name) { - if (!name) return; - this.current = name; - this.children().removeClass('active'); - return this.children("[data-name=" + this.current + "]").addClass('active'); - }; - - Tabs.prototype.render = function() { - this.change(this.current); - if (!(this.children('.active').length || this.current)) { - return this.children(':first').click(); - } - }; - - Tabs.prototype.children = function(sel) { - return this.el.children(sel); - }; - - Tabs.prototype.click = function(e) { - var name; - name = $(e.currentTarget).attr('data-name'); - return this.trigger('change', name); - }; - - Tabs.prototype.connect = function(tabName, controller) { - var _this = this; - this.bind('change', function(name) { - if (name === tabName) return controller.active(); - }); - return controller.bind('active', function() { - return _this.change(tabName); - }); - }; - - return Tabs; - - })(Spine.Controller); - - if (typeof module !== "undefined" && module !== null) { - module.exports = Spine.Tabs; - } - -}).call(this); diff --git a/app/assets/javascripts/app/lib/spine/tmpl.js b/app/assets/javascripts/app/lib/spine/tmpl.js deleted file mode 100755 index cd8253ac6..000000000 --- a/app/assets/javascripts/app/lib/spine/tmpl.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - var $; - - $ = typeof jQuery !== "undefined" && jQuery !== null ? jQuery : require("jqueryify"); - - $.fn.item = function() { - var item; - item = $(this); - item = item.data("item") || (typeof item.tmplItem === "function" ? item.tmplItem().data : void 0); - if (item != null) if (typeof item.reload === "function") item.reload(); - return item; - }; - - $.fn.forItem = function(item) { - return this.filter(function() { - var compare; - compare = $(this).item(); - return (typeof item.eql === "function" ? item.eql(compare) : void 0) || item === compare; - }); - }; - -}).call(this);