angular-pixlive
Advanced tools
Comparing version 1.0.5 to 1.0.7
{ | ||
"name": "angular-pixlive", | ||
"version": "1.0.5", | ||
"version": "1.0.7", | ||
"homepage": "http://www.pixlive.info", | ||
@@ -32,9 +32,14 @@ "authors": [ | ||
"devDependencies": { | ||
"grunt": "~0.4.5", | ||
"grunt-contrib-concat": "~0.5.1", | ||
"grunt-contrib-uglify": "~0.9.1", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-contrib-cssmin": "~0.12.2", | ||
"grunt-contrib-clean": "~0.6.0" | ||
"angular-template": "2.0.7", | ||
"angular-jsdoc": "1.4.1", | ||
"canonical-path": "0.0.2", | ||
"grunt": "1.0.1", | ||
"grunt-contrib-clean": "1.0.0", | ||
"grunt-contrib-concat": "1.0.0", | ||
"grunt-contrib-cssmin": "1.0.0", | ||
"grunt-contrib-uglify": "1.0.0", | ||
"grunt-contrib-watch": "1.0.0", | ||
"grunt-jsdoc": "2.0.0", | ||
"jsdoc": "3.4.0" | ||
} | ||
} |
@@ -6,3 +6,3 @@ module.exports = function(grunt) { | ||
clean: ["js/PixLive.bundle.js", "js/PixLive.bundle.min.js"], | ||
clean: ["js/PixLive.bundle.js", "js/PixLive.bundle.min.js", "build"], | ||
@@ -25,3 +25,18 @@ concat: { | ||
} | ||
}, | ||
jsdoc: { | ||
dist: { | ||
src: ['js'], | ||
options: { | ||
destination: 'build/docs', | ||
configure: 'node_modules/angular-jsdoc/common/conf.json', | ||
template: 'node_modules/angular-jsdoc/angular-template', | ||
tutorial: 'tutorials', | ||
readme: './README.md' | ||
} | ||
} | ||
} | ||
}); | ||
@@ -33,7 +48,15 @@ | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-jsdoc'); | ||
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal. | ||
grunt.registerTask('default', [ | ||
'clean', 'concat', 'uglify' | ||
'clean', 'jsdoc', 'concat', 'uglify' | ||
]); | ||
grunt.registerTask('test', [ | ||
'default' | ||
], function() { | ||
// Todo | ||
}); | ||
}; |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -5,0 +5,0 @@ */ |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -11,4 +11,4 @@ */ | ||
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -20,2 +20,28 @@ */ | ||
pixliveModule | ||
/** | ||
* @ngdoc directive | ||
* @name pxlView | ||
* @memberof pixlive | ||
* @param {service} $timeout Angular $timeout service | ||
* @param {service} $ionicPosition Ionic $ionicPosition service | ||
* @param {service} $ionicPlatform Ionic $ionicPlatform service | ||
* @param {service} $ionicBackdrop Ionic $ionicBackdrop service | ||
* @restrict E | ||
* | ||
* @description | ||
* Add an augmented reality view to your Ionic app. | ||
* | ||
* **Notice**: You should minimize the number of AR view included into your app to the minimum as this is CPU resource intensive. | ||
* You should also avoid having two AR views visible at the same time as this will create unexpected behaviors. | ||
* | ||
* **Warning**: This view has to be inside an `ion-view` element whose background has been set to transparent. Failing to do so will make the AR view invisible. | ||
* | ||
* @example | ||
* <ion-view view-title="AR" style="background-color: transparent !important;"> | ||
* <pxl-view> | ||
* <!-- Any overlay you want --> | ||
* </pxl-view> | ||
* </ion-view> | ||
*/ | ||
.directive('pxlView', [ | ||
@@ -216,3 +242,3 @@ '$timeout', | ||
// Call the original with the output prepended with formatted timestamp | ||
// Call the original method | ||
retainFn.apply(null, args) | ||
@@ -226,3 +252,3 @@ | ||
// Call the original with the output prepended with formatted timestamp | ||
// Call the original method | ||
releaseFn.apply(null, args) | ||
@@ -241,6 +267,66 @@ | ||
} | ||
]).config(["$provide", | ||
function($provide) { | ||
$provide.decorator('$ionicModal', ["$delegate","$q", | ||
function($delegate,$q) { | ||
// Save the original $log.show() | ||
var fromTemplate = $delegate.fromTemplate; | ||
var fromTemplateUrl = $delegate.fromTemplateUrl; | ||
var overrideShowHide = function (ret) { | ||
// Save old methods | ||
ret.showOld = ret.show; | ||
ret.hideOld = ret.hide; | ||
ret.show=function() { | ||
ionic.trigger('transfer.shown', { | ||
target: window | ||
}); | ||
var args2 = [].slice.call(arguments); | ||
return this.showOld.apply(this, args2); | ||
}; | ||
ret.hide=function() { | ||
ionic.trigger('transfer.hidden', { | ||
target: window | ||
}); | ||
var args2 = [].slice.call(arguments); | ||
return this.hideOld.apply(this, args2); | ||
}; | ||
}; | ||
$delegate.fromTemplate = function() { | ||
var args = [].slice.call(arguments); | ||
var ret = fromTemplate.apply(null, args); | ||
overrideShowHide(ret); | ||
return ret; | ||
}; | ||
$delegate.fromTemplateUrl = function() { | ||
var args = [].slice.call(arguments); | ||
var deferred = $q.defer(); | ||
fromTemplateUrl.apply(null, args).then(function(modal) { | ||
overrideShowHide(modal); | ||
deferred.resolve(modal); | ||
}, function(err) { | ||
deferred.reject(err); | ||
}); | ||
return deferred.promise; | ||
}; | ||
return $delegate; | ||
} | ||
]); | ||
} | ||
]); | ||
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -255,2 +341,13 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlRemoteController | ||
* @param {service} $ionicPlatform The Ionic Platform helper | ||
* @param {service} $q Angular promise service | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @description | ||
* Manage and trigger PixLive Maker content synchronization with the app. | ||
*/ | ||
.factory('PxlRemoteController', [ | ||
@@ -266,2 +363,12 @@ '$ionicPlatform', | ||
return { | ||
/** | ||
* Start an asynchronous content synchronization with PixLive Maker backend | ||
* | ||
* **Warning**: Only one synchronization can be started at a time. | ||
* | ||
* @memberof PxlRemoteController | ||
* @param {string[]} tags The array of tags to start the synchronization with. Pass an empty array for synchronizing your app with all the available content. | ||
* @returns {Promise} The Angular promise that can be used for checking asynchronously the result of the call. | ||
*/ | ||
synchronize: function(tags) { | ||
@@ -300,4 +407,4 @@ var deferred = $q.defer(); | ||
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -312,2 +419,12 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlController | ||
* @param {service} $ionicPlatform The Ionic Platform helper | ||
* @param {service} $q Angular promise service | ||
* @description | ||
* Exposes PixLive SDK methods using an angular-like service | ||
*/ | ||
.factory('PxlController', [ | ||
@@ -322,2 +439,11 @@ '$ionicPlatform', | ||
return { | ||
/** | ||
* Display the PixLive SDK notification list over the Ionic app. | ||
* If no notification is available, the call fails and return false. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {boolean} True if the method was able to show the list (i.e. if the list is not empty), false otherwise. | ||
*/ | ||
presentNotificationsList: function() { | ||
@@ -340,2 +466,34 @@ var deferred = $q.defer(); | ||
}, | ||
/** | ||
* Class returned by the getContexts method of the PxlController | ||
* service that describe a single context available within the app. | ||
* | ||
* @class | ||
* @groupName class | ||
* @name Context | ||
* @memberOf pixlive | ||
* @property {string} contextId - The ID of the context | ||
* @property {string} name - The name of the context as entered in PixLive Maker | ||
* @property {string} lastUpdate - Date of last update of the context in the format YYYY-MM-DD HH:MM:SS ±HHMM | ||
* @property {string} description - The description of the context as entered in PixLive Maker | ||
* @property {string} notificationTitle - The title of the last notification generated by the context, or `null` if no such notification is available. | ||
* @property {string} notificationMessage - The message of the last notification generated by the context, or `null` if no such notification is available. | ||
* @property {string} imageThumbnailURL - The absolute URL toward the thumbnail of the image representing this context, null if not available. | ||
* @property {string} imageHiResURL - The absolute URL toward the full resolution image representing this context, null if not available. | ||
*/ | ||
/** | ||
* Asynchronously return the list of contexts that is available within the app (i.e. the ones that have been synchronized.) | ||
* | ||
* See {@link pixlive.Context} for the description of the Context class. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `Array<Context>` | ||
* argument corresponding to all the context/content contained in the app. | ||
*/ | ||
getContexts: function() { | ||
@@ -357,2 +515,92 @@ var deferred = $q.defer(); | ||
return deferred.promise; | ||
}, | ||
/** | ||
* Asynchronously return the list of contexts that have been bookmarked. | ||
* | ||
* When bookmark support has been enabled (by calling cordova.plugins.PixLive.setBookmarkSupport(true)), | ||
* a bookmark button is displayed on fullscreen content such as web pages. Clicking it will mark the content as | ||
* bookmarked. The content that have been bookmarked can be retrieved using this method. | ||
* You can also add and remove bookmarks programatically using the {@link pixlive.PxlController#addBookmark} / {@link pixlive.PxlController#removeBookmark} method | ||
* | ||
* See {@link pixlive.Context} for the description of the Context class. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `Array<Context>` | ||
* argument corresponding to the context/content that have been bookmarked. | ||
*/ | ||
getBookmarks: function() { | ||
var deferred = $q.defer(); | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.getBookmarks(function(list) { | ||
deferred.resolve(list); | ||
}, function() { | ||
deferred.reject(); | ||
}); | ||
} else { | ||
deferred.resolve([]); | ||
} | ||
}); | ||
return deferred.promise; | ||
}, | ||
/** | ||
* Add a new bookmark for a given context. The context corresponding to the contextId | ||
* will be added to the bookmark list. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to add to the bookmark list | ||
* | ||
* @memberof PxlController | ||
*/ | ||
addBookmark: function(contextId) { | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.addBookmark(contextId); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Remove a context from the bookmark list. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to remove from the bookmark list | ||
* | ||
* @memberof PxlController | ||
*/ | ||
removeBookmark: function(contextId) { | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.removeBookmark(contextId); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Asynchronously returns true or false depending if the context identifier by contextId (its ID) has been bookmarked or not. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to check | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `boolean` | ||
* argument indicating if the context has been bookmarked (true) or not (false) | ||
* | ||
* @memberof PxlController | ||
*/ | ||
isBookmarked: function(contextId) { | ||
var deferred = $q.defer(); | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.isBookmarked(contextId, function(bookmarked) { | ||
deferred.resolve(bookmarked); | ||
}, function() { | ||
deferred.reject(); | ||
}); | ||
} else { | ||
deferred.resolve([]); | ||
} | ||
}); | ||
return deferred.promise; | ||
} | ||
@@ -363,4 +611,4 @@ }; | ||
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -375,2 +623,11 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlEventService | ||
* @description | ||
* Add / Remove event subscribers to PixLive SDK related events. | ||
* | ||
* **Note:** You should use the plugin's directive (like `pxlContextEnter`) instead of using this service directly. | ||
*/ | ||
.constant('PxlEventService', (function() { | ||
@@ -390,2 +647,10 @@ | ||
handler: handler, | ||
/** | ||
* Add a new listener for the provided event type. | ||
* | ||
* @memberof PxlEventService | ||
* @param {string} event The event to register for. See the [cordova-plugin-PixLive](https://github.com/vidinoti/cordova-plugin-PixLive) plugin for more info on the event types. | ||
* @param {function} callback The function to be called when the provided event is generated. | ||
*/ | ||
addListener: function(event, callback) { | ||
@@ -397,2 +662,10 @@ if(!eventListeners[event]) { | ||
}, | ||
/** | ||
* Remove an existing listener for the provided event type. | ||
* | ||
* @memberof PxlEventService | ||
* @param {string} event The event to register for. See the [cordova-plugin-PixLive](https://github.com/vidinoti/cordova-plugin-PixLive) plugin for more info on the event types. | ||
* @param {function} callback The function that has been passed to the `addListener(event, callback)` method. | ||
*/ | ||
removeListener: function(event, callback) { | ||
@@ -421,2 +694,24 @@ | ||
}]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlContextEnter | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context is entered. Such an event | ||
* happens when a context is linked with a beacon and you are getting close | ||
* to the beacon, or when an image is linked with such a context and this image has been recognized. | ||
* | ||
* The unique ID of the context is passed as a parameter. | ||
* | ||
* @example | ||
* <div pxl-context-enter="contextEnter(contextId)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlContextEnter', [ | ||
@@ -426,2 +721,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -441,2 +737,24 @@ var listener = function(event) { | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlContextExit | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context is exited. Such an event | ||
* happens when a context is linked with a beacon and you are getting away | ||
* from the beacon, or when an image is linked with such a context and this image is not | ||
* within the camera sight anymore. | ||
* | ||
* The unique ID of the context is passed as a parameter. | ||
* | ||
* @example | ||
* <div pxl-context-enter="contextExit(contextId)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlContextExit', [ | ||
@@ -446,2 +764,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -461,2 +780,186 @@ var listener = function(event) { | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorTriggered | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor state become triggered (i.e. active). | ||
* | ||
* The ID of the sensor and the type of sensor are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, the sensor ID corresponds | ||
* to the context ID to which the sensor is linked but this might change in the future as the | ||
* PixLive SDK does support any kind of IDs. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* @example | ||
* <div pxl-sensor-triggered="sensorTriggered(sensorId, sensorType)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorTriggered', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorTriggered](event.sensorId,event.sensorType); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorTriggered',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorTriggered',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorUpdate | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor parameter changes. | ||
* | ||
* The ID of the sensor, the type of sensor, and the sensor parameters are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, this sensor never gets updated. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* | ||
* The sensor object contains the following two properties: | ||
* * `rssi`: The RSSI in dbm of the received beacon signal | ||
* * `distance`: The estimated distance in meters between the beacon and the smartphone | ||
* | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* The sensor object contains the following property: | ||
* * `rssi`: The RSSI in dbm of the received beacon signal | ||
* | ||
* @example | ||
* <div pxl-sensor-update="sensorUpdate(sensorId, sensorType, sensor)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorUpdate', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorUpdate](event.sensorId,event.sensorType, event); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorUpdate',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorUpdate',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorUntriggered | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor state become untriggered (i.e. not anymore active). | ||
* | ||
* The ID of the sensor and the type of sensor are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, the sensor ID corresponds | ||
* to the context ID to which the sensor is linked but this might change in the future as the | ||
* PixLive SDK does support any kind of IDs. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* @example | ||
* <div pxl-sensor-triggered="sensorUntriggered(sensorId, sensorType)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorUntriggered', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorUntriggered](event.sensorId,event.sensorType); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorUntriggered',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorUntriggered',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlCodeRecognize | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a code (QR Code, Barcode etc..) is recognized by the PixLive SDK | ||
* | ||
* The code value (e.g. the URL in case of a QR Code with URL) is passed as parameter. | ||
* | ||
* *Note*: You have to enable Code recognition on the SDK for this method to be called. | ||
* | ||
* | ||
* @example | ||
* <div pxl-code-recognize="codeRec(codeValue)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlCodeRecognize', [ | ||
@@ -466,2 +969,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -480,6 +984,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlAnnotationsPresent', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlAnnotationsPresent | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when some augmented reality content is presented on screen. | ||
* | ||
* This gives you the opportunity to hide any overlay you may have added over the Augmented Reality (AR) view. | ||
* | ||
* *Note*: This method is only called when the AR view is displayed. | ||
* | ||
* @example | ||
* <div pxl-annotations-present="hideOverlay()"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlAnnotationsPresent', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -498,6 +1025,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlAnnotationsHide', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlAnnotationsHide | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when no more augmented reality content is present on screen. | ||
* | ||
* This gives you the opportunity to put back any overlay you may have added over the Augmented Reality (AR) view. | ||
* | ||
* *Note*: This method is only called when the AR view is displayed. | ||
* | ||
* @example | ||
* <div pxl-annotations-hide="showOverlay()"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlAnnotationsHide', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -516,6 +1066,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlSynchronizationRequired', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSynchronizationRequired | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context synchronization is required. | ||
* | ||
* You should then call the RemoteController to trigger the synchronization with the passed tags (and any others you might want to add). | ||
* | ||
* The tags array to synchronize the app with, is passed as parameter (`tags`in the example below) | ||
* | ||
* @example | ||
* <div pxl-synchronization-required="doSync(tags)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSynchronizationRequired', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -522,0 +1095,0 @@ var listener = function(event) { |
@@ -1,1 +0,1 @@ | ||
"use strict";var pixliveModule=angular.module("pixlive",[]);pixliveModule.directive("pxlView",["$timeout","$ionicPosition","$ionicPlatform","$ionicBackdrop",function(a,b,c,d){return{restrict:"E",require:"^?ionNavView",priority:800,compile:function(e,f){function g(a,b,c,d){var e=a.$parent;a.$watch(function(){return(e.$hasHeader?" has-header":"")+(e.$hasSubheader?" has-subheader":"")+(e.$hasFooter?" has-footer":"")+(e.$hasSubfooter?" has-subfooter":"")+(e.$hasTabs?" has-tabs":"")+(e.$hasTabsTop?" has-tabs-top":"")},function(a,c){b.removeClass(c),b.addClass(a)})}function h(e,f,g,h){e.$on("$ionicView.beforeEnter",function(a,b){e.arView&&e.arView.beforeEnter()}),e.$on("$ionicView.afterEnter",function(g,h){e.arView?(e.onResize(),e.arView.afterEnter()):c.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&(e.pixliveTimeout=a(function(){var a=b.offset(f),c=a.top,g=a.left,h=a.width,i=a.height;e.pixliveTimeout=null,e.arView=window.cordova.plugins.PixLive.createARView(g,c,h,i,!0),0!=d.isDisplayed()?e.arView.disableTouch():e.arView.enableTouch(),e.onResize=function(){var a=b.offset(f),c=a.top,d=a.left,g=a.width,h=a.height;e.arView.resize(d,c,g,h)},e.onModalShown=function(){e.arView.disableTouch()},e.onModalHidden=function(){e.arView.enableTouch()},e.transferShown=function(){ionic.trigger("transfer.shown",{target:window})},e.transferHidden=function(){ionic.trigger("transfer.hidden",{target:window})},ionic.on("resize",e.onResize,window),ionic.on("backdrop.shown",e.onModalShown,window),ionic.on("backdrop.hidden",e.onModalHidden,window),e.$on("popover.shown",e.transferShown),e.$on("popover.hidden",e.transferHidden)},300))})}),e.$on("$ionicView.beforeLeave",function(b,c){e.pixliveTimeout&&(a.cancel(e.pixliveTimeout),e.pixliveTimeout=null),e.arView&&e.arView.beforeLeave()}),e.$on("$ionicView.afterLeave",function(a,b){e.arView&&e.arView.afterLeave()}),e.$on("$destroy",function(){e.pixliveTimeout&&(a.cancel(e.pixliveTimeout),e.pixliveTimeout=null),e.arView&&(ionic.off("resize",e.onResize,window),e.arView.destroy()),e.onModalShown&&(ionic.off("backdrop.shown",e.onModalShown,window),e.onModalShown=null),e.onModalHidden&&(ionic.off("backdrop.hidden",e.onModalHidden,window),e.onModalHidden=null)})}return e.addClass("scroll-content ionic-scroll scroll-content-false"),{pre:g,post:h}}}}]).config(["$provide",function(a){a.decorator("$ionicBackdrop",["$delegate",function(a){var b=a.retain,c=a.release;return a.backdropHolds=0,a.addBackdropHolds=function(){a.backdropHolds++,1==a.backdropHolds&&ionic.trigger("backdrop.shown",{target:window})},a.removeBackdropHolds=function(){a.backdropHolds--,0==a.backdropHolds&&ionic.trigger("backdrop.hidden",{target:window})},ionic.on("transfer.shown",a.addBackdropHolds,window),ionic.on("transfer.hidden",a.removeBackdropHolds,window),a.retain=function(){var c=[].slice.call(arguments);b.apply(null,c),a.addBackdropHolds()},a.release=function(){var b=[].slice.call(arguments);c.apply(null,b),a.removeBackdropHolds()},a.isDisplayed=function(){return a.backdropHolds>0},a}])}]),pixliveModule.factory("PxlRemoteController",["$ionicPlatform","$q","PxlEventService",function(a,b,c){return{synchronize:function(d){var e=b.defer(),f=function(a){e.notify(100*a.progress)};return c.addListener("syncProgress",f),a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.synchronize(d,function(a){c.removeListener("syncProgress",f),e.resolve(a)},function(a){c.removeListener("syncProgress",f),e.reject(a)}):(c.removeListener("syncProgress",f),e.resolve([]))}),e.promise}}}]),pixliveModule.factory("PxlController",["$ionicPlatform","$q",function(a,b){return{presentNotificationsList:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.presentNotificationsList(function(){c.resolve()},function(){c.reject()}):c.resolve([])}),c.promise},getContexts:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getContexts(function(a){c.resolve(a)},function(){c.reject()}):c.resolve([])}),c.promise}}}]),pixliveModule.constant("PxlEventService",function(){var a={},b=function(b){if(b.type&&a[b.type])for(var c=a[b.type].length-1;c>=0;c--)a[b.type][c](b)};return{handler:b,addListener:function(b,c){a[b]||(a[b]=[]),a[b].push(c)},removeListener:function(b,c){if(a[b]&&0!=a[b].length){var d=a[b].indexOf(c);-1!=d&&a[b].splice(d,1)}}}}()).run(["PxlEventService","$ionicPlatform",function(a,b){b.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&!window.cordova.plugins.PixLive.onEventReceived&&(cordova.plugins.PixLive.onEventReceived=a.handler)})}]).directive("pxlContextEnter",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlContextEnter](a.context)})};a.addListener("enterContext",e),c.bind("$destroy",function(){a.removeListener("enterContext",e)})}}}]).directive("pxlContextExit",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlContextExit](a.context)})};a.addListener("exitContext",e),c.bind("$destroy",function(){a.removeListener("exitContext",e)})}}}]).directive("pxlCodeRecognize",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlCodeRecognize](a.code)})};a.addListener("codeRecognize",e),c.bind("$destroy",function(){a.removeListener("codeRecognize",e)})}}}]).directive("pxlAnnotationsPresent",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(a){a[d.pxlAnnotationsPresent]()})};a.addListener("presentAnnotations",e),c.bind("$destroy",function(){a.removeListener("presentAnnotations",e)})}}}]).directive("pxlAnnotationsHide",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(a){a[d.pxlAnnotationsHide]()})};a.addListener("hideAnnotations",e),c.bind("$destroy",function(){a.removeListener("hideAnnotations",e)})}}}]).directive("pxlSynchronizationRequired",["PxlEventService",function(a){return{link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlSynchronizationRequired](a.tags)})};a.addListener("requireSync",e),c.bind("$destroy",function(){a.removeListener("requireSync",e)})}}}]); | ||
"use strict";var pixliveModule=angular.module("pixlive",[]);pixliveModule.directive("pxlView",["$timeout","$ionicPosition","$ionicPlatform","$ionicBackdrop",function(a,b,c,d){return{restrict:"E",require:"^?ionNavView",priority:800,compile:function(e,f){function g(a,b,c,d){var e=a.$parent;a.$watch(function(){return(e.$hasHeader?" has-header":"")+(e.$hasSubheader?" has-subheader":"")+(e.$hasFooter?" has-footer":"")+(e.$hasSubfooter?" has-subfooter":"")+(e.$hasTabs?" has-tabs":"")+(e.$hasTabsTop?" has-tabs-top":"")},function(a,c){b.removeClass(c),b.addClass(a)})}function h(e,f,g,h){e.$on("$ionicView.beforeEnter",function(a,b){e.arView&&e.arView.beforeEnter()}),e.$on("$ionicView.afterEnter",function(g,h){e.arView?(e.onResize(),e.arView.afterEnter()):c.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&(e.pixliveTimeout=a(function(){var a=b.offset(f),c=a.top,g=a.left,h=a.width,i=a.height;e.pixliveTimeout=null,e.arView=window.cordova.plugins.PixLive.createARView(g,c,h,i,!0),0!=d.isDisplayed()?e.arView.disableTouch():e.arView.enableTouch(),e.onResize=function(){var a=b.offset(f),c=a.top,d=a.left,g=a.width,h=a.height;e.arView.resize(d,c,g,h)},e.onModalShown=function(){e.arView.disableTouch()},e.onModalHidden=function(){e.arView.enableTouch()},e.transferShown=function(){ionic.trigger("transfer.shown",{target:window})},e.transferHidden=function(){ionic.trigger("transfer.hidden",{target:window})},ionic.on("resize",e.onResize,window),ionic.on("backdrop.shown",e.onModalShown,window),ionic.on("backdrop.hidden",e.onModalHidden,window),e.$on("popover.shown",e.transferShown),e.$on("popover.hidden",e.transferHidden)},300))})}),e.$on("$ionicView.beforeLeave",function(b,c){e.pixliveTimeout&&(a.cancel(e.pixliveTimeout),e.pixliveTimeout=null),e.arView&&e.arView.beforeLeave()}),e.$on("$ionicView.afterLeave",function(a,b){e.arView&&e.arView.afterLeave()}),e.$on("$destroy",function(){e.pixliveTimeout&&(a.cancel(e.pixliveTimeout),e.pixliveTimeout=null),e.arView&&(ionic.off("resize",e.onResize,window),e.arView.destroy()),e.onModalShown&&(ionic.off("backdrop.shown",e.onModalShown,window),e.onModalShown=null),e.onModalHidden&&(ionic.off("backdrop.hidden",e.onModalHidden,window),e.onModalHidden=null)})}return e.addClass("scroll-content ionic-scroll scroll-content-false"),{pre:g,post:h}}}}]).config(["$provide",function(a){a.decorator("$ionicBackdrop",["$delegate",function(a){var b=a.retain,c=a.release;return a.backdropHolds=0,a.addBackdropHolds=function(){a.backdropHolds++,1==a.backdropHolds&&ionic.trigger("backdrop.shown",{target:window})},a.removeBackdropHolds=function(){a.backdropHolds--,0==a.backdropHolds&&ionic.trigger("backdrop.hidden",{target:window})},ionic.on("transfer.shown",a.addBackdropHolds,window),ionic.on("transfer.hidden",a.removeBackdropHolds,window),a.retain=function(){var c=[].slice.call(arguments);b.apply(null,c),a.addBackdropHolds()},a.release=function(){var b=[].slice.call(arguments);c.apply(null,b),a.removeBackdropHolds()},a.isDisplayed=function(){return a.backdropHolds>0},a}])}]).config(["$provide",function(a){a.decorator("$ionicModal",["$delegate","$q",function(a,b){var c=a.fromTemplate,d=a.fromTemplateUrl,e=function(a){a.showOld=a.show,a.hideOld=a.hide,a.show=function(){ionic.trigger("transfer.shown",{target:window});var a=[].slice.call(arguments);return this.showOld.apply(this,a)},a.hide=function(){ionic.trigger("transfer.hidden",{target:window});var a=[].slice.call(arguments);return this.hideOld.apply(this,a)}};return a.fromTemplate=function(){var a=[].slice.call(arguments),b=c.apply(null,a);return e(b),b},a.fromTemplateUrl=function(){var a=[].slice.call(arguments),c=b.defer();return d.apply(null,a).then(function(a){e(a),c.resolve(a)},function(a){c.reject(a)}),c.promise},a}])}]),pixliveModule.factory("PxlRemoteController",["$ionicPlatform","$q","PxlEventService",function(a,b,c){return{synchronize:function(d){var e=b.defer(),f=function(a){e.notify(100*a.progress)};return c.addListener("syncProgress",f),a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.synchronize(d,function(a){c.removeListener("syncProgress",f),e.resolve(a)},function(a){c.removeListener("syncProgress",f),e.reject(a)}):(c.removeListener("syncProgress",f),e.resolve([]))}),e.promise}}}]),pixliveModule.factory("PxlController",["$ionicPlatform","$q",function(a,b){return{presentNotificationsList:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.presentNotificationsList(function(){c.resolve()},function(){c.reject()}):c.resolve([])}),c.promise},getContexts:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getContexts(function(a){c.resolve(a)},function(){c.reject()}):c.resolve([])}),c.promise},getBookmarks:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getBookmarks(function(a){c.resolve(a)},function(){c.reject()}):c.resolve([])}),c.promise},addBookmark:function(b){a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.addBookmark(b)})},removeBookmark:function(b){a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.removeBookmark(b)})},isBookmarked:function(c){var d=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.isBookmarked(c,function(a){d.resolve(a)},function(){d.reject()}):d.resolve([])}),d.promise}}}]),pixliveModule.constant("PxlEventService",function(){var a={},b=function(b){if(b.type&&a[b.type])for(var c=a[b.type].length-1;c>=0;c--)a[b.type][c](b)};return{handler:b,addListener:function(b,c){a[b]||(a[b]=[]),a[b].push(c)},removeListener:function(b,c){if(a[b]&&0!=a[b].length){var d=a[b].indexOf(c);-1!=d&&a[b].splice(d,1)}}}}()).run(["PxlEventService","$ionicPlatform",function(a,b){b.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&!window.cordova.plugins.PixLive.onEventReceived&&(cordova.plugins.PixLive.onEventReceived=a.handler)})}]).directive("pxlContextEnter",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlContextEnter](a.context)})};a.addListener("enterContext",e),c.bind("$destroy",function(){a.removeListener("enterContext",e)})}}}]).directive("pxlContextExit",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlContextExit](a.context)})};a.addListener("exitContext",e),c.bind("$destroy",function(){a.removeListener("exitContext",e)})}}}]).directive("pxlSensorTriggered",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlSensorTriggered](a.sensorId,a.sensorType)})};a.addListener("sensorTriggered",e),c.bind("$destroy",function(){a.removeListener("sensorTriggered",e)})}}}]).directive("pxlSensorUpdate",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlSensorUpdate](a.sensorId,a.sensorType,a)})};a.addListener("sensorUpdate",e),c.bind("$destroy",function(){a.removeListener("sensorUpdate",e)})}}}]).directive("pxlSensorUntriggered",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlSensorUntriggered](a.sensorId,a.sensorType)})};a.addListener("sensorUntriggered",e),c.bind("$destroy",function(){a.removeListener("sensorUntriggered",e)})}}}]).directive("pxlCodeRecognize",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlCodeRecognize](a.code)})};a.addListener("codeRecognize",e),c.bind("$destroy",function(){a.removeListener("codeRecognize",e)})}}}]).directive("pxlAnnotationsPresent",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(a){a[d.pxlAnnotationsPresent]()})};a.addListener("presentAnnotations",e),c.bind("$destroy",function(){a.removeListener("presentAnnotations",e)})}}}]).directive("pxlAnnotationsHide",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(a){a[d.pxlAnnotationsHide]()})};a.addListener("hideAnnotations",e),c.bind("$destroy",function(){a.removeListener("hideAnnotations",e)})}}}]).directive("pxlSynchronizationRequired",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlSynchronizationRequired](a.tags)})};a.addListener("requireSync",e),c.bind("$destroy",function(){a.removeListener("requireSync",e)})}}}]); |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -10,2 +10,28 @@ */ | ||
pixliveModule | ||
/** | ||
* @ngdoc directive | ||
* @name pxlView | ||
* @memberof pixlive | ||
* @param {service} $timeout Angular $timeout service | ||
* @param {service} $ionicPosition Ionic $ionicPosition service | ||
* @param {service} $ionicPlatform Ionic $ionicPlatform service | ||
* @param {service} $ionicBackdrop Ionic $ionicBackdrop service | ||
* @restrict E | ||
* | ||
* @description | ||
* Add an augmented reality view to your Ionic app. | ||
* | ||
* **Notice**: You should minimize the number of AR view included into your app to the minimum as this is CPU resource intensive. | ||
* You should also avoid having two AR views visible at the same time as this will create unexpected behaviors. | ||
* | ||
* **Warning**: This view has to be inside an `ion-view` element whose background has been set to transparent. Failing to do so will make the AR view invisible. | ||
* | ||
* @example | ||
* <ion-view view-title="AR" style="background-color: transparent !important;"> | ||
* <pxl-view> | ||
* <!-- Any overlay you want --> | ||
* </pxl-view> | ||
* </ion-view> | ||
*/ | ||
.directive('pxlView', [ | ||
@@ -206,3 +232,3 @@ '$timeout', | ||
// Call the original with the output prepended with formatted timestamp | ||
// Call the original method | ||
retainFn.apply(null, args) | ||
@@ -216,3 +242,3 @@ | ||
// Call the original with the output prepended with formatted timestamp | ||
// Call the original method | ||
releaseFn.apply(null, args) | ||
@@ -231,2 +257,62 @@ | ||
} | ||
]).config(["$provide", | ||
function($provide) { | ||
$provide.decorator('$ionicModal', ["$delegate","$q", | ||
function($delegate,$q) { | ||
// Save the original $log.show() | ||
var fromTemplate = $delegate.fromTemplate; | ||
var fromTemplateUrl = $delegate.fromTemplateUrl; | ||
var overrideShowHide = function (ret) { | ||
// Save old methods | ||
ret.showOld = ret.show; | ||
ret.hideOld = ret.hide; | ||
ret.show=function() { | ||
ionic.trigger('transfer.shown', { | ||
target: window | ||
}); | ||
var args2 = [].slice.call(arguments); | ||
return this.showOld.apply(this, args2); | ||
}; | ||
ret.hide=function() { | ||
ionic.trigger('transfer.hidden', { | ||
target: window | ||
}); | ||
var args2 = [].slice.call(arguments); | ||
return this.hideOld.apply(this, args2); | ||
}; | ||
}; | ||
$delegate.fromTemplate = function() { | ||
var args = [].slice.call(arguments); | ||
var ret = fromTemplate.apply(null, args); | ||
overrideShowHide(ret); | ||
return ret; | ||
}; | ||
$delegate.fromTemplateUrl = function() { | ||
var args = [].slice.call(arguments); | ||
var deferred = $q.defer(); | ||
fromTemplateUrl.apply(null, args).then(function(modal) { | ||
overrideShowHide(modal); | ||
deferred.resolve(modal); | ||
}, function(err) { | ||
deferred.reject(err); | ||
}); | ||
return deferred.promise; | ||
}; | ||
return $delegate; | ||
} | ||
]); | ||
} | ||
]); |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -13,2 +13,11 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlEventService | ||
* @description | ||
* Add / Remove event subscribers to PixLive SDK related events. | ||
* | ||
* **Note:** You should use the plugin's directive (like `pxlContextEnter`) instead of using this service directly. | ||
*/ | ||
.constant('PxlEventService', (function() { | ||
@@ -28,2 +37,10 @@ | ||
handler: handler, | ||
/** | ||
* Add a new listener for the provided event type. | ||
* | ||
* @memberof PxlEventService | ||
* @param {string} event The event to register for. See the [cordova-plugin-PixLive](https://github.com/vidinoti/cordova-plugin-PixLive) plugin for more info on the event types. | ||
* @param {function} callback The function to be called when the provided event is generated. | ||
*/ | ||
addListener: function(event, callback) { | ||
@@ -35,2 +52,10 @@ if(!eventListeners[event]) { | ||
}, | ||
/** | ||
* Remove an existing listener for the provided event type. | ||
* | ||
* @memberof PxlEventService | ||
* @param {string} event The event to register for. See the [cordova-plugin-PixLive](https://github.com/vidinoti/cordova-plugin-PixLive) plugin for more info on the event types. | ||
* @param {function} callback The function that has been passed to the `addListener(event, callback)` method. | ||
*/ | ||
removeListener: function(event, callback) { | ||
@@ -59,2 +84,24 @@ | ||
}]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlContextEnter | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context is entered. Such an event | ||
* happens when a context is linked with a beacon and you are getting close | ||
* to the beacon, or when an image is linked with such a context and this image has been recognized. | ||
* | ||
* The unique ID of the context is passed as a parameter. | ||
* | ||
* @example | ||
* <div pxl-context-enter="contextEnter(contextId)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlContextEnter', [ | ||
@@ -64,2 +111,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -79,2 +127,24 @@ var listener = function(event) { | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlContextExit | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context is exited. Such an event | ||
* happens when a context is linked with a beacon and you are getting away | ||
* from the beacon, or when an image is linked with such a context and this image is not | ||
* within the camera sight anymore. | ||
* | ||
* The unique ID of the context is passed as a parameter. | ||
* | ||
* @example | ||
* <div pxl-context-enter="contextExit(contextId)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlContextExit', [ | ||
@@ -84,2 +154,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -99,2 +170,186 @@ var listener = function(event) { | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorTriggered | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor state become triggered (i.e. active). | ||
* | ||
* The ID of the sensor and the type of sensor are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, the sensor ID corresponds | ||
* to the context ID to which the sensor is linked but this might change in the future as the | ||
* PixLive SDK does support any kind of IDs. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* @example | ||
* <div pxl-sensor-triggered="sensorTriggered(sensorId, sensorType)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorTriggered', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorTriggered](event.sensorId,event.sensorType); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorTriggered',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorTriggered',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorUpdate | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor parameter changes. | ||
* | ||
* The ID of the sensor, the type of sensor, and the sensor parameters are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, this sensor never gets updated. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* | ||
* The sensor object contains the following two properties: | ||
* * `rssi`: The RSSI in dbm of the received beacon signal | ||
* * `distance`: The estimated distance in meters between the beacon and the smartphone | ||
* | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* The sensor object contains the following property: | ||
* * `rssi`: The RSSI in dbm of the received beacon signal | ||
* | ||
* @example | ||
* <div pxl-sensor-update="sensorUpdate(sensorId, sensorType, sensor)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorUpdate', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorUpdate](event.sensorId,event.sensorType, event); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorUpdate',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorUpdate',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSensorUntriggered | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a sensor state become untriggered (i.e. not anymore active). | ||
* | ||
* The ID of the sensor and the type of sensor are passed as parameters. The types and IDs are defined hereafter. | ||
* | ||
* Three types of sensors are defined: | ||
* 1. `Vision`<br/> | ||
* Corresponds to an image that has been recognized. As of today, the sensor ID corresponds | ||
* to the context ID to which the sensor is linked but this might change in the future as the | ||
* PixLive SDK does support any kind of IDs. | ||
* 2. `iBeacon`<br/> | ||
* Corresponds to an iBeacon that is in the required proximity of the smartphone. The ID is defined to be: | ||
* ``` | ||
* BeaconUUID_Major_Minor | ||
* ``` | ||
* 3. `VidiBeacon`<br/> | ||
* Corresponds to a VidiBeacon that is in the required proximity of the smartphone. | ||
* The ID is defined to be the VidiBeacon serial. | ||
* | ||
* @example | ||
* <div pxl-sensor-triggered="sensorUntriggered(sensorId, sensorType)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSensorUntriggered', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
var listener = function(event) { | ||
scope.$apply(function(self) { | ||
self[attrs.pxlSensorUntriggered](event.sensorId,event.sensorType); | ||
}); | ||
}; | ||
PxlEventService.addListener('sensorUntriggered',listener); | ||
element.bind('$destroy', function() { | ||
PxlEventService.removeListener('sensorUntriggered',listener); | ||
}); | ||
} | ||
}; | ||
} | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlCodeRecognize | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a code (QR Code, Barcode etc..) is recognized by the PixLive SDK | ||
* | ||
* The code value (e.g. the URL in case of a QR Code with URL) is passed as parameter. | ||
* | ||
* *Note*: You have to enable Code recognition on the SDK for this method to be called. | ||
* | ||
* | ||
* @example | ||
* <div pxl-code-recognize="codeRec(codeValue)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlCodeRecognize', [ | ||
@@ -104,2 +359,3 @@ 'PxlEventService', | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -118,6 +374,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlAnnotationsPresent', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlAnnotationsPresent | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when some augmented reality content is presented on screen. | ||
* | ||
* This gives you the opportunity to hide any overlay you may have added over the Augmented Reality (AR) view. | ||
* | ||
* *Note*: This method is only called when the AR view is displayed. | ||
* | ||
* @example | ||
* <div pxl-annotations-present="hideOverlay()"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlAnnotationsPresent', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -136,6 +415,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlAnnotationsHide', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlAnnotationsHide | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when no more augmented reality content is present on screen. | ||
* | ||
* This gives you the opportunity to put back any overlay you may have added over the Augmented Reality (AR) view. | ||
* | ||
* *Note*: This method is only called when the AR view is displayed. | ||
* | ||
* @example | ||
* <div pxl-annotations-hide="showOverlay()"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlAnnotationsHide', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -154,6 +456,29 @@ var listener = function(event) { | ||
} | ||
]).directive('pxlSynchronizationRequired', [ | ||
]) | ||
/** | ||
* @ngdoc directive | ||
* @name pxlSynchronizationRequired | ||
* @element Attribute | ||
* @memberof pixlive | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @restrict A | ||
* | ||
* @description | ||
* Expression that is evaluated when a context synchronization is required. | ||
* | ||
* You should then call the RemoteController to trigger the synchronization with the passed tags (and any others you might want to add). | ||
* | ||
* The tags array to synchronize the app with, is passed as parameter (`tags`in the example below) | ||
* | ||
* @example | ||
* <div pxl-synchronization-required="doSync(tags)"> | ||
* ... | ||
* </div> | ||
*/ | ||
.directive('pxlSynchronizationRequired', [ | ||
'PxlEventService', | ||
function(PxlEventService) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs) { | ||
@@ -160,0 +485,0 @@ var listener = function(event) { |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -13,2 +13,13 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlRemoteController | ||
* @param {service} $ionicPlatform The Ionic Platform helper | ||
* @param {service} $q Angular promise service | ||
* @param {service} PxlEventService PixLive SDK Event service | ||
* @description | ||
* Manage and trigger PixLive Maker content synchronization with the app. | ||
*/ | ||
.factory('PxlRemoteController', [ | ||
@@ -24,2 +35,12 @@ '$ionicPlatform', | ||
return { | ||
/** | ||
* Start an asynchronous content synchronization with PixLive Maker backend | ||
* | ||
* **Warning**: Only one synchronization can be started at a time. | ||
* | ||
* @memberof PxlRemoteController | ||
* @param {string[]} tags The array of tags to start the synchronization with. Pass an empty array for synchronizing your app with all the available content. | ||
* @returns {Promise} The Angular promise that can be used for checking asynchronously the result of the call. | ||
*/ | ||
synchronize: function(tags) { | ||
@@ -26,0 +47,0 @@ var deferred = $q.defer(); |
/* | ||
* angular-pixlive v0.0.1 | ||
* (c) 2015 Vidinoti http://vidinoti.com | ||
* angular-pixlive v1 | ||
* (c) 2015-2016 Vidinoti https://vidinoti.com | ||
* License: MIT | ||
@@ -13,2 +13,12 @@ * | ||
pixliveModule | ||
/** | ||
* @memberof pixlive | ||
* @ngdoc service | ||
* @name PxlController | ||
* @param {service} $ionicPlatform The Ionic Platform helper | ||
* @param {service} $q Angular promise service | ||
* @description | ||
* Exposes PixLive SDK methods using an angular-like service | ||
*/ | ||
.factory('PxlController', [ | ||
@@ -23,2 +33,11 @@ '$ionicPlatform', | ||
return { | ||
/** | ||
* Display the PixLive SDK notification list over the Ionic app. | ||
* If no notification is available, the call fails and return false. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {boolean} True if the method was able to show the list (i.e. if the list is not empty), false otherwise. | ||
*/ | ||
presentNotificationsList: function() { | ||
@@ -41,2 +60,34 @@ var deferred = $q.defer(); | ||
}, | ||
/** | ||
* Class returned by the getContexts method of the PxlController | ||
* service that describe a single context available within the app. | ||
* | ||
* @class | ||
* @groupName class | ||
* @name Context | ||
* @memberOf pixlive | ||
* @property {string} contextId - The ID of the context | ||
* @property {string} name - The name of the context as entered in PixLive Maker | ||
* @property {string} lastUpdate - Date of last update of the context in the format YYYY-MM-DD HH:MM:SS ±HHMM | ||
* @property {string} description - The description of the context as entered in PixLive Maker | ||
* @property {string} notificationTitle - The title of the last notification generated by the context, or `null` if no such notification is available. | ||
* @property {string} notificationMessage - The message of the last notification generated by the context, or `null` if no such notification is available. | ||
* @property {string} imageThumbnailURL - The absolute URL toward the thumbnail of the image representing this context, null if not available. | ||
* @property {string} imageHiResURL - The absolute URL toward the full resolution image representing this context, null if not available. | ||
*/ | ||
/** | ||
* Asynchronously return the list of contexts that is available within the app (i.e. the ones that have been synchronized.) | ||
* | ||
* See {@link pixlive.Context} for the description of the Context class. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `Array<Context>` | ||
* argument corresponding to all the context/content contained in the app. | ||
*/ | ||
getContexts: function() { | ||
@@ -58,2 +109,92 @@ var deferred = $q.defer(); | ||
return deferred.promise; | ||
}, | ||
/** | ||
* Asynchronously return the list of contexts that have been bookmarked. | ||
* | ||
* When bookmark support has been enabled (by calling cordova.plugins.PixLive.setBookmarkSupport(true)), | ||
* a bookmark button is displayed on fullscreen content such as web pages. Clicking it will mark the content as | ||
* bookmarked. The content that have been bookmarked can be retrieved using this method. | ||
* You can also add and remove bookmarks programatically using the {@link pixlive.PxlController#addBookmark} / {@link pixlive.PxlController#removeBookmark} method | ||
* | ||
* See {@link pixlive.Context} for the description of the Context class. | ||
* | ||
* @memberof PxlController | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `Array<Context>` | ||
* argument corresponding to the context/content that have been bookmarked. | ||
*/ | ||
getBookmarks: function() { | ||
var deferred = $q.defer(); | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.getBookmarks(function(list) { | ||
deferred.resolve(list); | ||
}, function() { | ||
deferred.reject(); | ||
}); | ||
} else { | ||
deferred.resolve([]); | ||
} | ||
}); | ||
return deferred.promise; | ||
}, | ||
/** | ||
* Add a new bookmark for a given context. The context corresponding to the contextId | ||
* will be added to the bookmark list. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to add to the bookmark list | ||
* | ||
* @memberof PxlController | ||
*/ | ||
addBookmark: function(contextId) { | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.addBookmark(contextId); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Remove a context from the bookmark list. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to remove from the bookmark list | ||
* | ||
* @memberof PxlController | ||
*/ | ||
removeBookmark: function(contextId) { | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.removeBookmark(contextId); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Asynchronously returns true or false depending if the context identifier by contextId (its ID) has been bookmarked or not. | ||
* | ||
* @param {string} contextId the ID (from the {@link pixlive.Context#contextId } property of the Context object) of the context to check | ||
* | ||
* @returns {Promise} An Angular Promise where the success | ||
* method will be called with an `boolean` | ||
* argument indicating if the context has been bookmarked (true) or not (false) | ||
* | ||
* @memberof PxlController | ||
*/ | ||
isBookmarked: function(contextId) { | ||
var deferred = $q.defer(); | ||
$ionicPlatform.ready(function () { | ||
if(window.cordova && window.cordova.plugins && window.cordova.plugins.PixLive) { | ||
window.cordova.plugins.PixLive.isBookmarked(contextId, function(bookmarked) { | ||
deferred.resolve(bookmarked); | ||
}, function() { | ||
deferred.reject(); | ||
}); | ||
} else { | ||
deferred.resolve([]); | ||
} | ||
}); | ||
return deferred.promise; | ||
} | ||
@@ -60,0 +201,0 @@ }; |
{ | ||
"name": "angular-pixlive", | ||
"version": "1.0.5", | ||
"version": "1.0.7", | ||
"description": "Plugin to use PixLive Augmented Reality toolkit the Angular way", | ||
@@ -29,10 +29,14 @@ "main": "js/PixLive.bundle.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.5", | ||
"grunt-contrib-concat": "~0.5.1", | ||
"grunt-contrib-uglify": "~0.9.1", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-contrib-cssmin": "~0.12.2", | ||
"grunt-contrib-clean": "~0.6.0" | ||
"angular-template": "2.0.7", | ||
"angular-jsdoc": "1.4.1", | ||
"canonical-path": "0.0.2", | ||
"grunt": "1.0.1", | ||
"grunt-contrib-clean": "1.0.0", | ||
"grunt-contrib-concat": "1.0.0", | ||
"grunt-contrib-cssmin": "1.0.0", | ||
"grunt-contrib-uglify": "1.0.0", | ||
"grunt-contrib-watch": "1.0.0", | ||
"grunt-jsdoc": "2.0.0", | ||
"jsdoc": "3.4.0" | ||
} | ||
} | ||
# angular-pixlive | ||
[![Build Status](https://travis-ci.org/vidinoti/angular-pixlive.svg?branch=master)](https://travis-ci.org/vidinoti/angular-pixlive) | ||
Plugin for using PixLive SDK in Ionic framework. | ||
## Using the AR View | ||
## Documentation | ||
The documentation is available at [http://vidinoti.github.io/angular-pixlive/docs](http://vidinoti.github.io/angular-pixlive/docs). | ||
## Using the Augmented Reality View | ||
Follow the following steps do add an augmented reality view in your Ionic project: | ||
* Add the plugin to your Ionic project: | ||
@@ -10,5 +18,11 @@ | ||
* Add the Cordova plugin for PixLive SDK to your Ionic project: | ||
`ionic plugin add cordova-plugin-pixlive --variable LICENSE_KEY=MyLicenseKey --variable PIXLIVE_SDK_IOS_LOCATION=\"/home/PixLiveSDKiOS/VDARSDK.framework\" --variable PIXLIVE_SDK_ANDROID_LOCATION=\"/home/PixLiveSDKAndroid/vdarsdk-release.aar\"` | ||
```bash | ||
ionic plugin add cordova-plugin-pixlive --variable LICENSE_KEY=MyLicenseKey \ | ||
--variable PIXLIVE_SDK_IOS_LOCATION=\"/home/PixLiveSDKiOS/VDARSDK.framework\" | ||
--variable PIXLIVE_SDK_ANDROID_LOCATION=\"/home/PixLiveSDKAndroid/vdarsdk-release.aar\" | ||
``` | ||
where the paths corresponds to the location for iOS and Android of the framework and AAR files. | ||
where the paths corresponds to the location for iOS and Android of the framework and AAR files. **Do not remove the backslashes before and after the quotes (i.e. \") or the command will fail.** | ||
* Add JS Bundle file in you index.html: | ||
@@ -26,8 +40,18 @@ | ||
if(window.cordova && window.cordova.plugins) { | ||
//Init PixLive SDK | ||
cordova.plugins.PixLive.setNotificationsSupport(true,'GoogleProjectID'); | ||
//Enable notifications | ||
cordova.plugins.PixLive.setNotificationsSupport(true,'GoogleProjectID'); | ||
} | ||
``` | ||
where GoogleProjectID corresponds to the ID of the Google project you created in the Google Developer console. | ||
where `GoogleProjectID` corresponds to the ID of the Google project you created in the Google Developer console. | ||
* You can also enable bookmark support (user will be able to bookmark some content. You can then create a view with all the bookmarked content): | ||
```js | ||
if(window.cordova && window.cordova.plugins) { | ||
//Enable bookmark support | ||
cordova.plugins.PixLive.setBookmarkSupport(true); | ||
} | ||
``` | ||
* Add an Augmented Reality view in one of your Ionic views. Note that content inserted within the view will be displayed on top of the AR camera view. | ||
@@ -38,3 +62,3 @@ | ||
<pxl-view> | ||
<!-- You can insert other elements here to create overlays --> | ||
</pxl-view> | ||
@@ -44,13 +68,18 @@ </ion-view> | ||
**Warning**: The camera view is inserted **below** your app. Therefore you need to make to have your view transparent where the camera should appear. As above, put the background color to transparent on your ion-view as well as on your ion-tabs, if any. | ||
**Warning**: The camera view is inserted **below** your Ionic app. Therefore you need to make sure to have your view transparent where the camera should appear. As above, set the CSS property `background-color` to `transparent` on your ion-view as well as on your ion-tabs, if any. | ||
## AR Model / Context Synchronization | ||
## Synchronizing content from PixLive Maker | ||
The plugin exposes a `PxlRemoteController` service allowing you to request synchronizations of the contexts / AR Models. This can be done anywhere in your controllers or at app launch time. The plugin make sure that everything is ready before issuing the call so it's safe to use it anywhere. | ||
PixLive Maker is a platform that allows anyone to create content for your app embeding PixLive SDK. | ||
Example of usage: | ||
Your app needs to be synchronized with PixLive Maker so that the content can be used within the app. | ||
To do so, the plugin exposes a `PxlRemoteController` service allowing you to request synchronizations of the contexts / AR content. This can be done anywhere in your controllers or at app launch time. The plugin make sure that everything is ready before issuing the call so it's safe to use it anywhere. | ||
Example of usage within a controller constructor: | ||
```js | ||
myApp.controller('PixLiveCtrl', function($scope, $ionicLoading, $compile, PxlRemoteController, $ionicPopup) { | ||
// Trigger a synchronization with the tag test, pass an empty array to synchronize with all the contexts. | ||
// Trigger a synchronization with the tag *test* | ||
// You can pass an empty array to synchronize with all the contexts. | ||
PxlRemoteController.synchronize(['test']).then(function(contexts) { | ||
@@ -70,5 +99,5 @@ console.log('Syncronization OK: '); | ||
## Events | ||
## Directives for events | ||
The following directives can be used **as attribute** on any elements to get the associated events from the PixLive SD: | ||
The following directives can be used **as attribute** on any elements to get the associated events from the PixLive SDK: | ||
@@ -81,2 +110,5 @@ * pxlContextEnter | ||
* pxlSynchronizationRequired | ||
* pxlSensorTriggered | ||
* pxlSensorUpdate | ||
* pxlSensorUntriggered | ||
@@ -86,3 +118,3 @@ It can be used for example as follow in your HTML template: | ||
``` | ||
<ion-view view-title="AR" style="background-color: transparent !important;"> | ||
<ion-view view-title="AR" style="background-color: transparent !important;"> | ||
<pxl-view pxl-context-enter="contextEnter"> | ||
@@ -94,2 +126,4 @@ | ||
This will call the `contextEnter` on the controller linked with the view when an image or a iBeacon is detected. | ||
This will call the `contextEnter` on the controller linked with the view when an image or a iBeacon is detected. The context ID is passed as a parameter to the contextEnter method. | ||
See the directives' doc for more information. |
Sorry, the diff of this file is not supported yet
105761
14
2032
121
11