From 04bf5dbcfc3229b29327e7cf34fd75e97bced5f5 Mon Sep 17 00:00:00 2001 From: Antonio Marcos SS Jr Date: Sun, 26 Feb 2017 21:46:45 -0300 Subject: [PATCH] =?UTF-8?q?-=20updated=20example=20in=20folder.=20-=20upda?= =?UTF-8?q?ted=20service,=20so=20that's=20possible=20to=20make=20chainable?= =?UTF-8?q?=20methods.=20-=20removed=20promises...=20it's=20better=20to=20?= =?UTF-8?q?call=20the=20callback=20instead;=20-=20removed=20deferList.=20-?= =?UTF-8?q?=20removed=20triggers=20from=20directive,=20it=20wasn't=20=20a?= =?UTF-8?q?=20clean=20solutions,=20now=20it's=20using=20the=20service=20di?= =?UTF-8?q?rectly,.=20-=20updated=20version=20and=20build=20-=20Update=20R?= =?UTF-8?q?EADME.md=20-=20added=20=C2=B4ng-intro-disable-button=C2=B4=20a?= =?UTF-8?q?=20directive=20responsible=20to=20disable/enable=20buttons=20wh?= =?UTF-8?q?en=20the=20intro=20opens=20and=20when=20the=20directive=20is=20?= =?UTF-8?q?added=20to=20a=20DOM.=20-=20=20updated=20the=20example.=20-=20a?= =?UTF-8?q?dded=20wiki=20url;=20-=20fixed=20some=20typos.=20-=20fixed=20ve?= =?UTF-8?q?rsion.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 62 ++++------ build/angular-intro.min.js | 4 +- build/angular-intro.min.js.map | 2 +- example/app.js | 118 +++++++++++++----- example/index.html | 27 +++- package.json | 2 +- src/angular-intro.js | 218 ++++++++++++++++----------------- 7 files changed, 243 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index 1e6f46e..01fcdfd 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This project will return the whole angular module so if you want to use as a dep ## How to use -You can use the two main directives, which are `ng-intro-options` and `ng-intro-method`, or you can include the service called `ngIntroService` +It's possible to include on your controller the service `ngIntroService` and customize as you need, or you may configure on your view the directives which are `ng-intro-options`, `ng-intro-method` and `ng-intro-disable-button`. ### Setting Options @@ -49,9 +49,10 @@ The directive will create a method on `$scope.CallMe` so that you can invoke it ### Call the start method -You can invoke it from an event such a click, - -`ng-click="CallMe();"` +You can invoke it from an event such as click. +` +ng-click="CallMe();" +` as long as you are still in the same controller scope. You can also specify a step number in the method call, `CallMe(3);`. @@ -74,70 +75,59 @@ Intro.js provides several callbacks. You can receive these callbacks in your co `ng-intro-onchange="ChangeEvent"` In your controller, create `ChangeEvent` - +```javascript $scope.ChangeEvent = function (targetElement, scope) { console.log("Change Event called"); console.log(targetElement); //The target element console.log(this); //The IntroJS object }; +``` -The other intro.js callbacks you can specify are `ng-intro-oncomplete`, `ng-intro-onexit`, `ng-intro-onchange` `ng-intro-onbeforechange` and `ng-intro-onafterchange`. +The other intro.js callbacks you can specify are `ng-intro-oncomplete`, `ng-intro-onexit`, `ng-intro-onchange`, `ng-intro-onbeforechange`, `ng-intro-onafterchange`, `ng-intro-onhintsadded`, `ng-intro-onhintclick` and `ng-intro-onhintclose`. ### As a service -There are two ways of make use of callbacks: - -**Using promises** - -The methods that return promises: +In your controller: +```javascript + ngIntroService.onComplete(function(){ + console.log('on complete callback!') + }); +``` +the list of supported callbacks are: * `onComplete` * `onExit` * `onBeforeChange` -* `onAfterChange` * `onChange` - -**Using watches (not recommended, available for compatibility)** - - `scope.$on('ngIntro-onAfterChange', function () { - ngIntro.exit(); - ยด - Its triggers are: - -* `ngIntro-onComplete` -* `ngIntro-onBeforeChange` -* `ngIntro-onChange` -* `ngIntro-onAfterChange` -* `ngIntro-onExit` - -* `ngIntro-onHintclick` -* `ngIntro-onHintclose` -* `ngIntro-onHintsAdded` - - - +* `onAfterChange` +* `onHintClick` +* `onHintClose` +* `onHintsAdded` ### Exit Method **Directive** - `ng-intro-exit-method="ExitMe"` + **Callback** - `$scope.ExitMe(function() { //callback } );` You can also call `$scope.ExitMe()` from your controller. **Service** - `ngIntroService.exit()` -**Callback** - `ngIntroService.onExit().then(function(){ - console.log('do something.') + +**Callback** - `ngIntroService.onExit(function(){ + console.log('do something.'); });` ### Plunker -You may use as Directive [as shown here](http://plnkr.co/edit/wo9EzfbOFjM7NDoAvmjA?p=preview) +You may use as Directive standalone without injecting ngIntroService [as shown here](http://plnkr.co/edit/wo9EzfbOFjM7NDoAvmjA?p=preview) or -alternatively as Service [as shown here](http://plnkr.co/edit/4JdONL) +alternatively as Service, [as shown here](http://plnkr.co/edit/4JdONL) +*i've added the directive, but it's not required, it's there to show the compatibility between both* ## How to build diff --git a/build/angular-intro.min.js b/build/angular-intro.min.js index c4462e0..cdb5a10 100644 --- a/build/angular-intro.min.js +++ b/build/angular-intro.min.js @@ -1,4 +1,4 @@ -/*! angular-intro.js - v3.2.0 - 2017-02-25 */ +/*! angular-intro.js - v3.1.1 - 2017-03-03 */ -!function(a,b){"function"==typeof define&&define.amd?define(["angular","intro.js"],b):"object"==typeof exports?module.exports=b(require("angular"),require("intro.js")):a.angularIntroJs=b(a.angular,a.introJs)}(this,function(a,b){function c(){this.message="Intro.js is not available. Make sure it is properly loaded.",this.name="IntroJsNotAvailable"}"object"==typeof b&&(b=b.introJs);var d=a.module("angular-intro",[]);return d.factory("ngIntroService",["$rootScope","$q",function(a,d){function e(a){x.setOptions(a)}function f(a){"number"==typeof a?x.start().goToStep(a):x.start()}function g(){x.exit()}function h(){x.previousStep()}function i(){x.nextStep()}function j(){x.refresh()}function k(){var b=d.defer();return y.push(b),x.oncomplete(function(){a.$broadcast("ngIntro-onComplete"),b.resolve()}),b.promise}function l(){var b=d.defer();return y.push(b),x.onbeforechange(function(b){a.$broadcast("ngIntro-onBeforeChange")}),b.promise}function m(){var b=d.defer();return y.push(b),x.onchange(function(c){a.$broadcast("ngIntro-onChange"),b.resolve()}),b.promise}function n(){"undefined"!=typeof x&&x.exit();for(var a=0;ah.length;a++)h[a]()}var h=[];d.ngIntroOncomplete&&d.$on("ngIntro-onComplete",function(){d.ngIntroOncomplete.call(this,d),b(function(){d.$digest()}),g()}),d.ngIntroOnexit&&d.$on("ngIntro-onExit",function(){d.ngIntroOnexit.call(this,d),b(function(){d.$digest()}),g()}),d.ngIntroOnbeforechange&&d.$on("ngIntro-onBeforeChange",function(){d.ngIntroOnbeforechange.call(this,targetElement,d),b(function(){d.$digest()})}),d.ngIntroOnchange&&d.$on("ngIntro-onChange",function(){d.ngIntroOnchange.call(this,targetElement,d),b(function(){d.$digest()})}),d.ngIntroOnafterchange&&d.$on("ngIntro-onAfterChange",function(){d.ngIntroOnafterchange.call(this,targetElement,d),b(function(){d.$digest()})}),d.ngIntroMethod=function(a){c.setOptions(d.ngIntroOptions),c.start(a)},d.ngIntroHintsMethod=function(){c.setOptions(d.ngIntroOptions),c.start(step),d.ngIntroOnhintsadded&&d.$on("ngIntro-onHintsAdded",function(){d.ngIntroOnhintsadded.call(this,targetElement,d),b(function(){d.$digest()})}),d.ngIntroOnhintclick&&d.$on("ngIntro-onHintClick",function(){d.ngIntroOnhintclick.call(this,targetElement,d),b(function(){d.$digest()})}),d.ngIntroOnhintclose&&d.$on("ngIntro-onHintClose",function(){d.ngIntroOnhintclose.call(this,targetElement,d),b(function(){d.$digest()})}),intro.addHints()},d.ngIntroShowHint=function(a){intro.showHint(a)},d.ngIntroShowHints=function(){intro.showHints()},d.ngIntroHideHint=function(a){intro.hideHint(a)},d.ngIntroHideHints=function(){intro.hideHints()},d.ngIntroNextMethod=function(){c.next()},d.ngIntroPreviousMethod=function(){c.previous()},d.ngIntroExitMethod=function(b){c.exit(),a.isFunction(b)&&b()},d.ngIntroRefreshMethod=function(){c.refresh()};var i=d.$watch("ngIntroAutostart",function(){d.ngIntroAutostart&&b(function(){d.ngIntroMethod()}),i()});h.push(d.$on("$locationChangeStart",function(){c.exit()})),h.push(d.$on("$locationChangeSuccess",function(){c.exit()})),d.ngIntroAutorefresh&&h.push(d.$watch(function(){c.refresh()})),h.push(d.$on("$destroy",function(){c.exit()})),d.$on("$destroy",function(){g()})}}}]),d}); +!function(a,b){"function"==typeof define&&define.amd?define(["angular","intro.js"],b):"object"==typeof exports?module.exports=b(require("angular"),require("intro.js")):a.angularIntroJs=b(a.angular,a.introJs)}(this,function(a,b){function c(){this.message="Intro.js is not available. Make sure it is properly loaded.",this.name="IntroJsNotAvailable"}"object"==typeof b&&(b=b.introJs);var d=a.module("angular-intro",[]);return d.factory("ngIntroService",["$q",function(d){function e(b,c){a.isFunction(c)&&(B[b]=c)}function f(a){delete B[a]}function g(a){A.setOptions(a)}function h(a){"number"==typeof a?A.start().goToStep(a):A.start(),i("open")}function i(b){for(var c in B)B.hasOwnProperty(c)&&a.isFunction(B[c])&&B[c](b)}function j(){A.exit(),i("closed")}function k(){A.previousStep(),i("open")}function l(){A.nextStep(),i("open")}function m(){A.refresh()}function n(b){return A.oncomplete(function(){a.isFunction(b)&&b(),i("closed")})}function o(b){return A.onbeforechange(function(){a.isFunction(b)&&b()})}function p(b){return A.onchange(function(){a.isFunction(b)&&b()})}function q(c){return"undefined"!=typeof A&&A.exit(),A=new b,i("closed"),a.isFunction(c)&&c(),A}function r(b){return A.onafterchange(function(c){a.isFunction(b)&&b()})}function s(b){return A.onexit(function(){i("closed"),a.isFunction(b)&&b()})}function t(){return A.addHints()}function u(){return A.showHints()}function v(a){return A.hideHint(a)}function w(){return A.hideHints()}function x(b){A.onhintclick(function(){a.isFunction(b)&&b()})}function y(b){return A.onhintclose(function(){a.isFunction(b)&&b()})}function z(b){return A.onhintclose(function(){a.isFunction(b)&&b()})}if("function"!=typeof b)throw new c;var A,B={},C={addListener:e,removeListener:f,setOptions:g,start:h,exit:j,clear:q,previous:k,next:l,refresh:m,onComplete:n,onExit:s,onBeforeChange:o,onAfterChange:r,onChange:p,addHints:t,showHints:u,hideHint:v,hideHints:w,onHintClick:x,onHintClose:y,onHintsAdded:z};return Object.defineProperty(C,"intro",{get:function(){return A},enumerable:!0,configurable:!0}),q(),C}]).directive("ngIntroDisableButton",["ngIntroService","$compile",function(a,b){var c=0;return{restrict:"A",priority:1,scope:{introDisableButton:"="},link:function(b,d,e){var f="disabledBtn"+c++;a.addListener(f,function(a){"open"===a?e.$set("disabled","disabled"):(delete e.disabled,d.removeAttr("disabled"))}),b.$on("$destroy",function(){a.removeListener(f)})}}}]).directive("ngIntroOptions",["$timeout","ngIntroService",function(b,c){return{restrict:"A",scope:{ngIntroMethod:"=",ngIntroExitMethod:"=?",ngIntroNextMethod:"=?",ngIntroPreviousMethod:"=?",ngIntroRefreshMethod:"=?",ngIntroOptions:"=",ngIntroOncomplete:"=",ngIntroOnexit:"=",ngIntroOnchange:"=",ngIntroOnbeforechange:"=",ngIntroOnafterchange:"=",ngIntroAutostart:"=",ngIntroAutorefresh:"=",ngIntroHintsMethod:"=?",ngIntroOnhintsadded:"=",ngIntroOnhintclick:"=?",ngIntroOnhintclose:"=?",ngIntroShowHint:"=?",ngIntroShowHints:"=?",ngIntroHideHint:"=?",ngIntroHideHints:"=?"},link:function(d,e,f){function g(){for(var a=0;a>h.length;a++)h[a]()}var h=[];d.ngIntroOncomplete&&c.onComplete(d.ngIntroOncomplete),d.ngIntroOnexit&&c.onExit(d.ngIntroOnexit),d.ngIntroOnbeforechange&&c.onBeforeChange(d.ngIntroOnbeforechange),d.ngIntroOnchange&&c.onChange(d.ngIntroOnchange),d.ngIntroOnafterchange&&c.onAfterChange(d.ngIntroOnafterchange),d.ngIntroMethod=function(a){c.setOptions(d.ngIntroOptions),c.start(a)},d.ngIntroHintsMethod=function(){c.setOptions(d.ngIntroOptions),c.start(step),d.ngIntroOnhintsadded&&c.onHintsAdded(d.ngIntroOnbeforechange),d.ngIntroOnhintclick&&c.onHintClick(d.ngIntroOnbeforechange),d.ngIntroOnhintclose&&c.onHintClick(d.ngIntroOnbeforechange),intro.addHints()},d.ngIntroShowHint=function(a){intro.showHint(a)},d.ngIntroShowHints=function(){intro.showHints()},d.ngIntroHideHint=function(a){intro.hideHint(a)},d.ngIntroHideHints=function(){intro.hideHints()},d.ngIntroNextMethod=function(){c.next()},d.ngIntroPreviousMethod=function(){c.previous()},d.ngIntroExitMethod=function(b){c.exit(),a.isFunction(b)&&b()},d.ngIntroRefreshMethod=function(){c.refresh()};var i=d.$watch("ngIntroAutostart",function(){d.ngIntroAutostart&&b(function(){d.ngIntroMethod()}),i()});h.push(d.$on("$locationChangeStart",function(){c.exit()})),h.push(d.$on("$locationChangeSuccess",function(){c.exit()})),d.ngIntroAutorefresh&&h.push(d.$watch(function(){c.refresh()})),h.push(d.$on("$destroy",function(){c.exit()})),d.$on("$destroy",function(){g()})}}}]),d}); //# sourceMappingURL=angular-intro.min.js.map \ No newline at end of file diff --git a/build/angular-intro.min.js.map b/build/angular-intro.min.js.map index 594d19e..d9dc28e 100644 --- a/build/angular-intro.min.js.map +++ b/build/angular-intro.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/angular-intro.js"],"names":["root","factory","define","amd","exports","module","require","angularIntroJs","angular","introJs","this","IntroJsNotAvailable","message","name","ngIntro","$rootScope","$q","setOptions","options","intro","start","step","goToStep","exit","previous","previousStep","next","nextStep","refresh","onComplete","q","defer","deferList","push","oncomplete","$broadcast","resolve","promise","onBeforeChange","onbeforechange","targetElement","onChange","onchange","clear","i","length","reject","onAfterChange","onafterchange","onExit","callback","onexit","addHints","showHints","hideHint","hideHints","onHintClick","onhintclick","onHintClose","onhintclose","onHintsAdded","service","introObject","directive","$timeout","restrict","scope","ngIntroMethod","ngIntroExitMethod","ngIntroNextMethod","ngIntroPreviousMethod","ngIntroRefreshMethod","ngIntroOptions","ngIntroOncomplete","ngIntroOnexit","ngIntroOnchange","ngIntroOnbeforechange","ngIntroOnafterchange","ngIntroAutostart","ngIntroAutorefresh","ngIntroHintsMethod","ngIntroOnhintsadded","ngIntroOnhintclick","ngIntroOnhintclose","ngIntroShowHint","ngIntroShowHints","ngIntroHideHint","ngIntroHideHints","link","element","attrs","clearWatches","destroy","$on","call","$digest","id","showHint","isFunction","autoStartWatch","$watch"],"mappings":";;CAAC,SAAUA,EAAMC,GACM,kBAAXC,SAAyBA,OAAOC,IAC1CD,QAA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at end of file +{"version":3,"sources":["../src/angular-intro.js"],"names":["root","factory","define","amd","exports","module","require","angularIntroJs","angular","introJs","this","IntroJsNotAvailable","message","name","ngIntro","$q","addListener","cb","isFunction","notifyList","removeListener","setOptions","options","intro","start","step","goToStep","notifyListeners","newSts","key","hasOwnProperty","exit","previous","previousStep","next","nextStep","refresh","onComplete","oncomplete","onBeforeChange","onbeforechange","onChange","onchange","clear","onAfterChange","onafterchange","targetElement","onExit","onexit","addHints","showHints","hideHint","hideHints","onHintClick","onhintclick","onHintClose","onhintclose","onHintsAdded","service","Object","defineProperty","get","enumerable","configurable","directive","ngIntroService","$compile","id","restrict","priority","scope","introDisableButton","link","elm","attrs","uniqueId","value","$set","disabled","removeAttr","$on","$timeout","ngIntroMethod","ngIntroExitMethod","ngIntroNextMethod","ngIntroPreviousMethod","ngIntroRefreshMethod","ngIntroOptions","ngIntroOncomplete","ngIntroOnexit","ngIntroOnchange","ngIntroOnbeforechange","ngIntroOnafterchange","ngIntroAutostart","ngIntroAutorefresh","ngIntroHintsMethod","ngIntroOnhintsadded","ngIntroOnhintclick","ngIntroOnhintclose","ngIntroShowHint","ngIntroShowHints","ngIntroHideHint","ngIntroHideHints","element","clearWatches","i","destroy","length","showHint","callback","autoStartWatch","$watch","push"],"mappings":";;CAAC,SAAUA,EAAMC,GACM,kBAAXC,SAAyBA,OAAOC,IAC1CD,QAAQ,UAAW,YAAaD,GACH,gBAAZG,SACjBC,OAAOD,QAAUH,EAAQK,QAAQ,WAAYA,QAAQ,aAErDN,EAAKO,eAAiBN,EAAQD,EAAKQ,QAASR,EAAKS,UAEjDC,KAAM,SAAUF,EAASC,GAM1B,QAASE,KACRD,KAAKE,QAAU,8DACfF,KAAKG,KAAO,sBAPS,gBAAXJ,KACVA,EAAUA,EAAQA,QAEnB,IAAIK,GAAUN,EAAQH,OAAO,mBAkW7B,OA3VAS,GAAQb,QAAQ,kBAAmB,KAAM,SAAUc,GA6ClD,QAASC,GAAYH,EAAMI,GACvBT,E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ACnC/F,EAAQiB,OACJvB,EAAQU,WAAW2F,IAAWA,KAGnCvC,EAAMgB,qBAAuB,WAC5BxE,EAAQsB,UAGT,IAAI0E,GAAiBxC,EAAMyC,OAAO,mBAAoB,WACjDzC,EAAMuB,kBACTZ,EAAS,WACRX,EAAMY,kBAGR4B,KAGDJ,GAAQM,KAAK1C,EAAMU,IAAI,uBAAwB,WAC7ClE,EAAQiB,UAGV2E,EAAQM,KAAK1C,EAAMU,IAAI,yBAA0B,WAChDlE,EAAQiB,UAGLuC,EAAMwB,oBACTY,EAAQM,KAAK1C,EAAMyC,OAAO,WACzBjG,EAAQsB,aAIVsE,EAAQM,KAAK1C,EAAMU,IAAI,WAAY,WAClClE,EAAQiB,UAGTuC,EAAMU,IAAI,WAAY,WACrBwB,WAWG1F","file":"angular-intro.min.js"} \ No newline at end of file diff --git a/example/app.js b/example/app.js index 64cb44a..f15b54d 100644 --- a/example/app.js +++ b/example/app.js @@ -1,30 +1,6 @@ var app = angular.module('myApp', ['angular-intro']); -app.controller('MyController', function ($scope) { - - $scope.CompletedEvent = function (scope) { - console.log("Completed Event called"); - }; - - $scope.ExitEvent = function (scope) { - console.log("Exit Event called"); - }; - - $scope.ChangeEvent = function (targetElement, scope) { - console.log("Change Event called"); - console.log(targetElement); //The target element - console.log(this); //The IntroJS object - }; - - $scope.BeforeChangeEvent = function (targetElement, scope) { - console.log("Before Change Event called"); - console.log(targetElement); - }; - - $scope.AfterChangeEvent = function (targetElement, scope) { - console.log("After Change Event called"); - console.log(targetElement); - }; +app.controller('MyController', function ($scope,ngIntroService) { $scope.IntroOptions = { steps:[ @@ -53,15 +29,99 @@ app.controller('MyController', function ($scope) { } ], showStepNumbers: false, + showBullets: false, exitOnOverlayClick: true, exitOnEsc:true, - nextLabel: 'NEXT!', + nextLabel: 'next', prevLabel: 'Previous', skipLabel: 'Exit', doneLabel: 'Thanks' }; - $scope.ShouldAutoStart = false; - -}); + $scope.CompletedEvent = function(){ + console.log('[directive] completed Event') + } + $scope.ExitEvent= function(){ + console.log('[directive] exit Event') + } + $scope.ChangeEvent = function(){ + console.log('[directive] change Event') + } + $scope.BeforeChangeEvent= function(){ + console.log('[directive] beforeChange Event') + } + $scope.AfterChangeEvent= function(){ + console.log('[directive] after change Event') + } + $scope.clearAndStartNewIntro = function(){ + $scope.IntroOptions = { + steps:[ + { + element: document.querySelector('#step1'), + intro: "After being cleared, step 1" + }, + { + element: '#step2', + intro: 'Setup and details :)', + position: 'right' + }, + { + element: '.jumbotron', + intro: 'We added a small feature, adding
ng-intro-disable-button
your buttons will be disabled when introJs is open :)

