summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/builder/BuilderSettings.js3
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js10
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js1
-rw-r--r--public/assets/javascripts/ui/lib/FormView.js28
-rw-r--r--public/assets/javascripts/ui/lib/View.js17
5 files changed, 43 insertions, 16 deletions
diff --git a/public/assets/javascripts/ui/builder/BuilderSettings.js b/public/assets/javascripts/ui/builder/BuilderSettings.js
index c551f95..0091454 100644
--- a/public/assets/javascripts/ui/builder/BuilderSettings.js
+++ b/public/assets/javascripts/ui/builder/BuilderSettings.js
@@ -122,6 +122,9 @@ var BuilderSettings = FormView.extend({
this.$name.val(data.name)
this.action = this.updateAction
+ Minotaur.unwatch(this)
+ Minotaur.hide()
+
window.history.pushState(null, document.title, "/layout/" + data.slug)
},
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index d6a79fb..9d75f66 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -5,7 +5,7 @@ var EditorSettings = FormView.extend({
createAction: "/api/project/new",
updateAction: "/api/project/edit",
destroyAction: "/api/project/destroy",
-
+
events: {
"keydown": 'stopPropagation',
"keydown [name=name]": 'enterSubmit',
@@ -32,7 +32,10 @@ var EditorSettings = FormView.extend({
data.rooms && Rooms.deserialize(data.rooms)
data.startPosition && scene.camera.move(data.startPosition)
- if (! data.isNew) {
+ if (data.isNew) {
+ this.$name.val( "Room " + moment().format("DD/MM/YYYY ha") )
+ }
+ else {
// console.log(data)
this.$id.val( data._id )
@@ -130,6 +133,9 @@ var EditorSettings = FormView.extend({
this.$name.val(data.name)
this.action = this.updateAction
+ Minotaur.unwatch(this)
+ Minotaur.hide()
+
window.history.pushState(null, document.title, "/project/" + data.slug + "/edit")
},
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index e3a8f2e..cc924da 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -4,6 +4,7 @@ var MediaEditor = FormView.extend({
events: {
"keydown": 'stopPropagation',
+ "focus [name]": "clearMinotaur",
"click [data-role=play-media]": "togglePaused",
"mousedown [name=keyframe]": "stopPropagation",
"mousedown": "stopPropagation",
diff --git a/public/assets/javascripts/ui/lib/FormView.js b/public/assets/javascripts/ui/lib/FormView.js
index 219952d..ab33bc0 100644
--- a/public/assets/javascripts/ui/lib/FormView.js
+++ b/public/assets/javascripts/ui/lib/FormView.js
@@ -54,15 +54,20 @@ var FormView = View.extend({
return fd
},
- save: function(e){
- e.preventDefault()
+ save: function(e, successCallback, errorCallback){
+ e && e.preventDefault()
this.$errors.hide().css("opacity", 0.0);
if (this.validate) {
var errors = this.validate()
if (errors && errors.length) {
- this.showErrors(errors)
+ if (errorCallback) {
+ errorCallback(errors)
+ }
+ else {
+ this.showErrors(errors)
+ }
return
}
}
@@ -74,18 +79,29 @@ var FormView = View.extend({
dataType: "json",
processData: false,
contentType: false,
- });
+ })
+
request.done($.proxy(function (response) {
if (response.error) {
var errors = []
for (var key in response.error.errors) {
errors.push(response.error.errors[key].message);
}
- this.showErrors(errors)
+ if (errorCallback) {
+ errorCallback(errors)
+ }
+ else {
+ this.showErrors(errors)
+ }
return
}
else {
- this.success && this.success(response)
+ if (successCallback) {
+ successCallback(response)
+ }
+ if (this.success) {
+ this.success(response)
+ }
}
}, this));
}
diff --git a/public/assets/javascripts/ui/lib/View.js b/public/assets/javascripts/ui/lib/View.js
index 999a0e5..d94e6db 100644
--- a/public/assets/javascripts/ui/lib/View.js
+++ b/public/assets/javascripts/ui/lib/View.js
@@ -1,13 +1,14 @@
var View = (function($, _){
var View = function(options) {
- this.cid = _.uniqueId('view');
+ this._id = _.uniqueId('view')
+ this.type = "view"
options || (options = {});
- _.extend(this, _.pick(options, viewOptions));
- this._ensureElement();
- this.initialize.apply(this, arguments);
- this.delegateEvents();
- };
+ _.extend(this, _.pick(options, viewOptions))
+ this._ensureElement()
+ this.initialize.apply(this, arguments)
+ this.delegateEvents()
+ }
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
@@ -58,7 +59,7 @@ var View = (function($, _){
var match = key.match(delegateEventSplitter);
var eventName = match[1], selector = match[2];
method = _.bind(method, this);
- eventName += '.delegateEvents' + this.cid;
+ eventName += '.delegateEvents' + this._id;
if (selector === '') {
this.$el.on(eventName, method);
} else {
@@ -70,7 +71,7 @@ var View = (function($, _){
// Clears all callbacks previously bound to the view with `delegateEvents`.
undelegateEvents: function() {
- this.$el.off('.delegateEvents' + this.cid);
+ this.$el.off('.delegateEvents' + this._id);
return this;
},