Book Image

PhoneGap By Example

Book Image

PhoneGap By Example

Overview of this book

Table of Contents (17 chapters)
PhoneGap By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Saving the dressed photo into the application's folder


To save the picture in the application's folder ,we need to implement the store and model of the picture and some logic.

Defining the picture model and store

The picture model itself is very simple. Let's create it and put it under app/model/Picture.js:

Ext.define('Imaginary.model.Picture', {
    extend: 'Ext.data.Model',
    config: {
        fields: [
            { name: 'id', type: 'int' },
            { name: 'url', type: 'string' }
        ]
    }
});

Where:

  • id is the generated identifier in locaStorage

  • url is the path to the picture on the device

The store is a little different than the one for effects. Let's add the following lines of code in the app/store/Pictures.js file:

The Pictures.js store, is as follows:

Ext.define('Imaginary.store.Pictures',{
    extend:'Ext.data.Store',
    requires: ['Ext.data.proxy.LocalStorage', 'Imaginary.model.Picture'],
    config:{
        model:'Imaginary.model.Picture', 
        storeId: 'Pictures...