Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBCDBC071 for ; Mon, 7 May 2012 22:25:12 +0000 (UTC) Received: (qmail 99878 invoked by uid 500); 7 May 2012 22:25:12 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 99857 invoked by uid 500); 7 May 2012 22:25:12 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 99823 invoked by uid 99); 7 May 2012 22:25:12 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2012 22:25:12 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3E6B614998; Mon, 7 May 2012 22:25:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: mwbrooks@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/5] CB-652 Update spec/phonegap to spec/cordova Message-Id: <20120507222512.3E6B614998@tyr.zones.apache.org> Date: Mon, 7 May 2012 22:25:12 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/table_of_contents_spec/example_no_target.html ---------------------------------------------------------------------- diff --git a/spec/cordova/table_of_contents_spec/example_no_target.html b/spec/cordova/table_of_contents_spec/example_no_target.html new file mode 100644 index 0000000..f6d6179 --- /dev/null +++ b/spec/cordova/table_of_contents_spec/example_no_target.html @@ -0,0 +1,496 @@ + + + + + + + + + +PhoneGap API Documentation + + + + +
+

Accelerometer

+
+
+

Accelerometer

+ +
+

Captures device motion in the x, y, and z direction.

+
+ +

Methods

+ + +

Arguments

+ + +

Objects (Read-Only)

+ + +
+

accelerometer.getCurrentAcceleration

+ +

Get the current acceleration along the x, y, and z axis.

+ +
navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
+			
+ +

Description

+ +

The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current position. The accelerometer can detect 3D movement along the x, y, and z axis.

+ +

The acceleration is returned using the accelerometerSuccess callback function.

+ +

Supported Platforms

+ +
    +
  • iPhone
  • +
+

Quick Example

+ +
function onSuccess(acceleration) {
+			    alert('Acceleration X: ' + acceleration.x + '\n' +
+			          'Acceleration Y: ' + acceleration.y + '\n' +
+			          'Acceleration Z: ' + acceleration.z + '\n';
+			};
+
+			function onError() {
+			    alert('onError!');
+			};
+
+			navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
+			
+ +

Full Example

+ +
<!DOCTYPE html>
+			<html>
+			  <head>
+			    <title>Acceleration Example</title>
+
+			    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
+			    <script type="text/javascript" charset="utf-8">
+
+			    // Wait for PhoneGap to load
+			    //
+			    function onLoad() {
+			        document.addEventListener("deviceready", onDeviceReady, false);
+			    }
+
+			    // PhoneGap is ready
+			    //
+			    function onDeviceReady() {
+			        navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
+			    }
+
+			    // onSuccess: Get a snapshot of the current acceleration
+			    //
+			    function onSuccess(acceleration) {
+			        alert('Acceleration X: ' + acceleration.x + '\n' +
+			              'Acceleration Y: ' + acceleration.y + '\n' +
+			              'Acceleration Z: ' + acceleration.z + '\n');
+			    }
+
+			    // onError: Failed to get the acceleration
+			    //
+			    function onError() {
+			        alert('onError!');
+			    }
+
+			    </script>
+			  </head>
+			  <body onload="onLoad()">
+			    <h1>Example</h1>
+			    <p>getCurrentAcceleration</p>
+			  </body>
+			</html>
+			
+ +

iPhone Quirks

+ +
    +
  • iPhone doesn't have the concept of getting the current acceleration at any given point.
  • +
  • You must watch the acceleration and capture the data at given time intervals.
  • +
  • Thus, the getCurrentAcceleration function will give you the last value reported from a phoneGap watchAccelerometer call.
  • +
+
+

accelerometer.watchAcceleration

+ +

At a regular interval, get the acceleration along the x, y, and z axis.

+ +
var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
+			                                                       accelerometerError,
+			                                                       [accelerometerOptions]);
+			
+ +

Description

+ +

The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current position. The accelerometer can detect 3D movement along the x, y, and z axis.

+ +

The accelerometer.watchAcceleration gets the device's current acceleration at a regular interval. Each time the Acceleration is retrieved, the accelerometerSuccess callback function is executed. Specify the interval in milliseconds via the frequency parameter in the acceleratorOptions object.

+ +

The returned watch ID references references the accelerometer watch interval. The watch ID can be used with accelerometer.clearWatch to stop watching the accelerometer.

+ +

Supported Platforms

+ +
    +
  • iPhone
  • +
+

Quick Example

