mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
refactored code to use newer version of backbone.js and underscore.js
This commit is contained in:
@@ -17,6 +17,7 @@ define([
|
||||
var AlertView = Backbone.View.extend({
|
||||
tagName: "div",
|
||||
className: "alert",
|
||||
template: _.template($("#alert_template").html()),
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
|
||||
@@ -32,11 +33,8 @@ define([
|
||||
},
|
||||
render: function () {
|
||||
var self = this;
|
||||
var template = _.template($("#alert_template").html(), {
|
||||
msg: this.message
|
||||
});
|
||||
|
||||
this.$el.addClass("alert-" + this.alert).html(template).alert();
|
||||
this.$el.addClass("alert-" + this.alert).html(this.template({msg: this.message})).alert();
|
||||
|
||||
if (this.delay > 0) {
|
||||
window.setTimeout(function () {
|
||||
|
@@ -24,10 +24,10 @@ define([
|
||||
"click .btn-cancel-field": "toggleCreateFormAction",
|
||||
"keyup input": "onKeyupInput"
|
||||
},
|
||||
template: _.template($("#create_template").html()),
|
||||
render: function () {
|
||||
var template = _.template($("#create_template").html());
|
||||
|
||||
this.$el.html(template);
|
||||
this.$el.html(this.template());
|
||||
|
||||
$("#new-source", this.$el).autocomplete({
|
||||
minLength: 2,
|
||||
|
@@ -16,16 +16,16 @@ define([
|
||||
var DcFieldsView = Backbone.View.extend({
|
||||
tagName: "div",
|
||||
className: "input-append",
|
||||
template: _.template($("#dc_fields_template").html()),
|
||||
initialize: function (options) {
|
||||
this.field = options.field;
|
||||
},
|
||||
render: function () {
|
||||
var template = _.template($("#dc_fields_template").html(), {
|
||||
dces_elements: this.collection.toJSON(),
|
||||
field: this.field.toJSON()
|
||||
});
|
||||
|
||||
this.$el.html(template);
|
||||
this.$el.html(this.template({
|
||||
dces_elements: this.collection.toJSON(),
|
||||
field: this.field.toJSON()
|
||||
})
|
||||
);
|
||||
|
||||
var index = $("#dces-element", this.$el)[0].selectedIndex - 1;
|
||||
if (index > 0) {
|
||||
|
@@ -22,6 +22,7 @@ define([
|
||||
var FieldEditView = Backbone.View.extend(_.extend({}, MultiViews, {
|
||||
tagName: "div",
|
||||
className: "field-edit",
|
||||
template: _.template($("#edit_template").html()),
|
||||
initialize: function () {
|
||||
this.model.on("change", this._onModelChange, this);
|
||||
},
|
||||
@@ -34,15 +35,15 @@ define([
|
||||
},
|
||||
render: function () {
|
||||
var self = this;
|
||||
var template = _.template($("#edit_template").html(), {
|
||||
lng: AdminFieldApp.lng(),
|
||||
field: this.model.toJSON(),
|
||||
vocabularyTypes: AdminFieldApp.vocabularyCollection.toJSON(),
|
||||
modelErrors: AdminFieldApp.errorManager.getModelError(this.model),
|
||||
languages: AdminFieldApp.languages
|
||||
});
|
||||
|
||||
this.$el.empty().html(template);
|
||||
this.$el.empty().html(this.template({
|
||||
lng: AdminFieldApp.lng(),
|
||||
field: this.model.toJSON(),
|
||||
vocabularyTypes: AdminFieldApp.vocabularyCollection.toJSON(),
|
||||
modelErrors: AdminFieldApp.errorManager.getModelError(this.model),
|
||||
languages: AdminFieldApp.languages
|
||||
}
|
||||
));
|
||||
|
||||
this._assignView({
|
||||
".dc-fields-subview": new DcFieldView({
|
||||
|
@@ -14,6 +14,7 @@ define([
|
||||
"i18n"
|
||||
], function ($, _, Backbone, i18n) {
|
||||
var FieldErrorView = Backbone.View.extend({
|
||||
template: _.template($("#field_error_template").html()),
|
||||
initialize: function () {
|
||||
AdminFieldApp.errorManager.on("add-error", this.render, this);
|
||||
AdminFieldApp.errorManager.on("remove-error", this.render, this);
|
||||
@@ -33,11 +34,7 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
var template = _.template($("#field_error_template").html(), {
|
||||
messages: messages
|
||||
});
|
||||
|
||||
$(".block-alert").html(template);
|
||||
$(".block-alert").html(this.template({messages: messages}));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ define([
|
||||
"keyup #live_search": "searchAction",
|
||||
"update-sort": "updateSortAction"
|
||||
},
|
||||
template: _.template($("#item_list_view_template").html()),
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
// store all single rendered views
|
||||
@@ -62,9 +63,7 @@ define([
|
||||
});
|
||||
},
|
||||
render: function () {
|
||||
var template = _.template($("#item_list_view_template").html());
|
||||
|
||||
this.$el.empty().html(template);
|
||||
this.$el.empty().html(this.template());
|
||||
|
||||
this.$listEl = $("ul#collection-fields", this.$el);
|
||||
|
||||
|
@@ -16,6 +16,7 @@ define([
|
||||
var FieldListRowView = Backbone.View.extend({
|
||||
tagName: "li",
|
||||
className: "field-row",
|
||||
template: _.template($("#list_row_template").html()),
|
||||
initialize: function () {
|
||||
// destroy view is model is deleted
|
||||
this.model.on("change", this.onChange, this);
|
||||
@@ -52,14 +53,13 @@ define([
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
var template = _.template($("#list_row_template").html(), {
|
||||
id: this.model.get("id"),
|
||||
position: this.model.get("sorter"),
|
||||
name: this.model.get("name"),
|
||||
tag: this.model.get("tag")
|
||||
});
|
||||
|
||||
this.$el.empty().html(template);
|
||||
this.$el.empty().html(this.template({
|
||||
id: this.model.get("id") || "",
|
||||
position: this.model.get("sorter"),
|
||||
name: this.model.get("name"),
|
||||
tag: this.model.get("tag")
|
||||
}
|
||||
));
|
||||
|
||||
// highlight view if edit view model match current view model
|
||||
if (AdminFieldApp.fieldEditView
|
||||
|
@@ -20,6 +20,7 @@ define([
|
||||
events: {
|
||||
"click .confirm": "confirmAction"
|
||||
},
|
||||
template: _.template($("#modal_template").html()),
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
// remove view when modal is closed
|
||||
@@ -32,11 +33,7 @@ define([
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
var template = _.template($("#modal_template").html(), {
|
||||
msg: this.message || ""
|
||||
});
|
||||
|
||||
this.$el.html(template).modal();
|
||||
this.$el.html(this.template({msg: this.message || ""})).modal();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@@ -16,6 +16,7 @@ define([
|
||||
"apps/admin/fields/views/alert"
|
||||
], function ($, _, Backbone, i18n, bootstrap, AlertView) {
|
||||
var SaveView = Backbone.View.extend({
|
||||
template: _.template($("#save_template").html()),
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.previousAttributes = [];
|
||||
@@ -78,8 +79,7 @@ define([
|
||||
return this;
|
||||
},
|
||||
render: function () {
|
||||
var template = _.template($("#save_template").html());
|
||||
this.$el.html(template);
|
||||
this.$el.html(this.template());
|
||||
this.updateStateButton();
|
||||
|
||||
return this;
|
||||
|
@@ -13,8 +13,8 @@ define([
|
||||
"backbone"
|
||||
], function ($, _, Backbone) {
|
||||
var SchedulerView = Backbone.View.extend({
|
||||
template: _.template($('#scheduler_template').html()),
|
||||
initialize: function () {
|
||||
this.template = _.template($('#scheduler_template').html());
|
||||
// render only parts of the model
|
||||
this.model.on('change:configuration', this.renderConfiguration, this);
|
||||
this.model.on('change:actual', this.renderActual, this);
|
||||
|
@@ -13,8 +13,8 @@ define([
|
||||
"backbone"
|
||||
], function ($, _, Backbone) {
|
||||
var TaskView = Backbone.View.extend({
|
||||
template: _.template($('#task_template').html()),
|
||||
initialize: function () {
|
||||
this.template = _.template($('#task_template').html());
|
||||
// render only parts of the model
|
||||
this.model.on('change:id', this.renderId, this);
|
||||
this.model.on('change:configuration', this.renderConfiguration, this);
|
||||
|
Reference in New Issue
Block a user