Class Index | File Index

## Classes

- _global_
- M
- M.ActionSheetDialogView
- M.AlertDialogView
- M.Application
- M.Base64
- M.ButtonGroupView
- M.ButtonView
- M.ConfirmDialogView
- M.ContainerView
- M.Controller
- M.Cypher
- M.DataProvider
- M.Date
- M.DateValidator
- M.EmailValidator
- M.Environment
- M.EventDispatcher
- M.FormView
- M.GridView
- M.I18N
- M.ImageView
- M.LabelView
- M.ListItemView
- M.ListView
- M.LoaderView
- M.LocalStorageProvider
- M.Logger
- M.Math
- M.Model
- M.ModelAttribute
- M.ModelRegistry
- M.NotMinusValidator
- M.NumberValidator
- M.Object
- M.Observable
- M.PageView
- M.PhoneValidator
- M.PresenceValidator
- M.RecordManager
- M.RemoteStorageProvider
- M.Request
- M.ScrollView
- M.SearchBarView
- M.SelectionListItemView
- M.SelectionListView
- M.SHA256
- M.TabBarItemView
- M.TabBarView
- M.TextFieldView
- M.ToggleView
- M.ToolbarView
- M.UrlValidator
- M.Validator
- M.View
- M.ViewManager
- M.WebSqlProvider

# Class M.LocalStorageProvider

Extends M.DataProvider.
Encapsulates access to LocalStorage (in-browser key value store). LocalStorage is an in-browser key-value store to persist data. This data provider persists model records as JSON strings with their name and id as key. When fetching these strings from storage, their automatically converted in their corresponding model records.
Defined in: local_storage.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| M.LocalStorageProvider()

Field Summary
Field Attributes | Field Name and Description
--- | ---
| type The type of this object.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| allKeys(obj) Returns all keys for model defined by modelName.
| buildRecord(key, obj) Fetches a record from LocalStorage and checks whether automatic parsing by JSON.parse set the elements right.
| del(obj) deletes a model from the local storage key defines which one to delete e.g.
| find(The) Finds all models of type defined by modelName that match a key or a simple query.
| findAll(obj) Returns all models defined by modelName.
| findByKey(The) Finds a record identified by the key.
| save(that) Saves a model record to the local storage The key is the model record's name combined with id, value is stringified object e.g.

Methods borrowed from class M.DataProvider:
  check
Methods borrowed from class M.Object:
  bindToCaller, create, destroy, extend, get, include, set

Class Detail
M.LocalStorageProvider()
Field Detail
{String} type
The type of this object.
Method Detail
{Object} allKeys(obj)
Returns all keys for model defined by modelName.

Parameters:
{Object} obj
  The param obj, includes model

Returns:
  {Object} keys All keys for model records in LocalStorage for a certain model identified by the model's name.

{Object} buildRecord(key, obj)
Fetches a record from LocalStorage and checks whether automatic parsing by JSON.parse set the elements right. Means: check whether resulting object's properties have the data type define by their model attribute object. E.g. String containing a date is automatically transfered into a M.Date object when the model attribute has the data type 'Date' set for this property.

Parameters:
{String} key
  The key to fetch the element from LocalStorage
{Object} obj
  The param object, includes model

Returns:
  {Object} record The record object. Includes all model record properties with correctly set data types.

{Boolean} del(obj)
deletes a model from the local storage key defines which one to delete e.g. key: 'Note_123'

Parameters:
{Object} obj
  The param obj, includes model

Returns:
  {Boolean} Boolean indicating whether save was successful (YES|true) or not (NO|false).

{Object|Boolean} find(The)
Finds all models of type defined by modelName that match a key or a simple query. A simple query example: 'price < 2.21' Right now, no AND or OR joins possible, just one query constraint. If no query is passed, all models are returned by calling findAll()

Parameters:
{Object} The
  param object containing e.g. the query or the key.

Returns:
  {Object|Boolean} Returns an object if find is done with a key, an array of objects when a query is given or no parameter passed.

{Object} findAll(obj)
Returns all models defined by modelName. Models are saved with key: Modelname_ID, e.g. Note_123

Parameters:
{Object} obj
  The param obj, includes model

Returns:
  {Object} The array of fetched objects/model records. If no records the array is empty.

{Object|Boolean} findByKey(The)
Finds a record identified by the key.

Parameters:
{Object} The
  param object containing e.g. the query or the key.

Returns:
  {Object|Boolean} Returns an object identified by key, correctly built as a model record by calling or a boolean (NO|false) if no key is given or the key does not exist in LocalStorage. parameter passed.

{Boolean} save(that)
Saves a model record to the local storage The key is the model record's name combined with id, value is stringified object e.g. Note_123 => '{ text: 'buy some food' }'

Parameters:
{Object} that
  (is a model).

Returns:
  {Boolean} Boolean indicating whether save was successful (YES|true) or not (NO|false).

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 08 2010 15:07:31 GMT+0100 (MEZ)