PHP Classes

File: public/js/app/bb-todo/models/task.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy   Silex MVC Blog   public/js/app/bb-todo/models/task.js   Download  
File: public/js/app/bb-todo/models/task.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Silex MVC Blog
MVC based blog using on the Silex micro-framework
Author: By
Last change:
Date: 8 years ago
Size: 2,258 bytes
 

Contents

Class file image Download
define([], function () { // Task Model // ---------- var Task = Backbone.Model.extend({ // Reference to this collection's model. urlRoot: function () { if(app.todo.params.storage === 'local'){ return null; } if(app.todo.params.storage === 'server'){ return app.todo.params.serverStorage.urlRoot; } }, // Default attributes for the todo item. defaults: function () { return { title: "Empty task...", task_order: app.todo.taskList.nextOrder(), done: false }; }, // Ensure that each todo created has `title`. initialize: function () { if (!this.get("title")) { this.set({"title": this.defaults().title}); } }, // Toggle the `done` state of this todo item. toggle: function () { this.update({done: !this.get("done")}); }, // Destroy the model. delete: function (options) { var opts = options || {}; var defaults = { wait: true, emulateHTTP: _.isUndefined(app.todo.params.serverStorage.emulateHTTP) ? false : app.todo.params.serverStorage.emulateHTTP, success: function (collection, response, options) { }, error: function (collection, xhr, options) { app.sys.onFailure(xhr); } }; this.destroy(_.extend(defaults, opts)); }, // Save the model. update: function (attributes, options) { var opts = options || {}; var defaults = { wait: true, emulateHTTP: _.isUndefined(app.todo.params.serverStorage.emulateHTTP) ? false : app.todo.params.serverStorage.emulateHTTP, success: function (collection, response, options) { }, error: function (collection, xhr, options) { app.sys.onFailure(xhr); } }; this.save(attributes, _.extend(defaults, opts)); } }); return Task; });