diff --git a/static/coffee/screenly-ose.coffee b/static/coffee/screenly-ose.coffee index 61bee5ea..e70a69d1 100644 --- a/static/coffee/screenly-ose.coffee +++ b/static/coffee/screenly-ose.coffee @@ -24,6 +24,8 @@ get_mimetype = (filename) => # Models +default_duration = 10 + # Tell Backbone to send its saves as JSON-encoded. Backbone.emulateJSON = on @@ -36,7 +38,7 @@ API.Asset = class Asset extends Backbone.Model uri: '' start_date: now() end_date: now() - duration: 10 + duration: default_duration API.Assets = class Assets extends Backbone.Collection url: "/api/assets" @@ -118,6 +120,7 @@ class EditAssetView extends Backbone.View (@$ 'input, select').prop 'disabled', on save.done (data) => + default_duration = @model.get 'duration' @collection.add @model if not @model.collection (@$el.children ":first").modal 'hide' _.extend @model.attributes, data @@ -164,6 +167,7 @@ class EditAssetView extends Backbone.View updateMimetype: (filename) => mt = get_mimetype filename @$fv 'mimetype', mt if mt + _.defer @change class AssetRowView extends Backbone.View diff --git a/static/js/screenly-ose.js b/static/js/screenly-ose.js index e8a871c8..73d20c7b 100644 --- a/static/js/screenly-ose.js +++ b/static/js/screenly-ose.js @@ -5,7 +5,7 @@ (function() { - var API, App, Asset, AssetRowView, Assets, AssetsView, EditAssetView, date_to, delay, get_mimetype, get_template, mimetypes, now, y2ts, years_from_now, + var API, App, Asset, AssetRowView, Assets, AssetsView, EditAssetView, date_to, default_duration, delay, get_mimetype, get_template, mimetypes, now, y2ts, years_from_now, _this = this, __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; }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -68,6 +68,8 @@ } }; + default_duration = 10; + Backbone.emulateJSON = true; API.Asset = Asset = (function(_super) { @@ -90,7 +92,7 @@ uri: '', start_date: now(), end_date: now(), - duration: 10 + duration: default_duration }; }; @@ -268,6 +270,7 @@ } (this.$('input, select')).prop('disabled', true); save.done(function(data) { + default_duration = _this.model.get('duration'); if (!_this.model.collection) { _this.collection.add(_this.model); } @@ -343,8 +346,9 @@ var mt; mt = get_mimetype(filename); if (mt) { - return this.$fv('mimetype', mt); + this.$fv('mimetype', mt); } + return _.defer(this.change); }; return EditAssetView;