---
This tutorial is based on Intel XDK 1621
1) Create A New Project
1-1) Click PROJECTS
1-2) Click START A NEW PROJECT
1-3) Select START WITH A TEMPLATE and then select BLANK CORDOVA STARTER (LITE)
1-3) Enter Project Name
1-4) You should get Success message.
2) Add jQuery Mobile Template
2-1) Your project starts with basic files without jQuery Mobile files
The Design button is not functional at all.
2-2) Add a new html file, eg test.html
2-3) Select jQuery Framework
2-4) Add a button to the layout
2-4) jQuery Mobile library files will be automatically added to your project
2-5) Add the following lines to the index file (refer screenshot)
The Design button will automatically be activated
| 
<link rel="stylesheet" type="text/css" href="jqm/jquery.mobile-min.css"> 
<link rel="stylesheet" type="text/css" href="css/test_main.less.css" class="main-less"> 
… 
    <script type="application/javascript" src="lib/jquery.min.js"></script> 
    <script type="application/javascript" src="jqm/jquery.mobile-min.js" data-ver="0"></script> | 
2-6) If you clear up all comment codes, you would have a nice looking codes of around 36 lines only.
3) The app.ready event
3-1) The app.ready event defined in the file init-dev.js at line no.124 is used to indicate the state at which the app has initialized all device API. At this point, calls to device API is now functional.
3-2) Copy the codes from Cordova Sample Page and add to index page
| 
… 
<body> 
    <p>Hello, Cordova!</p> 
        <button onclick="capturePhoto();">Capture Photo</button> <br> 
    <button onclick="capturePhotoEdit();">Capture Editable Photo</button> <br> 
    <button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br> 
    <button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button><br> 
    <img style="display:none;width:60px;height:60px;" id="smallImage" src="" /> 
    <img style="display:none;" id="largeImage" src="" /> 
    <script> 
        var pictureSource;   // picture source 
        var destinationType; // sets the format of returned value        
        function onAppReady() { 
            if( navigator.splashscreen && navigator.splashscreen.hide ) {   // Cordova API detected 
                navigator.splashscreen.hide() ; 
            } 
            if( window.intel && intel.xdk && intel.xdk.device ) {           // Intel XDK device API detected, but... 
                if( intel.xdk.device.hideSplashScreen )                     // ...hideSplashScreen() is inside the base plugin 
                    intel.xdk.device.hideSplashScreen() ; 
            } 
            pictureSource=navigator.camera.PictureSourceType; 
            destinationType=navigator.camera.DestinationType; 
        } 
        document.addEventListener("app.Ready", onAppReady, false) ; 
    // Called when a photo is successfully retrieved 
    // 
    function onPhotoDataSuccess(imageData) { 
      // Uncomment to view the base64-encoded image data 
      // console.log(imageData); 
      // Get image handle 
      // 
      var smallImage = document.getElementById('smallImage'); 
      // Unhide image elements 
      // 
      smallImage.style.display = 'block'; 
      // Show the captured photo 
      // The inline CSS rules are used to resize the image 
      // 
      smallImage.src = "data:image/jpeg;base64," + imageData; 
    } 
    // Called when a photo is successfully retrieved 
    // 
    function onPhotoURISuccess(imageURI) { 
      // Uncomment to view the image file URI 
      // console.log(imageURI); 
      // Get image handle 
      // 
      var largeImage = document.getElementById('largeImage'); 
      // Unhide image elements 
      // 
      largeImage.style.display = 'block'; 
      // Show the captured photo 
      // The inline CSS rules are used to resize the image 
      // 
      largeImage.src = imageURI; 
    } 
    // A button will call this function 
    // 
    function capturePhoto() { 
      // Take picture using device camera and retrieve image as base64-encoded string 
      navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, 
        destinationType: destinationType.DATA_URL }); 
    } 
    // A button will call this function 
    // 
    function capturePhotoEdit() { 
      // Take picture using device camera, allow edit, and retrieve image as base64-encoded string 
      navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true, 
        destinationType: destinationType.DATA_URL }); 
    } 
    // A button will call this function 
    // 
    function getPhoto(source) { 
      // Retrieve image file location from specified source 
      navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
        destinationType: destinationType.FILE_URI, 
        sourceType: source }); 
    } 
    // Called if something bad happens. 
    // 
    function onFail(message) { 
      alert('Failed because: ' + message); 
    } 
    </script> 
</body> 
</html> | 
3-3) Add Camera Plug-in
3-5) Emulator
You can only view the User Interface but you cannot test the camera function.
This project must be compiled and installed into a real device.
 
I dont see Select jQuery Framework in the latest release? is this article relevant. how do i do this in later intel xdk IDE
ReplyDelete