short-jsdoc
Version:
short and simple jsdoc Object Oriented syntax format and implementation
1 lines • 597 kB
JSON
window.__shortjsdoc_data = {"source":"\n\n//@filename {Foo} fileName test1/index.js\n\n/*@module foo @class c*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-collection.js\n\n/*\n\n@module Backbone\n@class Backbone.Collection\n\nCollections are ordered sets of models. You can bind \"change\" events to be notified when any model in the collection has been modified, listen for \"add\" and \"remove\" events, fetch the collection from the server, and use a full suite of Underscore.js methods.\n\nAny event that is triggered on a model in a collection will also be triggered on the collection directly, for convenience. This allows you to listen for changes to specific attributes in any model in a collection, for example: documents.on(\"change:selected\", ...)\n\n\n\n@method extend\nTo create a Collection class of your own, extend Backbone.Collection, providing instance properties, as well as optional classProperties to be attached directly to the collection's constructor function.\n\n@param {Object} properties\n@param {Object} classProperties Optional\n*/\n\n\n/* @method model \nOverride this property to specify the model class that the collection contains. If defined, you can pass raw attributes objects (and arrays) to add, create, and reset, and the attributes will be converted into a model of the proper type.\n\n\tvar Library = Backbone.Collection.extend({\n\t model: Book\n\t});\nA collection can also contain polymorphic models by overriding this property with a constructor that returns a model.\n\n\tvar Library = Backbone.Collection.extend({\n\n\t model: function(attrs, options) {\n\t if (condition) {\n\t return new PublicDocument(attrs, options);\n\t } else {\n\t return new PrivateDocument(attrs, options);\n\t }\n\t }\n\t});\n@param {Object}attrs\n@param {Object} options\n\n*/\n\n\n\n/*\n@constructor\n\nWhen creating a Collection, you may choose to pass in the initial array of models. The collection's comparator may be included as an option. Passing false as the comparator option will prevent sorting. If you define an initialize function, it will be invoked when the collection is created. There are a couple of options that, if provided, are attached to the collection directly: model and comparator.\n\n\tvar tabs = new TabSet([tab1, tab2, tab3]);\n\tvar spaces = new Backbone.Collection([], {\n\t model: Space\n\t});\n\n@param {Array} models optional\n@param {Object} options optional\n\n*/\n\n\n/*\n@property {Array} models\nRaw access to the JavaScript array of models inside of the collection. Usually you'll want to use get, at, or the Underscore methods to access model objects, but occasionally a direct reference to the array is desired.\n*/\n\n\n/*@method toJSON\nReturn an array containing the attributes hash of each model (via toJSON) in the collection. This can be used to serialize and persist the collection as a whole. The name of this method is a bit confusing, because it conforms to JavaScript's JSON API.\n\n\tvar collection = new Backbone.Collection([\n\t {name: \"Tim\", age: 5},\n\t {name: \"Ida\", age: 26},\n\t {name: \"Rob\", age: 55}\n\t]);\n\n\talert(JSON.stringify(collection));\n\n@returns {Array}\n\n*/\n\n/*\n@method sync\nsynccollection.sync(method, collection, [options]) \nUses Backbone.sync to persist the state of a collection to the server. Can be overridden for custom behavior.\n\n\n@param {String} method\n@param {Backbone.Collection} collection\n@param {Object} options optional\n\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-events.js\n\n\n//@module Backbone\n\n/*\n@class Backbone.Events\n\nEvents is a module that can be mixed in to any object, giving the object the ability to bind and trigger custom named events. Events do not have to be declared before they are bound, and may take passed arguments. For example:\n\n\tvar object = {};\n\n\t_.extend(object, Backbone.Events);\n\n\tobject.on(\"alert\", function(msg) {\n\t alert(\"Triggered \" + msg);\n\t});\n\n\tobject.trigger(\"alert\", \"an event\");\n\t\nFor example, to make a handy event dispatcher that can coordinate events among different areas of your application: var dispatcher = _.clone(Backbone.Events)\n\n\n#Catalog of Events \nHere's the complete list of built-in Backbone events, with arguments. You're also free to trigger your own events on Models, Collections and Views as you see fit. The Backbone object itself mixes in Events, and can be used to emit any global events that your application needs.\n\n\t\"add\" (model, collection, options) — when a model is added to a collection.\n\t\"remove\" (model, collection, options) — when a model is removed from a collection.\n\t\"reset\" (collection, options) — when the collection's entire contents have been replaced.\n\t\"sort\" (collection, options) — when the collection has been re-sorted.\n\t\"change\" (model, options) — when a model's attributes have changed.\n\t\"change:[attribute]\" (model, value, options) — when a specific attribute has been updated.\n\t\"destroy\" (model, collection, options) — when a model is destroyed.\n\t\"request\" (model_or_collection, xhr, options) — when a model or collection has started a request to the server.\n\t\"sync\" (model_or_collection, resp, options) — when a model or collection has been successfully synced with the server.\n\t\"error\" (model_or_collection, resp, options) — when model's or collection's request to remote server has failed.\n\t\"invalid\" (model, error, options) — when a model's validation fails on the client.\n\t\"route:[name]\" (params) — Fired by the router when a specific route is matched.\n\t\"route\" (route, params) — Fired by the router when any route has been matched.\n\t\"route\" (router, route, params) — Fired by history when any route has been matched.\n\t\"all\" — this special event fires for any triggered event, passing the event name as the first argument.\nGenerally speaking, when calling a function that emits an event (model.set, collection.add, and so on...), if you'd like to prevent the event from being triggered, you may pass {silent: true} as an option. Note that this is rarely, perhaps even never, a good idea. Passing through a specific flag in the options for your event callback to look at, and choose to ignore, will usually work out better.\n\n*/\n\n\n\n/*\n@method bind\n\nAlias on\n\nBind a callback function to an object. The callback will be invoked whenever the event is fired. If you have a large number of different events on a page, the convention is to use colons to namespace them: \"poll:start\", or \"change:selection\". The event string may also be a space-delimited list of several events...\n\n\tbook.on(\"change:title change:author\", ...);\n\nTo supply a context value for this when the callback is invoked, pass the optional third argument: model.on('change', this.render, this)\n\nCallbacks bound to the special \"all\" event will be triggered when any event occurs, and are passed the name of the event as the first argument. For example, to proxy all events from one object to another:\n\n\tproxy.on(\"all\", function(eventName) {\n\t object.trigger(eventName);\n\t});\nAll Backbone event methods also support an event map syntax, as an alternative to positional arguments:\n\n\tbook.on({\n\t \"change:title\": titleView.update,\n\t \"change:author\": authorPane.update,\n\t \"destroy\": bookView.remove\n\t});\n\n@param {String} event\n@param {Function} callback\n@param {Object} context optional\n*/\n\n\n\n/*\n@method off\nRemove a previously-bound callback function from an object. If no context is specified, all of the versions of the callback with different contexts will be removed. If no callback is specified, all callbacks for the event will be removed. If no event is specified, callbacks for all events will be removed.\n\n\t// Removes just the `onChange` callback.\n\tobject.off(\"change\", onChange);\n\n\t// Removes all \"change\" callbacks.\n\tobject.off(\"change\");\n\n\t// Removes the `onChange` callback for all events.\n\tobject.off(null, onChange);\n\n\t// Removes all callbacks for `context` for all events.\n\tobject.off(null, null, context);\n\n\t// Removes all callbacks on `object`.\n\tobject.off();\nNote that calling model.off(), for example, will indeed remove all events on the model — including events that Backbone uses for internal bookkeeping.\n*/\n\n\n\n/*@method trigger\nTrigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to trigger will be passed along to the event callbacks.\n*/\n\n\n\n/*@method once\nJust like on, but causes the bound callback to only fire once before being removed. Handy for saying \"the next time that X happens, do this\".\n@param {String}event\n@param {Function} callback\n*/\n\n\n/*\n@method listenTo\n\nTell an object to listen to a particular event on an other object. The advantage of using this form, instead of other.on(event, callback, object), is that listenTo allows the object to keep track of the events, and they can be removed all at once later on. The callback will always be called with object as context.\n\n\tview.listenTo(model, 'change', view.render);\n\n@param {Backbone.Events} other\n@param {String} event\n@param {Function} calback\n*/\n\n\n\n/*\n@method stopListening\n\nTell an object to stop listening to events. Either call stopListening with no arguments to have the object remove all of its registered callbacks ... or be more precise by telling it to remove just the events it's listening to on a specific object, or a specific event, or just a specific callback.\n\n\tview.stopListening();\n\n\tview.stopListening(model);\n\n\n@param {Backbone.Events} other optional\n@param {String} event optional\n@param {Function} calback optional\n\n*/\n\n\n/*@method listenToOnce\nJust like listenTo, but causes the bound callback to only fire once before being removed.\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-history.js\n\n/*@module Backbone\n\n@class Backbone.History\n\n*History* serves as a global router (per frame) to handle hashchange events or pushState, match the appropriate route, and trigger callbacks. You shouldn't ever have to create one of these yourself since Backbone.history already contains one.\n\n*pushState support* exists on a purely opt-in basis in Backbone. Older browsers that don't support pushState will continue to use hash-based URL fragments, and if a hash URL is visited by a pushState-capable browser, it will be transparently upgraded to the true URL. Note that using real URLs requires your web server to be able to correctly render those pages, so back-end changes are required as well. For example, if you have a route of /documents/100, your web server must be able to serve that page, if the browser visits that URL directly. For full search-engine crawlability, it's best to have the server generate the complete HTML for the page ... but if it's a web application, just rendering the same content you would have for the root URL, and filling in the rest with Backbone Views and JavaScript works fine.\n\n\n@method start\n\nWhen all of your Routers have been created, and all of the routes are set up properly, call Backbone.history.start() to begin monitoring hashchange events, and dispatching routes. Subsequent calls to Backbone.history.start() will throw an error, and Backbone.History.started is a boolean value indicating whether it has already been called.\n\nTo indicate that you'd like to use HTML5 pushState support in your application, use Backbone.history.start({pushState: true}). If you'd like to use pushState, but have browsers that don't support it natively use full page refreshes instead, you can add {hashChange: false} to the options.\n\nIf your application is not being served from the root url / of your domain, be sure to tell History where the root really is, as an option: Backbone.history.start({pushState: true, root: \"/public/search/\"})\n\nWhen called, if a route succeeds with a match for the current URL, Backbone.history.start() returns true. If no defined route matches the current URL, it returns false.\n\nIf the server has already rendered the entire page, and you don't want the initial route to trigger when starting History, pass silent: true.\n\nBecause hash-based history in Internet Explorer relies on an <iframe>, be sure to only call start() after the DOM is ready.\n\n\t$(function(){\n\t new WorkspaceRouter();\n\t new HelpPaneRouter();\n\t Backbone.history.start({pushState: true});\n\t});\n\n@param {Object} options\n\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-model.js\n\n/*\n@module Backbone\n@class Backbone.Model \n\n\nModels are the heart of any JavaScript application, containing the interactive data as well as a large part of the logic surrounding it: conversions, validations, computed properties, and access control. You extend Backbone.Model with your domain-specific methods, and Model provides a basic set of functionality for managing changes.\n\nThe following is a contrived example, but it demonstrates defining a model with a custom method, setting an attribute, and firing an event keyed to changes in that specific attribute. After running this code once, sidebar will be available in your browser's console, so you can play around with it.\n\n\tvar Sidebar = Backbone.Model.extend({\n\t promptColor: function() {\n\t var cssColor = prompt(\"Please enter a CSS color:\");\n\t this.set({color: cssColor});\n\t }\n\t});\n\n\twindow.sidebar = new Sidebar;\n\n\tsidebar.on('change:color', function(model, color) {\n\t $('#sidebar').css({background: color});\n\t});\n\n\tsidebar.set({color: 'white'});\n\n\tsidebar.promptColor();\n\n@extends Backbone.Events\n\n*/\n\n\n\n\n/*\n@method extend\n\nTo create a Model class of your own, you extend Backbone.Model and provide instance properties, as well as optional classProperties to be attached directly to the constructor function.\n\nextend correctly sets up the prototype chain, so subclasses created with extend can be further extended and subclassed as far as you like.\n\n\tvar Note = Backbone.Model.extend({\n\n\t initialize: function() { ... },\n\n\t author: function() { ... },\n\n\t coordinates: function() { ... },\n\n\t allowedToEdit: function(account) {\n\t return true;\n\t }\n\n\t});\n\n\tvar PrivateNote = Note.extend({\n\n\t allowedToEdit: function(account) {\n\t return account.owns(this);\n\t }\n\n\t});\n\n#super\n\nBrief aside on super: JavaScript does not provide a simple way to call super — the function of the same name defined higher on the prototype chain. If you override a core function like set, or save, and you want to invoke the parent object's implementation, you'll have to explicitly call it, along these lines:\n\n\tvar Note = Backbone.Model.extend({\n\t set: function(attributes, options) {\n\t Backbone.Model.prototype.set.apply(this, arguments);\n\t ...\n\t }\n\t});\n\n\n\n@static\n@param {Object} properties\n@param {Object} classProperties\n*/\n\n\n\n/*\n@method initialize\n\nUse like this:\n\n\tnew Model([attributes], [options]) \n\nWhen creating an instance of a model, you can pass in the initial values of the attributes, which will be set on the model. If you define an initialize function, it will be invoked when the model is created.\n\n\tnew Book({\n\t title: \"One Thousand and One Nights\",\n\t author: \"Scheherazade\"\n\t});\nIn rare cases, if you're looking to get fancy, you may want to override constructor, which allows you to replace the actual constructor function for your model.\n\n\tvar Library = Backbone.Model.extend({\n\t constructor: function() {\n\t this.books = new Books();\n\t Backbone.Model.apply(this, arguments);\n\t },\n\t parse: function(data, options) {\n\t this.books.reset(data.books);\n\t return data.library;\n\t }\n\t});\nIf you pass a {collection: ...} as the options, the model gains a collection property that will be used to indicate which collection the model belongs to, and is used to help compute the model's url. The model.collection property is normally created automatically when you first add a model to a collection. Note that the reverse is not true, as passing this option to the constructor will not automatically add the model to the collection. Useful, sometimes.\n\nIf {parse: true} is passed as an option, the attributes will first be converted by parse before being set on the model.\n\n*/\n\n\n\n/*@method get\nGet the current value of an attribute from the model. For example: note.get(\"title\")\n@param {String} name the property name to get\n@returns {Any} the value of the property\n*/\n\n\n\n\n/*\n@method set\n\nSet a hash of attributes (one or many) on the model. If any of the attributes change the model's state, a \"change\" event will be triggered on the model. Change events for specific attributes are also triggered, and you can bind to those as well, for example: change:title, and change:content. You may also pass individual keys and values.\n\n\tnote.set({title: \"March 20\", content: \"In his eyes she eclipses...\"});\n\n\tbook.set(\"title\", \"A Scandal in Bohemia\");\n\n@param {String} name\n@param {Any} value\n@param {Object} options Optional\n*/\n\n\n\n\n/*\n@method escape\n\nSimilar to get, but returns the HTML-escaped version of a model's attribute. If you're interpolating data from the model into HTML, using escape to retrieve attributes will prevent XSS attacks.\n\n\tvar hacker = new Backbone.Model({\n\t name: \"<script>alert('xss')</script>\"\n\t});\n\n\talert(hacker.escape('name'));\n*/\n\n\n/*\n@method has\nReturns true if the attribute is set to a non-null or non-undefined value.\n\n\tif (note.has(\"title\")) {\n\t ...\n\t}\n\n@param {String} name\n*/\n\n\n/*\n@method unset\nRemove an attribute by deleting it from the internal attributes hash. Fires a \"change\" event unless silent is passed as an option.\n@param {String}attribute\n@param {Object} options Optional\n*/\n\n\n\n\n/*\n@method clear\n\nRemoves all attributes from the model, including the id attribute. Fires a \"change\" event unless silent is passed as an option.\n\n@param {Object} options Optional\n*/\n\n\n/*\n@property {String} id \n\nA special property of models, the id is an arbitrary string (integer id or UUID). If you set the id in the attributes hash, it will be copied onto the model as a direct property. Models can be retrieved by id from collections, and the id is used to generate model URLs by default.\n*/\n\n\n\n/*\n@property {String} idAttribute\nA model's unique identifier is stored under the id attribute. If you're directly communicating with a backend (CouchDB, MongoDB) that uses a different unique key, you may set a Model's idAttribute to transparently map from that key to id.\n\n\tvar Meal = Backbone.Model.extend({\n\t idAttribute: \"_id\"\n\t});\n\n\tvar cake = new Meal({ _id: 1, name: \"Cake\" });\n\talert(\"Cake id: \" + cake.id);\n*/\n\n\n\n/*\n@property {String} cid \n\nA special property of models, the cid or client id is a unique identifier automatically assigned to all models when they're first created. Client ids are handy when the model has not yet been saved to the server, and does not yet have its eventual true id, but already needs to be visible in the UI.\n*/\n\n\n\n/*@property {Object}attributes\nThe attributes property is the internal hash containing the model's state — usually (but not necessarily) a form of the JSON object representing the model data on the server. It's often a straightforward serialization of a row from the database, but it could also be client-side computed state.\n\nPlease use set to update the attributes instead of modifying them directly. If you'd like to retrieve and munge a copy of the model's attributes, use _.clone(model.attributes) instead.\n\nDue to the fact that Events accepts space separated lists of events, attribute names should not include spaces.\n*/\n\n\n\n\n\n/*\n@property{Object}changed\nThe changed property is the internal hash containing all the attributes that have changed since the last set. Please do not update changed directly since its state is internally maintained by set. A copy of changed can be acquired from changedAttributes.\n*/\n\n\n\n/*\n@property{Object}defaults\nThe defaults hash (or function) can be used to specify the default attributes for your model. When creating an instance of the model, any unspecified attributes will be set to their default value.\n\n\tvar Meal = Backbone.Model.extend({\n\t defaults: {\n\t \"appetizer\": \"caesar salad\",\n\t \"entree\": \"ravioli\",\n\t \"dessert\": \"cheesecake\"\n\t }\n\t});\n\n\talert(\"Dessert will be \" + (new Meal).get('dessert'));\nRemember that in JavaScript, objects are passed by reference, so if you include an object as a default value, it will be shared among all instances. Instead, define defaults as a function.\n*/\n\n\n\n\n\n\n\n/*\n@method toJSON \nReturn a shallow copy of the model's attributes for JSON stringification. This can be used for persistence, serialization, or for augmentation before being sent to the server. The name of this method is a bit confusing, as it doesn't actually return a JSON string — but I'm afraid that it's the way that the JavaScript API for JSON.stringify works.\n\n\tvar artist = new Backbone.Model({\n\t firstName: \"Wassily\",\n\t lastName: \"Kandinsky\"\n\t});\n\n\tartist.set({birthday: \"December 16, 1866\"});\n\n\talert(JSON.stringify(artist));\n\n@param {Object} options Optional\n@return {String}\n*/\n\n\n\n\n/*\n@method sync\nUses Backbone.sync to persist the state of a model to the server. Can be overridden for custom behavior.\n@param {String} method\n@param {Backbone.Model} model\n@param {Object} options Optional\n@static\n*/\n\n\n\n\n/*\n@method fetch\n\nResets the model's state from the server by delegating to Backbone.sync. Returns a jqXHR. Useful if the model has never been populated with data, or if you'd like to ensure that you have the latest server state. A \"change\" event will be triggered if the server's state differs from the current attributes. Accepts success and error callbacks in the options hash, which are both passed (model, response, options) as arguments.\n\n\t// Poll every 10 seconds to keep the channel model up-to-date.\n\tsetInterval(function() {\n\t channel.fetch();\n\t}, 10000);\n\n@param {Object} options Optional\n*/\n\n\n\n\n/*\n@method save\n\nSave a model to your database (or alternative persistence layer), by delegating to Backbone.sync. Returns a jqXHR if validation is successful and false otherwise. The attributes hash (as in set) should contain the attributes you'd like to change — keys that aren't mentioned won't be altered — but, a complete representation of the resource will be sent to the server. As with set, you may pass individual keys and values instead of a hash. If the model has a validate method, and validation fails, the model will not be saved. If the model isNew, the save will be a \"create\" (HTTP POST), if the model already exists on the server, the save will be an \"update\" (HTTP PUT).\n\nIf instead, you'd only like the changed attributes to be sent to the server, call model.save(attrs, {patch: true}). You'll get an HTTP PATCH request to the server with just the passed-in attributes.\n\nCalling save with new attributes will cause a \"change\" event immediately, a \"request\" event as the Ajax request begins to go to the server, and a \"sync\" event after the server has acknowledged the successful change. Pass {wait: true} if you'd like to wait for the server before setting the new attributes on the model.\n\nIn the following example, notice how our overridden version of Backbone.sync receives a \"create\" request the first time the model is saved and an \"update\" request the second time.\n\n\tBackbone.sync = function(method, model) {\n\t alert(method + \": \" + JSON.stringify(model));\n\t model.set('id', 1);\n\t};\n\n\tvar book = new Backbone.Model({\n\t title: \"The Rough Riders\",\n\t author: \"Theodore Roosevelt\"\n\t});\n\n\tbook.save();\n\n\tbook.save({author: \"Teddy\"});\n\nsave accepts success and error callbacks in the options hash, which will be passed the arguments (model, response, options). If a server-side validation fails, return a non-200 HTTP response code, along with an error response in text or JSON.\n\n\tbook.save(\"author\", \"F.D.R.\", {error: function(){ ... }});\n\n@param {Object} attributes optional\n@param {Object} options optional\n\n*/\n\n\n\n\n\n/*\n@method destroy\n\nDestroys the model on the server by delegating an HTTP DELETE request to Backbone.sync. Returns a jqXHR object, or false if the model isNew. Accepts success and error callbacks in the options hash, which will be passed (model, response, options). Triggers a \"destroy\" event on the model, which will bubble up through any collections that contain it, a \"request\" event as it begins the Ajax request to the server, and a \"sync\" event, after the server has successfully acknowledged the model's deletion. Pass {wait: true} if you'd like to wait for the server to respond before removing the model from the collection.\n\n\tbook.destroy({success: function(model, response) {\n\t ...\n\t}});\n\n@param {Object} options optional\n\n*/\n\n\n\n\n\n/*\n\n@method validate\n\nThis method is left undefined, and you're encouraged to override it with your custom validation logic, if you have any that can be performed in JavaScript. By default validate is called before save, but can also be called before set if {validate:true} is passed. The validate method is passed the model attributes, as well as the options from set or save. If the attributes are valid, don't return anything from validate; if they are invalid, return an error of your choosing. It can be as simple as a string error message to be displayed, or a complete error object that describes the error programmatically. If validate returns an error, save will not continue, and the model attributes will not be modified on the server. Failed validations trigger an \"invalid\" event, and set the validationError property on the model with the value returned by this method.\n\n\tvar Chapter = Backbone.Model.extend({\n\t validate: function(attrs, options) {\n\t if (attrs.end < attrs.start) {\n\t return \"can't end before it starts\";\n\t }\n\t }\n\t});\n\n\tvar one = new Chapter({\n\t title : \"Chapter One: The Beginning\"\n\t});\n\n\tone.on(\"invalid\", function(model, error) {\n\t alert(model.get(\"title\") + \" \" + error);\n\t});\n\n\tone.save({\n\t start: 15,\n\t end: 10\n\t});\n\n\"invalid\" events are useful for providing coarse-grained error messages at the model or collection level.\n\n@param {Object} attributes optional\n@param {Object} options optional\n\n*/\n\n\n/*\n@property {Error} validation\nThe value returned by validate during the last failed validation.\n\n\n*/\n\n\n\n/*@method isValid\n\nRun validate to check the model state.\n\n\tvar Chapter = Backbone.Model.extend({\n\t validate: function(attrs, options) {\n\t if (attrs.end < attrs.start) {\n\t return \"can't end before it starts\";\n\t }\n\t }\n\t});\n\n\tvar one = new Chapter({\n\t title : \"Chapter One: The Beginning\"\n\t});\n\n\tone.set({\n\t start: 15,\n\t end: 10\n\t});\n\n\tif (!one.isValid()) {\n\t alert(one.get(\"title\") + \" \" + one.validationError);\n\t}\n\n@return {boolean} true if model is valid\n*/\n\n\n\n/*@method url\nReturns the relative URL where the model's resource would be located on the server. If your models are located somewhere else, override this method with the correct logic. Generates URLs of the form: \"[collection.url]/[id]\" by default, but you may override by specifying an explicit urlRoot if the model's collection shouldn't be taken into account.\n\nDelegates to Collection#url to generate the URL, so make sure that you have it defined, or a urlRoot property, if all models of this class share a common root URL. A model with an id of 101, stored in a Backbone.Collection with a url of \"/documents/7/notes\", would have this URL: \"/documents/7/notes/101\"\n\n@return {String} the relative of url for this model\n*/\n\n\n/*\n@property {Function|String} urlRoot\n\nSpecify a urlRoot if you're using a model outside of a collection, to enable the default url function to generate URLs based on the model id. \"[urlRoot]/id\"\nNormally, you won't need to define this. Note that urlRoot may also be a function.\n\n\tvar Book = Backbone.Model.extend({urlRoot : '/books'});\n\n\tvar solaris = new Book({id: \"1083-lem-solaris\"});\n\n\talert(solaris.url());\n*/\n\n\n\n\n/*\n@method parse\nparse is called whenever a model's data is returned by the server, in fetch, and save. The function is passed the raw response object, and should return the attributes hash to be set on the model. The default implementation is a no-op, simply passing through the JSON response. Override this if you need to work with a preexisting API, or better namespace your responses.\n\nIf you're working with a Rails backend that has a version prior to 3.1, you'll notice that its default to_json implementation includes a model's attributes under a namespace. To disable this behavior for seamless Backbone integration, set:\n\n\tActiveRecord::Base.include_root_in_json = false\n\n@param {Object} response \n@param {Object} options\n\n*/\n\n\n/*\n@method clone\n\nReturns a new instance of the model with identical attributes.\n\n*/\n\n\n/*@method isNew\nHas this model been saved to the server yet? If the model does not yet have an id, it is considered to be new.\n@return {boolean}\n*/\n\n\n/*\n@method hasChanged\nHas the model changed since the last set? If an attribute is passed, returns true if that specific attribute has changed.\n\nNote that this method, and the following change-related ones, are only useful during the course of a \"change\" event.\n\n\tbook.on(\"change\", function() {\n\t if (book.hasChanged(\"title\")) {\n\t ...\n\t }\n\t});\n\n@param {String} attribute optional\n\n*/\n\n\n/*\n@method changedAttributes\nRetrieve a hash of only the model's attributes that have changed since the last set, or false if there are none. Optionally, an external attributes hash can be passed in, returning the attributes in that hash which differ from the model. This can be used to figure out which portions of a view should be updated, or what calls need to be made to sync the changes to the server.\n\n@param {Object} attributes optional\n*/\n\n\n/*\n@method previous\nDuring a \"change\" event, this method can be used to get the previous value of a changed attribute.\n\n\tvar bill = new Backbone.Model({\n\t name: \"Bill Smith\"\n\t});\n\n\tbill.on(\"change:name\", function(model, name) {\n\t alert(\"Changed name from \" + bill.previous(\"name\") + \" to \" + name);\n\t});\n\n\tbill.set({name : \"Bill Jones\"});\n\n@param {String} attribute optional\n*/\n\n\n/* @method previousAttributes\nReturn a copy of the model's previous attributes. Useful for getting a diff between versions of a model, or getting back to a valid state after an error occurs.\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-router.js\n\n/*\n@module Backbone\n@class Backbone.Router\n\nWeb applications often provide linkable, bookmarkable, shareable URLs for important locations in the app. Until recently, hash fragments (#page) were used to provide these permalinks, but with the arrival of the History API, it's now possible to use standard URLs (/page). Backbone.Router provides methods for routing client-side pages, and connecting them to actions and events. For browsers which don't yet support the History API, the Router handles graceful fallback and transparent translation to the fragment version of the URL.\n\nDuring page load, after your application has finished creating all of its routers, be sure to call Backbone.history.start(), or Backbone.history.start({pushState: true}) to route the initial URL.\n\n*/\n\n\n\n/*\n@method extend \n\nGet started by creating a custom router class. Define actions that are triggered when certain URL fragments are matched, and provide a routes hash that pairs routes to actions. Note that you'll want to avoid using a leading slash in your route definitions:\n\n\tvar Workspace = Backbone.Router.extend({\n\n\t routes: {\n\t \"help\": \"help\", // #help\n\t \"search/:query\": \"search\", // #search/kiwis\n\t \"search/:query/p:page\": \"search\" // #search/kiwis/p7\n\t },\n\n\t help: function() {\n\t ...\n\t },\n\n\t search: function(query, page) {\n\t ...\n\t }\n\n\t});\n\n@param {Object} properties\n@param {Object} classProperties Optional\n@static\n*/\n\n/*\n\n@property {Object<String,String>}routes\n\nThe routes hash maps URLs with parameters to functions on your router (or just direct function definitions, if you prefer), similar to the View's events hash. Routes can contain parameter parts, :param, which match a single URL component between slashes; and splat parts *splat, which can match any number of URL components. Part of a route can be made optional by surrounding it in parentheses (/:optional).\n\nFor example, a route of \"search/:query/p:page\" will match a fragment of #search/obama/p2, passing \"obama\" and \"2\" to the action.\n\nA route of \"file/*path\" will match #file/nested/folder/file.txt, passing \"nested/folder/file.txt\" to the action.\n\nA route of \"docs/:section(/:subsection)\" will match #docs/faq and #docs/faq/installing, passing \"faq\" to the action in the first case, and passing \"faq\" and \"installing\" to the action in the second.\n\nTrailing slashes are treated as part of the URL, and (correctly) treated as a unique route when accessed. docs and docs/ will fire different callbacks. If you can't avoid generating both types of URLs, you can define a \"docs(/)\" matcher to capture both cases.\n\nWhen the visitor presses the back button, or enters a URL, and a particular route is matched, the name of the action will be fired as an event, so that other objects can listen to the router, and be notified. In the following example, visiting #help/uploading will fire a route:help event from the router.\n\n\troutes: {\n\t \"help/:page\": \"help\",\n\t \"download/*path\": \"download\",\n\t \"folder/:name\": \"openFolder\",\n\t \"folder/:name-:mode\": \"openFolder\"\n\t}\n\trouter.on(\"route:help\", function(page) {\n\t ...\n\t});\n\n*/\n\n\n/*@constructor\nWhen creating a new router, you may pass its routes hash directly as an option, if you choose. All options will also be passed to your initialize function, if defined.\n@param {Object}options Optional\n*/\n\n\n\n/*\n@method route\n\nManually create a route for the router, The route argument may be a routing string or regular expression. Each matching capture from the route or regular expression will be passed as an argument to the callback. The name argument will be triggered as a \"route:name\" event whenever the route is matched. If the callback argument is omitted router[name] will be used instead. Routes added later may override previously declared routes.\n\n\tinitialize: function(options) {\n\n\t // Matches #page/10, passing \"10\"\n\t this.route(\"page/:number\", \"page\", function(number){ ... });\n\n\t // Matches /117-a/b/c/open, passing \"117-a/b/c\" to this.open\n\t this.route(/^(.*?)\\/open$/, \"open\");\n\n\t},\n\n\topen: function(id) { ... }\n\n@param {String}route\n@param {String } name\n@param {Function} handler Optional\n*/\n\n\n\n\n/*\n@method navigate\nWhenever you reach a point in your application that you'd like to save as a URL, call navigate in order to update the URL. If you wish to also call the route function, set the trigger option to true. To update the URL without creating an entry in the browser's history, set the replace option to true.\n\n\topenPage: function(pageNumber) {\n\t this.document.pages.at(pageNumber).open();\n\t this.navigate(\"page/\" + pageNumber);\n\t}\n\n# Or ...\n\n\tapp.navigate(\"help/troubleshooting\", {trigger: true});\n\nOr ...\n\n\tapp.navigate(\"help/troubleshooting\", {trigger: true, replace: true});\n\n@param {String} fragment\n@param {Object}options Optional\n*/\n\n\n/*\n@method execute\n\nThis method is called internally within the router, whenever a route matches and its corresponding callback is about to be executed. Override it to perform custom parsing or wrapping of your routes, for example, to parse query strings before handing them to your route callback, like so:\n\n\tvar Router = Backbone.Router.extend({\n\t execute: function(callback, args) {\n\t args.push(parseQueryString(args.pop()));\n\t if (callback) callback.apply(this, args);\n\t }\n\t});\n\n@param {Function} callback\n@param {Any} args\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone-view.js\n\n/*\n\n@module Backbone\n\n@class Backbone.View\n\nBackbone views are almost more convention than they are code — they don't determine anything about your HTML or CSS for you, and can be used with any JavaScript templating library. The general idea is to organize your interface into logical views, backed by models, each of which can be updated independently when the model changes, without having to redraw the page. Instead of digging into a JSON object, looking up an element in the DOM, and updating the HTML by hand, you can bind your view's render function to the model's \"change\" event — and now everywhere that model data is displayed in the UI, it is always immediately up to date.\n\n@extend Backbone.Events\n\n*/\n\n/*@method extend\n\n\nGet started with views by creating a custom view class. You'll want to override the render function, specify your declarative events, and perhaps the tagName, className, or id of the View's root element.\n\n\tvar DocumentRow = Backbone.View.extend({\n\n\t tagName: \"li\",\n\n\t className: \"document-row\",\n\n\t events: {\n\t \"click .icon\": \"open\",\n\t \"click .button.edit\": \"openEditDialog\",\n\t \"click .button.delete\": \"destroy\"\n\t },\n\n\t initialize: function() {\n\t this.listenTo(this.model, \"change\", this.render);\n\t },\n\n\t render: function() {\n\t ...\n\t }\n\n\t});\nProperties like tagName, id, className, el, and events may also be defined as a function, if you want to wait to define them until runtime.\n\n@static\n*/\n\n\n\n/* @method initialize\n\nThere are several special options that, if passed, will be attached directly to the view: model, collection, el, id, className, tagName, attributes and events. If the view defines an initialize function, it will be called when the view is first created. If you'd like to create a view that references an element already in the DOM, pass in the element as an option: new View({el: existingElement})\n\n\tvar doc = documents.first();\n\n\tnew DocumentRow({\n\t model: doc,\n\t id: \"document-row-\" + doc.id\n\t});\n\n@param {Any}options Optional\n\n*/\n\n/*\n@property {HTMLElement} el\nAll views have a DOM element at all times (the el property), whether they've already been inserted into the page or not. In this fashion, views can be rendered at any time, and inserted into the DOM all at once, in order to get high-performance UI rendering with as few reflows and repaints as possible. this.el is created from the view's tagName, className, id and attributes properties, if specified. If not, el is an empty div.\n\n\tvar ItemView = Backbone.View.extend({\n\t tagName: 'li'\n\t});\n\n\tvar BodyView = Backbone.View.extend({\n\t el: 'body'\n\t});\n\n\tvar item = new ItemView();\n\tvar body = new BodyView();\n\n\talert(item.el + ' ' + body.el);\n*/\n\n/*@property {jQuery} $el \nA cached jQuery object for the view's element. A handy reference instead of re-wrapping the DOM element all the time.\n\n\tview.$el.show();\n\n\tlistView.$el.append(itemView.el);\n\n*/\n\n/*@method setElement\nIf you'd like to apply a Backbone view to a different DOM element, use setElement, which will also create the cached $el reference and move the view's delegated events from the old element to the new one.\n@param {HTMLElement} element\n*/\n\n/*@property {Object} attributes\nA hash of attributes that will be set as HTML DOM element attributes on the view's el (id, class, data-properties, etc.), or a function that returns such a hash.\n*/\n\n/* @property {jQuery} $\nIf jQuery is included on the page, each view has a $ function that runs queries scoped within the view's element. If you use this scoped jQuery function, you don't have to use model ids as part of your query to pull out specific elements in a list, and can rely much more on HTML class attributes. It's equivalent to running: view.$el.find(selector)\n\n\tui.Chapter = Backbone.View.extend({\n\t serialize : function() {\n\t return {\n\t title: this.$(\".title\").text(),\n\t start: this.$(\".start-page\").text(),\n\t end: this.$(\".end-page\").text()\n\t };\n\t }\n\t});\n\n*/\n\n/*\n@property template\n\nWhile templating for a view isn't a function provided directly by Backbone, it's often a nice convention to define a template function on your views. In this way, when rendering your view, you have convenient access to instance data. For example, using Underscore templates:\n\n\tvar LibraryView = Backbone.View.extend({\n\t\ttemplate: _.template(...)\n\t});\n\n@param {Any}data*/\n\n\n/*@method render\nThe default implementation of render is a no-op. Override this function with your code that renders the view template from model data, and updates this.el with the new HTML. A good convention is to return this at the end of render to enable chained calls.\n\n\tvar Bookmark = Backbone.View.extend({\n\t template: _.template(...),\n\t render: function() {\n\t this.$el.html(this.template(this.model.attributes));\n\t return this;\n\t }\n\t});\nBackbone is agnostic with respect to your preferred method of HTML templating. Your render function could even munge together an HTML string, or use document.createElement to generate a DOM tree. However, we suggest choosing a nice JavaScript templating library. Mustache.js, Haml-js, and Eco are all fine alternatives. Because Underscore.js is already on the page, _.template is available, and is an excellent choice if you prefer simple interpolated-JavaScript style templates.\n\nWhatever templating strategy you end up with, it's nice if you never have to put strings of HTML in your JavaScript. At DocumentCloud, we use Jammit in order to package up JavaScript templates stored in /app/views as part of our main core.js asset package.\n*/\n\n\n/*@method remove\n\nRemoves a view from the DOM, and calls stopListening to remove any bound events that the view has listenTo'd.\n\n*/\n\n/*\n@method delegateEvents\n\ndelegateEventsdelegateEvents([events]) \nUses jQuery's on function to provide declarative callbacks for DOM events within a view. If an events hash is not passed directly, uses this.events as the source. Events are written in the format {\"event selector\": \"callback\"}. The callback may be either the name of a method on the view, or a direct function body. Omitting the selector causes the event to be bound to the view's root element (this.el). By default, delegateEvents is called within the View's constructor for you, so if you have a simple events hash, all of your DOM events will always already be connected, and you will never have to call this function yourself.\n\nThe events property may also be defined as a function that returns an events hash, to make it easier to programmatically define your events, as well as inherit them from parent views.\n\nUsing delegateEvents provides a number of advantages over manually using jQuery to bind events to child elements during render. All attached callbacks are bound to the view before being handed off to jQuery, so when the callbacks are invoked, this continues to refer to the view object. When delegateEvents is run again, perhaps with a different events hash, all callbacks are removed and delegated afresh — useful for views which need to behave differently when in different modes.\n\nA view that displays a document in a search result might look something like this:\n\n\tvar DocumentView = Backbone.View.extend({\n\n\t events: {\n\t \"dblclick\" : \"open\",\n\t \"click .icon.doc\" : \"select\",\n\t \"contextmenu .icon.doc\" : \"showMenu\",\n\t \"click .show_notes\" : \"toggleNotes\",\n\t \"click .title .lock\" : \"editAccessLevel\",\n\t \"mouseover .title .date\" : \"showTooltip\"\n\t },\n\n\t render: function() {\n\t this.$el.html(this.template(this.model.attributes));\n\t return this;\n\t },\n\n\t open: function() {\n\t window.open(this.model.get(\"viewer_url\"));\n\t },\n\n\t select: function() {\n\t this.model.set({selected: true});\n\t },\n\n\t ...\n\n\t});\n\n@param events optional\n*/\n\n\n\n/*@method undelegateEvents\nRemoves all of the view's delegated events. Useful if you want to disable or remove a view from the DOM temporarily.\n*/\n\n//@filename {Foo} fileName /home/sg/git/short-jsdoc/vendor-jsdoc/backbonejs/backbone.js\n\n/*\n@module Backbone\n\n#About\nBackbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.\n\nThe project is hosted on GitHub, and the annotated source code is available, as well as an online test suite, an example application, a list of tutorials and a long list of real-world projects that use Backbone. Backbone is available for use under the MIT software license.\n\nYou can report bugs and discuss features on the GitHub issues page, on Freenode IRC in the #documentcloud channel, post questions to the Google Group, add pages to the wiki or send tweets to @documentcloud.\n\nBackbone is an open-source component of DocumentCloud.\n\n#Dependencies\nBackbone's only hard dependency is Underscore.js ( >= 1.5.0). For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery, and json2.js for older Internet Explorer support. (Mimics of the Underscore and jQuery APIs, such as Lo-Dash and Zepto, will also tend to work, with varying degrees of compatibility.)\n\n#Introduction\n\nWhen working on a web application that involves a lot of JavaScript, one of the first things you learn is to stop tying your data to the DOM. It's all too easy to create JavaScript applications that end up as tangled piles of jQuery selectors and callbacks, all trying frantically to keep data in sync between the HTML UI, your JavaScript logic, and the database on your server. For rich client-side applications, a more structured approach is often helpful.\n\nWith Backbone, you represent your data as Models, which can be created, validated, destroyed, and saved to the server. Whenever a UI action causes an attribute of a model to change, the model triggers a \"change\" event; all the Views that display the model's state can be notified of the change, so that they are able to respond accordingly, re-rendering themselves with the new information. In a finished Backbone app, you don't have to write the glue code that looks into the DOM to find an element with a specific id, and update the HTML manually — when the model changes, the views simply update themselves.\n\nPhilosophically, Backbone is an attempt to discover the minimal set of data-structuring (models and collections) and user interface (views and URLs) primitives that are generally useful when building web applications with JavaScript. In an ecosystem where overarching, decides-everything-for-you frameworks are commonplace, and many libraries require your site to be reorganized to suit their look, feel, and default behavior — Backbone should continue to be a tool that gives you the freedom to design the full experience of your web application.\n\nIf you're new here, and aren't yet quite sure what Backbone is for, start by browsing the list of Backbone-based projects.\n\n\n\n@class Backbone\n\n\n\n\n@method sync \n\nBackbone.sync is the function that Backbone calls every time it attempts to read or save a model to the server. By default, it uses jQuery.ajax to make a RESTful JSON request and returns a jqXHR. You can override it in order to use a different persistence strategy, such as WebSockets, XML transport, or Local Storage.\n\nThe method signature of Backbone.sync is sync(method, model, [options])\n\nmethod – the CRUD method (\"create\", \"read\", \"update\", or \"delete\")\nmodel – the model to be saved (or collection to be read)\noptions – success and error callbacks, and all other jQuery request options\nWith the default implementation, when Backbone.sync sends up a request to save a model, its attributes will be passed, serialized as JSON, and sent in the HTTP body with content-type application/json. When returning a JSON response, send down the attributes of the model that have been changed by the server, and need to be updated on the client. When responding to a \"read\" request from a collection (Collection#fetch), send down an array of model attribute objects.\n\nWhenever a model or collection begins a sync with the server, a \"request\" event is emitted. If the request completes successfully you'll get a \"sync\" event, and an \"error\" event if not.\n\nThe sync function may be overriden globally as Backbone.sync, or at a finer-grained level, by adding a sync function to a Backbone collection or to an individual model.\n\nThe default sync handler maps CRUD