diff --git a/www/scripts/apps/admin/fields/views/alert.js b/www/scripts/apps/admin/fields/views/alert.js index c2283249e6..41f6d9e0e2 100644 --- a/www/scripts/apps/admin/fields/views/alert.js +++ b/www/scripts/apps/admin/fields/views/alert.js @@ -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 () { diff --git a/www/scripts/apps/admin/fields/views/create.js b/www/scripts/apps/admin/fields/views/create.js index e79b09aa1d..148eee649c 100644 --- a/www/scripts/apps/admin/fields/views/create.js +++ b/www/scripts/apps/admin/fields/views/create.js @@ -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, diff --git a/www/scripts/apps/admin/fields/views/dcField.js b/www/scripts/apps/admin/fields/views/dcField.js index 2306d4f660..3cd607315d 100644 --- a/www/scripts/apps/admin/fields/views/dcField.js +++ b/www/scripts/apps/admin/fields/views/dcField.js @@ -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) { diff --git a/www/scripts/apps/admin/fields/views/edit.js b/www/scripts/apps/admin/fields/views/edit.js index f5c0e8b98c..83e39766b1 100644 --- a/www/scripts/apps/admin/fields/views/edit.js +++ b/www/scripts/apps/admin/fields/views/edit.js @@ -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({ diff --git a/www/scripts/apps/admin/fields/views/fieldError.js b/www/scripts/apps/admin/fields/views/fieldError.js index 690318eeb8..cf19162b1b 100644 --- a/www/scripts/apps/admin/fields/views/fieldError.js +++ b/www/scripts/apps/admin/fields/views/fieldError.js @@ -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; } diff --git a/www/scripts/apps/admin/fields/views/list.js b/www/scripts/apps/admin/fields/views/list.js index 1ba42ef9b7..1d41586e08 100644 --- a/www/scripts/apps/admin/fields/views/list.js +++ b/www/scripts/apps/admin/fields/views/list.js @@ -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); diff --git a/www/scripts/apps/admin/fields/views/listRow.js b/www/scripts/apps/admin/fields/views/listRow.js index 3efe276372..012c981104 100644 --- a/www/scripts/apps/admin/fields/views/listRow.js +++ b/www/scripts/apps/admin/fields/views/listRow.js @@ -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 diff --git a/www/scripts/apps/admin/fields/views/modal.js b/www/scripts/apps/admin/fields/views/modal.js index 7a44dbacc0..4c186b6acd 100644 --- a/www/scripts/apps/admin/fields/views/modal.js +++ b/www/scripts/apps/admin/fields/views/modal.js @@ -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; }, diff --git a/www/scripts/apps/admin/fields/views/save.js b/www/scripts/apps/admin/fields/views/save.js index f03fd7fde9..3361504d3d 100644 --- a/www/scripts/apps/admin/fields/views/save.js +++ b/www/scripts/apps/admin/fields/views/save.js @@ -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; diff --git a/www/scripts/apps/admin/tasks-manager/views/scheduler.js b/www/scripts/apps/admin/tasks-manager/views/scheduler.js index eb34fb9061..baa75decfd 100644 --- a/www/scripts/apps/admin/tasks-manager/views/scheduler.js +++ b/www/scripts/apps/admin/tasks-manager/views/scheduler.js @@ -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); diff --git a/www/scripts/apps/admin/tasks-manager/views/task.js b/www/scripts/apps/admin/tasks-manager/views/task.js index b5edab0db0..d39d2da355 100644 --- a/www/scripts/apps/admin/tasks-manager/views/task.js +++ b/www/scripts/apps/admin/tasks-manager/views/task.js @@ -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);