if you\'re using anchor tags, you should prevent ng-click manually.

click here for more details.

' + } + ], + showStepNumbers: true, + showBullets: true, + exitOnOverlayClick: false, + exitOnEsc:false, + nextLabel: 'Next!', + prevLabel: 'Previous', + skipLabel: 'Skip', + doneLabel: 'Done' + }; + + + ngIntroService.clear(); + ngIntroService.setOptions($scope.IntroOptions); + + ngIntroService.onComplete(function(){ + console.log('update some cookie or localstorage.') + }) + + ngIntroService.onExit(function(){ + console.log("[service] exit"); + }) + + ngIntroService.onBeforeChange(function(){ + console.log("[service] before change"); + }) + + ngIntroService.onChange(()=>{ + console.log("[service] on change"); + }) + + ngIntroService.onAfterChange(()=>{ + console.log("[service] after Change"); + }) + + ngIntroService.start(); + } +}).directive('ngClick', function () { + return { + restrict: 'A', + priority: 1, + terminal: true, + link: function (scope, element, attr) { + var clickAction = attr.ngClick; // get the current ngclick value + var d = element.bind('click',function () { + if (attr.disabled==undefined) {//check if the tag is available to be clicked + scope.$eval(clickAction) // call the event + } + }); + scope.$on('$destroy', function(){ + d(); // destroy the bind we created, so it a memory leak is prevented. + }) + } + }; +}); \ No newline at end of file diff --git a/example/index.html b/example/index.html index deacde4..f5deb1c 100644 --- a/example/index.html +++ b/example/index.html @@ -33,18 +33,24 @@

