angular-pixlive
Version:
Plugin to use PixLive Augmented Reality toolkit the Angular way
1 lines • 11.8 kB
JavaScript
;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},presentNearbyList:function(c,d){b.defer();a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.presentNearbyList(c,d)})},refreshNearbyList:function(c,d){b.defer();a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.refreshNearbyList(c,d)})},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},getContext:function(c){var d=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getContext(c,function(a){d.resolve(a)},function(){d.reject()}):d.resolve([])}),d.promise},isContainingGPSPoints:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.isContainingGPSPoints(function(a){c.resolve(a)},function(){c.reject()}):c.resolve([])}),c.promise},computeDistanceBetweenGPSPoints:function(c,d,e,f){var g=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.computeDistanceBetweenGPSPoints(c,d,e,f,function(a){g.resolve(a)},function(){g.reject()}):g.resolve([])}),g.promise},getNearbyBeacons:function(){var c=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getNearbyBeacons(function(a){c.resolve(a)},function(){c.reject()}):c.resolve([])}),c.promise},getNearbyGPSPoints:function(c,d){var e=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getNearbyGPSPoints(c,d,function(a){e.resolve(a)},function(){e.reject()}):e.resolve([])}),e.promise},getGPSPointsInBoundingBox:function(c,d,e,f){var g=b.defer();return a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive?window.cordova.plugins.PixLive.getGPSPointsInBoundingBox(c,d,e,f,function(a){g.resolve(a)},function(){g.reject()}):g.resolve([])}),g.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},openURLInInternalBrowser:function(b){a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.openURLInInternalBrowser(b)})},setCloudRecognitionLanguage:function(b){a.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.PixLive&&window.cordova.plugins.PixLive.setCloudRecognitionLanguage(b)})}}}]),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("pxlEventFromContent",["PxlEventService",function(a){return{restrict:"A",link:function(b,c,d){var e=function(a){b.$apply(function(b){b[d.pxlEventFromContent](a.eventName,a.eventParams)})};a.addListener("eventFromContent",e),c.bind("$destroy",function(){a.removeListener("eventFromContent",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)})}}}]);