+ +
function onSuccess(acceleration) {
+			    alert('Acceleration X: ' + acceleration.x + '\n' +
+			          'Acceleration Y: ' + acceleration.y + '\n' +
+			          'Acceleration Z: ' + acceleration.z + '\n');
+			};
+
+			function onError() {
+			    alert('onError!');
+			};
+
+			var options = { frequency: 3000 };  // Update every 3 seconds
+
+			var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+			
+ +

Full Example

+ +
<!DOCTYPE html>
+			<html>
+			  <head>
+			    <title>Acceleration Example</title>
+
+			    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
+			    <script type="text/javascript" charset="utf-8">
+
+			    // The watch id references the current `watchAcceleration`
+			    var watchID = null;
+
+			    // Wait for PhoneGap to load
+			    //
+			    function onLoad() {
+			        document.addEventListener("deviceready", onDeviceReady, false);
+			    }
+
+			    // PhoneGap is ready
+			    //
+			    function onDeviceReady() {
+			        startWatch();
+			    }
+
+			    // Start watching the acceleration
+			    //
+			    function startWatch() {
+
+			        // Update acceleration every 3 seconds
+			        var options = { frequency: 3000 };
+
+			        watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+			    }
+
+			    // Stop watching the acceleration
+			    //
+			    function stopWatch() {
+			        if (watchID) {
+			            navigator.accelerometer.clearWatch(watchID);
+			            watchID = null;
+			        }
+			    }
+
+			    // onSuccess: Get a snapshot of the current acceleration
+			    //
+			    function onSuccess(acceleration) {
+			        var element = document.getElementById('accelerometer');
+			        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
+			                            'Acceleration Y: ' + acceleration.y + '<br />' +
+			                            'Acceleration Z: ' + acceleration.z + '<br />';
+			    }
+
+			    // onError: Failed to get the acceleration
+			    //
+			    function onError() {
+			        alert('onError!');
+			    }
+
+			    </script>
+			  </head>
+			  <body onload="onLoad()">
+			    <div id="accelerometer">Waiting for accelerometer...</div>
+			  </body>
+			</html>
+			
+ +

iPhone Quirks

+ +
    +
  • At the interval requested, PhoneGap will call the success callback function and pass the accelerometer results.
  • +
  • However, in requests to the device PhoneGap restricts the interval to minimum of every 40ms and a maximum of every 1000ms. +
      +
    • For example, if you request an interval of 3 seconds (3000ms), PhoneGap will request an interval of 1 second from the device but invoke the success callback at the requested interval of 3 seconds.
    • +
    +
  • +
+
+

accelerometer.clearWatch

+ +

Stop watching the Acceleration referenced by the watch ID parameter.

+ +
navigator.accelerometer.clearWatch(watchID);
+			
+ + +

Supported Platforms

+ +
    +
  • iPhone
  • +
+

Quick Example

+ +
var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+
+			// ... later on ...
+
+			navigator.accelerometer.clearWatch(watchID);
+			
+ +

Full Example

+ +
<!DOCTYPE html>
+			<html>
+			  <head>
+			    <title>Acceleration Example</title>
+
+			    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
+			    <script type="text/javascript" charset="utf-8">
+
+			    // The watch id references the current `watchAcceleration`
+			    var watchID = null;
+
+			    // Wait for PhoneGap to load
+			    //
+			    function onLoad() {
+			        document.addEventListener("deviceready", onDeviceReady, false);
+			    }
+
+			    // PhoneGap is ready
+			    //
+			    function onDeviceReady() {
+			        startWatch();
+			    }
+
+			    // Start watching the acceleration
+			    //
+			    function startWatch() {
+
+			        // Update acceleration every 3 seconds
+			        var options = { frequency: 3000 };
+
+			        watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+			    }
+
+			    // Stop watching the acceleration
+			    //
+			    function stopWatch() {
+			        if (watchID) {
+			            navigator.accelerometer.clearWatch(watchID);
+			            watchID = null;
+			        }
+			    }
+
+			    // onSuccess: Get a snapshot of the current acceleration
+			    //
+			    function onSuccess(acceleration) {
+			        var element = document.getElementById('accelerometer');
+			        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
+			                            'Acceleration Y: ' + acceleration.y + '<br />' +
+			                            'Acceleration Z: ' + acceleration.z + '<br />';
+			    }
+
+			    // onError: Failed to get the acceleration
+			    //
+			    function onError() {
+			        alert('onError!');
+			    }
+
+			    </script>
+			  </head>
+			  <body onload="onLoad()">
+			    <div id="accelerometer">Waiting for accelerometer...</div>
+			    <button onclick="stopWatch();">Stop Watching</button>
+			  </body>
+			</html>
+			
+ +
+