ng-intro

Angular Intro.js

-

AngularJS directives for intro.js

- Demo - Start at step 3 +

AngularJS service and directives for intro.js

+ Demo + Start at step 3 + + Replace current intro using the service +

Setup

Include the JS and CSS files for intro.js, and angular-intro.min.js. Add the module angular-intro to your app declaration.

- +

Include in your controller: ngIntroService.

+ +

Options

-

Set the options like so: ng-intro-options="IntroOptions". Define $scope.IntroOptions in your controller. The format is exactly the same as the original.

+ +

Not required, but both works well together
Set the options like so: ng-intro-options="IntroOptions". Define $scope.IntroOptions in your controller. The format is exactly the same as the original.

Method name

Pick a method name, ng-intro-method="CallMe". You can invoke the intro from elsewhere by calling CallMe();. You can also specify a step number using CallMe(3);. To autostart, use ng-intro-autostart="true"

@@ -57,11 +63,19 @@

Callbacks

Example

-

Set the options and method name: +

[using Directives]Set the options and method name:

 <div ng-controller="MyController"
      ng-intro-options="IntroOptions"
      ng-intro-method="CallMe" ...
+    
+		               
+

+

[using Controller] Set the options and start : +

+var introOptions = {};
+ngIntroService.clear();
+ngIntroService.setOptions(introOptions);
 		               

@@ -85,6 +99,7 @@

Ex

Call it either way

<button ng-click="CallMe();">Go</button>
$scope.CallMe();
+
[service]ngIntroService.start();

diff --git a/package.json b/package.json index a687d06..f3c5c1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-intro.js", - "version": "3.2.0", + "version": "3.1.1", "description": "Angular directive to wrap intro.js", "main": "src/angular-intro.js", "directories": { diff --git a/src/angular-intro.js b/src/angular-intro.js index ae46a2a..b89fb73 100644 --- a/src/angular-intro.js +++ b/src/angular-intro.js @@ -17,17 +17,17 @@ this.name = 'IntroJsNotAvailable'; } - ngIntro.factory("ngIntroService", ['$rootScope', '$q', function ($rootScope, $q) { + ngIntro.factory("ngIntroService", ['$q', function ($q) { if (typeof (introJs) !== 'function') { throw new IntroJsNotAvailable(); } var intro; + var notifyList = {}; - var deferList = []; var service = { - introObject: intro, - + addListener: addListener, + removeListener: removeListener, setOptions: setOptions, start: start, exit: exit, @@ -54,7 +54,22 @@ onHintClose: onHintClose, onHintsAdded: onHintsAdded, }; + Object.defineProperty(service, "intro", { + get: function () { + return intro; + }, + enumerable: true, + configurable: true + }); + function addListener(name, cb){ + if(angular.isFunction(cb)) + notifyList[name] = cb; + } + function removeListener(name){ + delete notifyList[name]; + + } function setOptions(options) { intro.setOptions(options); } @@ -65,142 +80,143 @@ } else { intro.start(); } + notifyListeners('open'); + } + function notifyListeners(newSts){ + for(var key in notifyList){ + if(notifyList.hasOwnProperty(key)){ + if(angular.isFunction(notifyList[key])) + notifyList[key](newSts); + } + + } } - function exit() { intro.exit(); + notifyListeners('closed'); } function previous() { intro.previousStep(); + notifyListeners('open'); } function next() { intro.nextStep(); + notifyListeners('open'); } function refresh() { intro.refresh(); } - function onComplete() { - var q = $q.defer(); - deferList.push(q); - - intro.oncomplete(function () { - $rootScope.$broadcast('ngIntro-onComplete'); - q.resolve(); + function onComplete(cb) { + return intro.oncomplete(function () { + if(angular.isFunction(cb)) cb(); + notifyListeners('closed'); }); - - return q.promise; } - function onBeforeChange() { - var q = $q.defer(); - deferList.push(q); - - intro.onbeforechange(function (targetElement) { - $rootScope.$broadcast('ngIntro-onBeforeChange'); + function onBeforeChange(cb) { + return intro.onbeforechange(function () { + if(angular.isFunction(cb)) cb(); }); - - return q.promise; } - function onChange() { - var q = $q.defer(); - deferList.push(q); - - intro.onchange(function (targetElement) { - $rootScope.$broadcast('ngIntro-onChange'); - q.resolve(); + function onChange(cb) { + return intro.onchange(function() { + if(angular.isFunction(cb)) cb(); }); - return q.promise; + } - function clear(){ + function clear(cb){ if(typeof(intro) !=='undefined') intro.exit(); - for(var i = 0; i< deferList.length; i++){ - deferList[i].reject(); - } - deferList = []; intro = new introJs(); + + notifyListeners('closed'); + + if(angular.isFunction(cb)) cb(); + + return intro; } - function onAfterChange() { - var q = $q.defer(); - deferList.push(q); - - intro.onafterchange(function (targetElement) { - $rootScope.$broadcast('ngIntro-onAfterChange'); - q.resolve(); + function onAfterChange(cb) { + return intro.onafterchange(function (targetElement) { + if(angular.isFunction(cb)) cb(); }); - return q.promise; } - function onExit(callback) { - var q = $q.defer(); - deferList.push(q); - - intro.onexit(function () { - $rootScope.$broadcast('ngIntro-onExit'); - q.resolve(); + function onExit(cb) { + return intro.onexit(function () { + notifyListeners('closed'); + if(angular.isFunction(cb)) cb(); }); - return q.promise; } function addHints(){ - intro.addHints(); + return intro.addHints(); } function showHints(){ - intro.showHints(); + return intro.showHints(); } function hideHint(step){ - intro.hideHint(step); + return intro.hideHint(step); } function hideHints(){ - intro.hideHints(); + return intro.hideHints(); } - function onHintClick(){ - var q = $q.defer(); - deferList.push(q); - + function onHintClick(cb){ intro.onhintclick(function () { - $rootScope.$broadcast('ngIntro-onHintClick'); - q.resolve(); + if(angular.isFunction(cb)) cb(); }); - return q.promise; } - function onHintClose(){ - var q = $q.defer(); - deferList.push(q); - - intro.onhintclose(function () { - $rootScope.$broadcast('ngIntro-onHintClose'); - q.resolve(); + function onHintClose(cb){ + return intro.onhintclose(function () { + if(angular.isFunction(cb)) cb(); }); - return q.promise; } - function onHintsAdded(){ - var q = $q.defer(); - deferList.push(q); - - intro.onhintclose(function () { - $rootScope.$broadcast('ngIntro-onHintsAdded'); - q.resolve(); + function onHintsAdded(cb){ + return intro.onhintclose(function () { + if(angular.isFunction(cb)) cb(); }); - return q.promise; } clear(); return service; + }]).directive('ngIntroDisableButton',['ngIntroService','$compile', function(ngIntroService, $compile){ + var id = 0; + return{ + restrict:'A', + priority: 1, + scope:{ + introDisableButton: '=' + }, + link: function (scope, elm, attrs) { + var uniqueId = "disabledBtn"+id++; + ngIntroService.addListener(uniqueId, function(value){ + if (value === 'open') { + attrs.$set('disabled', 'disabled'); + } else { + delete attrs.disabled; + elm.removeAttr('disabled'); + } + }); + + scope.$on('$destroy', function(){ + ngIntroService.removeListener(uniqueId); + }); + + } + }; }]).directive('ngIntroOptions', ['$timeout', 'ngIntroService', function ($timeout, ngIntro) { return { restrict: 'A', @@ -233,40 +249,23 @@ var destroy = []; if (scope.ngIntroOncomplete) { - scope.$on('ngIntro-onComplete', function () { - scope.ngIntroOncomplete.call(this, scope); - $timeout(function () { scope.$digest(); }); - clearWatches(); - }); + ngIntro.onComplete(scope.ngIntroOncomplete); } if (scope.ngIntroOnexit) { - scope.$on('ngIntro-onExit', function () { - scope.ngIntroOnexit.call(this, scope); - $timeout(function () { scope.$digest(); }); - clearWatches(); - }); + ngIntro.onExit(scope.ngIntroOnexit); } if (scope.ngIntroOnbeforechange) { - scope.$on('ngIntro-onBeforeChange', function () { - scope.ngIntroOnbeforechange.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onBeforeChange(scope.ngIntroOnbeforechange); } if (scope.ngIntroOnchange) { - scope.$on('ngIntro-onChange', function () { - scope.ngIntroOnchange.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onChange(scope.ngIntroOnchange); } if (scope.ngIntroOnafterchange) { - scope.$on('ngIntro-onAfterChange', function () { - scope.ngIntroOnafterchange.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onAfterChange(scope.ngIntroOnafterchange); } scope.ngIntroMethod = function (step) { @@ -275,29 +274,19 @@ }; scope.ngIntroHintsMethod = function() { - ngIntro.setOptions(scope.ngIntroOptions); ngIntro.start(step); if(scope.ngIntroOnhintsadded) { - scope.$on('ngIntro-onHintsAdded', function () { - scope.ngIntroOnhintsadded.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onHintsAdded(scope.ngIntroOnbeforechange); } if(scope.ngIntroOnhintclick) { - scope.$on('ngIntro-onHintClick', function () { - scope.ngIntroOnhintclick.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onHintClick(scope.ngIntroOnbeforechange); } if(scope.ngIntroOnhintclose) { - scope.$on('ngIntro-onHintClose', function () { - scope.ngIntroOnhintclose.call(this, targetElement, scope); - $timeout(function () { scope.$digest(); }); - }); + ngIntro.onHintClick(scope.ngIntroOnbeforechange); } intro.addHints(); @@ -376,5 +365,4 @@ }; }]); return ngIntro; -})); - +})); \ No newline at end of file