Acceleration

+ +

Contains Accelerometer data captured at a specific point in time.

+ +

Properties

+ +
    +
  • + x: Amount of motion on the x-axis. Range [0, 1] (Number)
  • +
  • + y: Amount of motion on the y-axis. Range [0, 1] (Number)
  • +
  • + z: Amount of motion on the z-axis. Range [0, 1] (Number)
  • +
  • + timestamp: Creation timestamp in milliseconds. (DOMTimeStamp)
  • +
+

Description

+ +

This object is created and populated by PhoneGap, and returned by an Accelerometer method.

+ +

Supported Platforms

+ +
    +
  • Untested
  • +
+

Quick Example

+ +
function onSuccess(acceleration) {
+			    alert('Acceleration X: ' + acceleration.x + '\n' +
+			          'Acceleration Y: ' + acceleration.y + '\n' +
+			          'Acceleration Z: ' + acceleration.z + '\n';
+			};
+
+			function onError() {
+			    alert('onError!');
+			};
+
+			navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
+			
+ +

Full Example

+ +
<!DOCTYPE html>
+			<html>
+			  <head>
+			    <title>Acceleration Example</title>
+
+			    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
+			    <script type="text/javascript" charset="utf-8">
+
+			    // Wait for PhoneGap to load
+			    //
+			    function onLoad() {
+			        document.addEventListener("deviceready", onDeviceReady, false);
+			    }
+
+			    // PhoneGap is ready
+			    //
+			    function onDeviceReady() {
+			        navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
+			    }
+
+			    // onSuccess: Get a snapshot of the current acceleration
+			    //
+			    function onSuccess() {
+			        alert('Acceleration X: ' + acceleration.x + '\n' +
+			              'Acceleration Y: ' + acceleration.y + '\n' +
+			              'Acceleration Z: ' + acceleration.z + '\n';
+			    }
+
+			    // onError: Failed to get the acceleration
+			    //
+			    function onError() {
+			        alert('onError!');
+			    }
+
+			    </script>
+			  </head>
+			  <body onload="onLoad()">
+			    <h1>Example</h1>
+			    <p>getCurrentAcceleration</p>
+			  </body>
+			</html>
+			
+ +
+

accelerometerSuccess

+ +

onSuccess callback function that provides the Acceleration information.

+ +
function(acceleration) {
+			    // Do something
+			}
+			
+ +

Parameters

+ +
    +
  • + acceleration: The acceleration at a single moment in time. (Acceleration)
  • +
+

Example

+ +
function onSuccess(acceleration) {
+			    alert('Acceleration X: ' + acceleration.x + '\n' +
+			          'Acceleration Y: ' + acceleration.y + '\n' +
+			          'Acceleration Z: ' + acceleration.z + '\n';
+			};
+			
+ +
+

accelerometerError

+ +

onError callback function for acceleration functions.

+ +
function() {
+			    // Handle the error
+			}
+			
+ +
+

accelerometerOptions

+ +

An optional parameter to customize the retrieval of the accelerometer.

+ +

Options

+ +
    +
  • + frequency: How often to retrieve the Acceleration in milliseconds. (Number) (Default: 10000)
  • +
+
+ + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/update_index_spec.rb ---------------------------------------------------------------------- diff --git a/spec/cordova/update_index_spec.rb b/spec/cordova/update_index_spec.rb new file mode 100644 index 0000000..7b28a4f --- /dev/null +++ b/spec/cordova/update_index_spec.rb @@ -0,0 +1,59 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +$:.unshift File.join(File.dirname(__FILE__), '..') +require 'spec_helpers' +require 'update_index' +require 'rubygems' +require 'nokogiri' + +describe UpdateIndex do + before :each do + directory = Helper::create_tmp_directory_assets(__FILE__) + @file = { + :input => File.join(directory, 'index.md.html'), + :output => File.join(directory, 'index.html') + } + @update_index = UpdateIndex.new + end + + it 'should skip all files but index.md.html' do + @update_index.run('index.md').should be_false + @update_index.run('index.html').should be_false + @update_index.run('_index.md.html').should be_false + end + + it 'should rename the title' do + Nokogiri::HTML( File.read @file[:input] ).css('#subheader > h1')[0].content.should_not == @update_index.header_title + @update_index.run @file[:input] + Nokogiri::HTML( File.read @file[:output] ).css('#subheader > h1')[0].content.should == @update_index.header_title + end + + it 'should rename the file' do + File.exists?(@file[:input]).should be_true + File.exists?(@file[:output]).should be_false + + @update_index.run @file[:input] + + File.exists?(@file[:input]).should be_false + File.exists?(@file[:output]).should be_true + end + + after :all do + Helper::remove_tmp_directory + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/update_index_spec/index.md.html ---------------------------------------------------------------------- diff --git a/spec/cordova/update_index_spec/index.md.html b/spec/cordova/update_index_spec/index.md.html new file mode 100644 index 0000000..5a81724 --- /dev/null +++ b/spec/cordova/update_index_spec/index.md.html @@ -0,0 +1,112 @@ + + + + + + + + + + + PhoneGap API Documentation + + + + +
+

Geolocation

+ +
+ + + +
+
+

API Reference

+
    +
  • +

    Accelerometer

    + Tap into the device's motion sensor. +
  • +
  • +

    Camera

    + Capture photo using the device's camera. +
  • +
  • +

    Capture

    + Capture media using device applications. +
  • +
  • +

    Device

    + Gather device specific information. +
  • +
  • +

    Events

    + Hook into native events through JavaScript. +
  • +
  • +

    File

    + Hook into native file system through JavaScript. +
  • +
  • +

    Geolocation

    + Make your application location aware. +
  • +
  • +

    Media

    + Record and play back audio. +
  • +
  • +

    Notification

    + Visual, audible, and tactile device notifications. +
  • +
  • +

    Storage

    + Hook into the native devices storage options. +
  • +
+
+ +
+ + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/update_keyword_index_spec.rb ---------------------------------------------------------------------- diff --git a/spec/cordova/update_keyword_index_spec.rb b/spec/cordova/update_keyword_index_spec.rb new file mode 100644 index 0000000..96f855c --- /dev/null +++ b/spec/cordova/update_keyword_index_spec.rb @@ -0,0 +1,66 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +$:.unshift File.join(File.dirname(__FILE__), '..') +require 'spec_helpers' +require 'update_keyword_index' +require 'rubygems' +require 'nokogiri' + +describe UpdateKeywordIndex do + before :each do + directory = Helper::create_tmp_directory_assets(__FILE__) + @file = File.join(directory, '_index.html') + @update_keyword = UpdateKeywordIndex.new + end + + it 'should skip all files but _index.html' do + # All false + @update_keyword.run('index.html').should be_false + @update_keyword.run('index.htm').should be_false + @update_keyword.run('_index.htm').should be_false + @update_keyword.run('index.md.html').should be_false + end + + it 'should rename the title' do + Nokogiri::HTML(File.read @file).css('#subheader > h1' )[0].content.should_not == @update_keyword.header_title + @update_keyword.run @file + Nokogiri::HTML(File.read @file).css('#subheader > h1' )[0].content.should == @update_keyword.header_title + end + + it 'should rename the h1' do + Nokogiri::HTML(File.read @file).css('#content > h1')[0].content.should_not == @update_keyword.content_title + @update_keyword.run @file + Nokogiri::HTML(File.read @file).css('#content > h1')[0].content.should == @update_keyword.content_title + end + + it 'should remove the
' do + Nokogiri::HTML(File.read @file).css('#content > hr').should have_at_least(1).items + @update_keyword.run @file + Nokogiri::HTML(File.read @file).css('#content > hr').should have(0).items + end + + it 'should update references from index.md.html to index.html' do + Nokogiri::HTML(File.read @file).to_html.scan('index.md.html').length.should_not == 0 + @update_keyword.run @file + Nokogiri::HTML(File.read @file).to_html.scan('index.md.html').length.should == 0 + end + + after :all do + Helper::remove_tmp_directory + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/update_keyword_index_spec/_index.html ---------------------------------------------------------------------- diff --git a/spec/cordova/update_keyword_index_spec/_index.html b/spec/cordova/update_keyword_index_spec/_index.html new file mode 100644 index 0000000..ac5f59a --- /dev/null +++ b/spec/cordova/update_keyword_index_spec/_index.html @@ -0,0 +1,155 @@ + + + + + + + + + +PhoneGap API Documentation + + + + +
+

Index

+ + +
+ + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/yaml_front_matter_spec.rb ---------------------------------------------------------------------- diff --git a/spec/cordova/yaml_front_matter_spec.rb b/spec/cordova/yaml_front_matter_spec.rb new file mode 100644 index 0000000..74e969e --- /dev/null +++ b/spec/cordova/yaml_front_matter_spec.rb @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +$:.unshift File.join(File.dirname(__FILE__), '..') +require 'spec_helpers' +require 'yaml_front_matter' + +describe YamlFrontMatter do + before :each do + directory = Helper::create_tmp_directory_assets(__FILE__) + @file = { + :yaml => File.join(directory, 'has_yaml.md'), + :no_yaml => File.join(directory, 'no_yaml.md') + } + @yaml_front_matter = YamlFrontMatter.new + end + + it 'should skip files with no YAML Front Matter' do + expected_data = File.read(@file[:no_yaml]) + @yaml_front_matter.run(@file[:no_yaml]).should == {} + actual_data = File.read(@file[:no_yaml]) + + actual_data.should == expected_data + end + + it 'should parse files with YAML Front Matter' do + @yaml_front_matter.run(@file[:yaml]).should == { + 'platforms' => 'Android, BlackBerry, iOS', + 'type' => 'Function' + } + end + + it 'should strip YAML Front Matter from the file' do + File.read(@file[:yaml]).should match(/\A\W+/) + @yaml_front_matter.run(@file[:yaml]) + File.read(@file[:yaml]).should_not match(/\A\W+/) # No whitespace + end + + after :all do + Helper::remove_tmp_directory + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/yaml_front_matter_spec/has_yaml.md ---------------------------------------------------------------------- diff --git a/spec/cordova/yaml_front_matter_spec/has_yaml.md b/spec/cordova/yaml_front_matter_spec/has_yaml.md new file mode 100644 index 0000000..6f3e750 --- /dev/null +++ b/spec/cordova/yaml_front_matter_spec/has_yaml.md @@ -0,0 +1,13 @@ +--- +platforms: Android, BlackBerry, iOS +type: Function +--- + + + + + +PhoneGap +======== + +It's a fun place to be \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/cordova/yaml_front_matter_spec/no_yaml.md ---------------------------------------------------------------------- diff --git a/spec/cordova/yaml_front_matter_spec/no_yaml.md b/spec/cordova/yaml_front_matter_spec/no_yaml.md new file mode 100644 index 0000000..d8b5837 --- /dev/null +++ b/spec/cordova/yaml_front_matter_spec/no_yaml.md @@ -0,0 +1,4 @@ +PhoneGap II +=========== + +The return of the system admin. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/add_title_spec.rb ---------------------------------------------------------------------- diff --git a/spec/phonegap/add_title_spec.rb b/spec/phonegap/add_title_spec.rb deleted file mode 100644 index 8214eb0..0000000 --- a/spec/phonegap/add_title_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -$: << File.join(File.dirname(__FILE__), '..') -$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'cordova') -require 'spec_helpers' -require 'add_title' -require 'nokogiri' # Nokogiri may not be the best way to test this suite. Any thoughts? - -describe AddTitle do - # Create a fresh copy of the test file for each test run - before :all do - tmp_directory = Helper::create_tmp_directory_assets(__FILE__) - @file = { - :normal => File.join(tmp_directory, 'example.html'), - :no_source => File.join(tmp_directory, 'example_no_source.html'), - :no_target => File.join(tmp_directory, 'example_no_target.html') - } - @add_title = AddTitle.new - end - - it 'should set the title' do - @add_title.run(@file[:normal]).should == 'Accelerometer' - Nokogiri::HTML(File.read @file[:normal]).css('#subheader > h1')[0].content.should == 'Accelerometer' - end - - it 'should skip files with no source title' do - @add_title.run(@file[:no_source]).should be_nil - end - - it 'should skip files with no target title' do - @add_title.run(@file[:no_target]).should be_nil - end - - after :all do - Helper::remove_tmp_directory - end -end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/add_title_spec/example.html ---------------------------------------------------------------------- diff --git a/spec/phonegap/add_title_spec/example.html b/spec/phonegap/add_title_spec/example.html deleted file mode 100644 index 9918a71..0000000 --- a/spec/phonegap/add_title_spec/example.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - - - - - PhoneGap API Documentation - - - - -
-

[ Object Title Goes Here ]

- - - -
- - - -
-

Accelerometer

- -
-

Captures device motion in the x, y, and z direction.

-
- -

Methods

- - - -

Arguments

- - - -

Objects (Read-Only)

- - - -
- -

accelerometer.getCurrentAcceleration

- -

Get the current acceleration along the x, y, and z axis.

- -
navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
-
- -

Description

- -

The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current position. The accelerometer can detect 3D movement along the x, y, and z axis.

- -

The acceleration is returned using the accelerometerSuccess callback function.

- -

Supported Platforms

- -
    -
  • iPhone
  • -
- -

Quick Example

- -
function onSuccess(acceleration) {
-    alert('Acceleration X: ' + acceleration.x + '\n' +
-          'Acceleration Y: ' + acceleration.y + '\n' +
-          'Acceleration Z: ' + acceleration.z + '\n';
-};
-
-function onError() {
-    alert('onError!');
-};
-
-navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-
- -

Full Example

- -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-                      "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-  <head>
-    <title>Acceleration Example</title>
-
-    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
-    <script type="text/javascript" charset="utf-8">
-
-    // Wait for PhoneGap to load
-    //
-    function onLoad() {
-        document.addEventListener("deviceready", onDeviceReady, false);
-    }
-
-    // PhoneGap is ready
-    //
-    function onDeviceReady() {
-        navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-    }
-
-    // onSuccess: Get a snapshot of the current acceleration
-    //
-    function onSuccess(acceleration) {
-        alert('Acceleration X: ' + acceleration.x + '\n' +
-              'Acceleration Y: ' + acceleration.y + '\n' +
-              'Acceleration Z: ' + acceleration.z + '\n');
-    }
-
-    // onError: Failed to get the acceleration
-    //
-    function onError() {
-        alert('onError!');
-    }
-
-    </script>
-  </head>
-  <body onload="onLoad()">
-    <h1>Example</h1>
-    <p>getCurrentAcceleration</p>
-  </body>
-</html>
-
- -

iPhone Quirks

- -
    -
  • iPhone doesn't have the concept of getting the current acceleration at any given point.
  • -
  • You must watch the acceleration and capture the data at given time intervals.
  • -
  • Thus, the getCurrentAcceleration function will give you the last value reported from a phoneGap watchAccelerometer call.
  • -
- -
- -

accelerometer.watchAcceleration

- -

At a regular interval, get the acceleration along the x, y, and z axis.

- -
var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
-                                                       accelerometerError,
-                                                       [accelerometerOptions]);
-
- -

Description

- -

The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current position. The accelerometer can detect 3D movement along the x, y, and z axis.

- -

The accelerometer.watchAcceleration gets the device's current acceleration at a regular interval. Each time the Acceleration is retrieved, the accelerometerSuccess callback function is executed. Specify the interval in milliseconds via the frequency parameter in the acceleratorOptions object.

- -

The returned watch ID references references the accelerometer watch interval. The watch ID can be used with accelerometer.clearWatch to stop watching the accelerometer.

- -

Supported Platforms

- -
    -
  • iPhone
  • -
- -

Quick Example

- -
function onSuccess(acceleration) {
-    alert('Acceleration X: ' + acceleration.x + '\n' +
-          'Acceleration Y: ' + acceleration.y + '\n' +
-          'Acceleration Z: ' + acceleration.z + '\n');
-};
-
-function onError() {
-    alert('onError!');
-};
-
-var options = { frequency: 3000 };  // Update every 3 seconds
-
-var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
-
- -

Full Example

- -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-                      "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-  <head>
-    <title>Acceleration Example</title>
-
-    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
-    <script type="text/javascript" charset="utf-8">
-
-    // The watch id references the current `watchAcceleration`
-    var watchID = null;
-
-    // Wait for PhoneGap to load
-    //
-    function onLoad() {
-        document.addEventListener("deviceready", onDeviceReady, false);
-    }
-
-    // PhoneGap is ready
-    //
-    function onDeviceReady() {
-        startWatch();
-    }
-
-    // Start watching the acceleration
-    //
-    function startWatch() {
-
-        // Update acceleration every 3 seconds
-        var options = { frequency: 3000 };
-
-        watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
-    }
-
-    // Stop watching the acceleration
-    //
-    function stopWatch() {
-        if (watchID) {
-            navigator.accelerometer.clearWatch(watchID);
-            watchID = null;
-        }
-    }
-
-    // onSuccess: Get a snapshot of the current acceleration
-    //
-    function onSuccess(acceleration) {
-        var element = document.getElementById('accelerometer');
-        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
-                            'Acceleration Y: ' + acceleration.y + '<br />' +
-                            'Acceleration Z: ' + acceleration.z + '<br />';
-    }
-
-    // onError: Failed to get the acceleration
-    //
-    function onError() {
-        alert('onError!');
-    }
-
-    </script>
-  </head>
-  <body onload="onLoad()">
-    <div id="accelerometer">Waiting for accelerometer...</div>
-  </body>
-</html>
-
- -

iPhone Quirks

- -
    -
  • At the interval requested, PhoneGap will call the success callback function and pass the accelerometer results.
  • -
  • However, in requests to the device PhoneGap restricts the interval to minimum of every 40ms and a maximum of every 1000ms. -
      -
    • For example, if you request an interval of 3 seconds (3000ms), PhoneGap will request an interval of 1 second from the device but invoke the success callback at the requested interval of 3 seconds.
    • -
  • -
- -
- -

accelerometer.clearWatch

- -

Stop watching the Acceleration referenced by the watch ID parameter.

- -
navigator.accelerometer.clearWatch(watchID);
-
- - - -

Supported Platforms

- -
    -
  • iPhone
  • -
- -

Quick Example

- -
var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
-
-// ... later on ...
-
-navigator.accelerometer.clearWatch(watchID);
-
- -

Full Example

- -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-                      "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-  <head>
-    <title>Acceleration Example</title>
-
-    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
-    <script type="text/javascript" charset="utf-8">
-
-    // The watch id references the current `watchAcceleration`
-    var watchID = null;
-
-    // Wait for PhoneGap to load
-    //
-    function onLoad() {
-        document.addEventListener("deviceready", onDeviceReady, false);
-    }
-
-    // PhoneGap is ready
-    //
-    function onDeviceReady() {
-        startWatch();
-    }
-
-    // Start watching the acceleration
-    //
-    function startWatch() {
-
-        // Update acceleration every 3 seconds
-        var options = { frequency: 3000 };
-
-        watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
-    }
-
-    // Stop watching the acceleration
-    //
-    function stopWatch() {
-        if (watchID) {
-            navigator.accelerometer.clearWatch(watchID);
-            watchID = null;
-        }
-    }
-
-    // onSuccess: Get a snapshot of the current acceleration
-    //
-    function onSuccess(acceleration) {
-        var element = document.getElementById('accelerometer');
-        element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
-                            'Acceleration Y: ' + acceleration.y + '<br />' +
-                            'Acceleration Z: ' + acceleration.z + '<br />';
-    }
-
-    // onError: Failed to get the acceleration
-    //
-    function onError() {
-        alert('onError!');
-    }
-
-    </script>
-  </head>
-  <body onload="onLoad()">
-    <div id="accelerometer">Waiting for accelerometer...</div>
-    <button onclick="stopWatch();">Stop Watching</button>
-  </body>
-</html>
-
- -
- -

Acceleration

- -

Contains Accelerometer data captured at a specific point in time.

- -

Properties

- -
    -
  • x: Amount of motion on the x-axis. Range [0, 1] (Number)
  • -
  • y: Amount of motion on the y-axis. Range [0, 1] (Number)
  • -
  • z: Amount of motion on the z-axis. Range [0, 1] (Number)
  • -
  • timestamp: Creation timestamp in milliseconds. (DOMTimeStamp)
  • -
- -

Description

- -

This object is created and populated by PhoneGap, and returned by an Accelerometer method.

- -

Supported Platforms

- -
    -
  • Untested
  • -
- -

Quick Example

- -
function onSuccess(acceleration) {
-    alert('Acceleration X: ' + acceleration.x + '\n' +
-          'Acceleration Y: ' + acceleration.y + '\n' +
-          'Acceleration Z: ' + acceleration.z + '\n';
-};
-
-function onError() {
-    alert('onError!');
-};
-
-navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-
- -

Full Example

- -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-                      "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-  <head>
-    <title>Acceleration Example</title>
-
-    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
-    <script type="text/javascript" charset="utf-8">
-
-    // Wait for PhoneGap to load
-    //
-    function onLoad() {
-        document.addEventListener("deviceready", onDeviceReady, false);
-    }
-
-    // PhoneGap is ready
-    //
-    function onDeviceReady() {
-        navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-    }
-
-    // onSuccess: Get a snapshot of the current acceleration
-    //
-    function onSuccess() {
-        alert('Acceleration X: ' + acceleration.x + '\n' +
-              'Acceleration Y: ' + acceleration.y + '\n' +
-              'Acceleration Z: ' + acceleration.z + '\n';
-    }
-
-    // onError: Failed to get the acceleration
-    //
-    function onError() {
-        alert('onError!');
-    }
-
-    </script>
-  </head>
-  <body onload="onLoad()">
-    <h1>Example</h1>
-    <p>getCurrentAcceleration</p>
-  </body>
-</html>
-
- -
- -

accelerometerSuccess

- -

onSuccess callback function that provides the Acceleration information.

- -
function(acceleration) {
-    // Do something
-}
-
- -

Parameters

- -
    -
  • acceleration: The acceleration at a single moment in time. (Acceleration)
  • -
- -

Example

- -
function onSuccess(acceleration) {
-    alert('Acceleration X: ' + acceleration.x + '\n' +
-          'Acceleration Y: ' + acceleration.y + '\n' +
-          'Acceleration Z: ' + acceleration.z + '\n';
-};
-
- -
- -

accelerometerError

- -

onError callback function for acceleration functions.

- -
function() {
-    // Handle the error
-}
-
- -
- -

accelerometerOptions

- -

An optional parameter to customize the retrieval of the accelerometer.

- -

Options

- -
    -
  • frequency: How often to retrieve the Acceleration in milliseconds. (Number) (Default: 10000)
  • -
- -
- - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/add_title_spec/example_no_source.html ---------------------------------------------------------------------- diff --git a/spec/phonegap/add_title_spec/example_no_source.html b/spec/phonegap/add_title_spec/example_no_source.html deleted file mode 100644 index 5b60058..0000000 --- a/spec/phonegap/add_title_spec/example_no_source.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - PhoneGap API Documentation - - -
-

[ Object Title Goes Here ]

-
- - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/add_title_spec/example_no_target.html ---------------------------------------------------------------------- diff --git a/spec/phonegap/add_title_spec/example_no_target.html b/spec/phonegap/add_title_spec/example_no_target.html deleted file mode 100644 index 4610238..0000000 --- a/spec/phonegap/add_title_spec/example_no_target.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - PhoneGap API Documentation - - -
-

Accelerometer

-
- - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/jodoc_spec.rb ---------------------------------------------------------------------- diff --git a/spec/phonegap/jodoc_spec.rb b/spec/phonegap/jodoc_spec.rb deleted file mode 100644 index 4efe9c6..0000000 --- a/spec/phonegap/jodoc_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -$:.unshift File.join(File.dirname(__FILE__), '..') -require 'spec_helpers' -require 'jodoc' - -describe JoDoc do - before :all do - @tmp_public_directory = Helper::tmp_public_directory - DocsGenerator.new(Helper::create_tmp_directory_assets, @tmp_public_directory).run - end - - it 'should run on a validate directory' do - File.directory?(@tmp_public_directory).should be_true - end - - it 'should not run on a non-existent directory' do - bad_input_directory = File.expand_path File.join(File.dirname(__FILE__), 'hello', 'world') - lambda { JoDoc.new bad_input_directory, @tmp_public_directory }.should raise_exception - end - - it 'should generate HTML assets from Markdown' do - File.exists?(File.join(@tmp_public_directory, 'en', 'edge', 'phonegap_accelerometer_accelerometer.md.html')).should be_true - end - - after :all do - Helper::remove_tmp_directory - end -end http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/e0d6b692/spec/phonegap/prettify_spec.rb ---------------------------------------------------------------------- diff --git a/spec/phonegap/prettify_spec.rb b/spec/phonegap/prettify_spec.rb deleted file mode 100644 index 481c019..0000000 --- a/spec/phonegap/prettify_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -$: << File.join(File.dirname(__FILE__), '..', '..', 'lib') -$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'cordova') -require 'prettify' -require 'spec_helpers' - -describe Prettify do - before :each do - directory = Helper::create_tmp_directory_assets(__FILE__) - @file = { - :normal => File.join(directory, 'example.html'), - } - @prettify = Prettify.new - end - - it 'should find some code blocks' do - code_tags = @prettify.run @file[:normal] - code_tags.should have_at_least(1).item - end - - it 'should add the prettyprint class to each code block' do - @prettify.run @file[:normal] - - doc = Nokogiri::HTML(File.read @file[:normal]) - doc.css('#content pre.prettyprint').should have_at_least(1).item - end - - after :all do - Helper::remove_tmp_directory - end -end \ No newline at end of file