diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..baa91a3 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "bower_components" +} \ No newline at end of file diff --git a/example/js/app.js b/example/js/app.js index 89f0d52..6397c90 100644 --- a/example/js/app.js +++ b/example/js/app.js @@ -13,7 +13,7 @@ angular.module('app', ['angularHelpOverlay']).controller('MainCtrl', function ($ $scope.toggleHelp = function() { $scope.showHelp = !$scope.showHelp; - /*var picture = $('.jumbotron img'); + var picture = $('.jumbotron img'); if (picture.is(':visible')) { return ($('body').data('chardinJs')).toggle(); } else { @@ -22,7 +22,7 @@ angular.module('app', ['angularHelpOverlay']).controller('MainCtrl', function ($ }, 600, function() { return ($('body').data('chardinJs')).toggle(); }); - }*/ + } }; }); diff --git a/example/js/demo.js b/example/js/demo.js index 94365bc..2e4c5c2 100644 --- a/example/js/demo.js +++ b/example/js/demo.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript 1.6.2 (function() { $(function() { - //$('body').chardinJs(); + $('body').chardinJs(); $('a[data-toggle="chardinjs"]').on('click', function(e) { e.preventDefault(); if ($('.jumbotron img').is(':visible')) { diff --git a/lib/angular-help-overlay.js b/lib/angular-help-overlay.js index 7983555..b39ebe9 100644 --- a/lib/angular-help-overlay.js +++ b/lib/angular-help-overlay.js @@ -1,53 +1,65 @@ /*global angular:false */ +!(function () { -angular.module('angularHelpOverlay', []).directive('helpOverlay', ['$document', function ($document) { - var noop = false; // Special flag in case we get an a chardinJs change event outside of our control. - return { - restrict: 'A', - scope: { - helpOverlay: '=', - overlayStart: '&overlayStartCallback', - overlayStop: '&overlayStopCallback' - }, - link: function (scope, element, attrs) { - - $document.on('chardinJs:start', function (event) { - if (angular.isFunction(scope.overlayStart)) { - scope.overlayStart(event); - } - - if (scope.helpOverlay === false) { - scope.$apply(function () { - noop = true; - scope.helpOverlay = true; - }); - } - }); - - $document.on('chardinJs:stop', function (event) { - if (angular.isFunction(scope.overlayStop)) { - scope.overlayStop(event); - } - - if (scope.helpOverlay === true) { - scope.$apply(function () { - noop = true; - scope.helpOverlay = false; - }); - } - }); - - scope.$watch('helpOverlay', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (noop === true) { - noop = false; - } else if (newValue === true) { - $(element).chardinJs('start'); - } else if (newValue === false) { - $(element).chardinJs('stop'); + angular.module('angularHelpOverlay', []) + .directive('helpOverlay', HelpOverlay); + + HelpOverlay.$inject = ['$document']; + + //angular.module('angularHelpOverlay', []).directive('helpOverlay', ['$document', function ($document) { + + function HelpOverlay($document) { + var noop = false; // Special flag in case we get an a chardinJs change event outside of our control. + return { + restrict: 'A', + //controller: HelpOverlayController, + //controllerAs: 'vm', + scope: { + helpOverlay: '=', + overlayStart: '&overlayStartCallback', + overlayStop: '&overlayStopCallback' + }, + link: function (scope, element, attrs) { + + $(document).on('chardinJs:start', function (event) { + if (angular.isFunction(scope.overlayStart)) { + scope.overlayStart(event); } - } - }); - } - }; -}]); \ No newline at end of file + + if (scope.helpOverlay === false) { + scope.$apply(function () { + noop = true; + scope.helpOverlay = true; + }); + } + }); + + $(document).on('chardinJs:stop', function (event) { + if (angular.isFunction(scope.overlayStop)) { + scope.overlayStop(event); + } + + if (scope.helpOverlay === true) { + scope.$apply(function () { + noop = true; + scope.helpOverlay = false; + }); + } + }); + + scope.$watch('helpOverlay', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (noop === true) { + noop = false; + } else if (newValue === true) { + $(element).chardinJs('start'); + } else if (newValue === false) { + $(element).chardinJs('stop'); + } + } + }); + } + }; + } + +})(); diff --git a/lib/angular-help-overlay.min.js b/lib/angular-help-overlay.min.js index e6a69a4..87fede5 100644 --- a/lib/angular-help-overlay.min.js +++ b/lib/angular-help-overlay.min.js @@ -1,2 +1,2 @@ -/*! angular-help-overlay 2015-08-12 */ -angular.module("angularHelpOverlay",[]).directive("helpOverlay",["$document",function(a){var b=!1;return{restrict:"A",scope:{helpOverlay:"=",overlayStart:"&overlayStartCallback",overlayStop:"&overlayStopCallback"},link:function(c,d,e){a.on("chardinJs:start",function(a){angular.isFunction(c.overlayStart)&&c.overlayStart(a),c.helpOverlay===!1&&c.$apply(function(){b=!0,c.helpOverlay=!0})}),a.on("chardinJs:stop",function(a){angular.isFunction(c.overlayStop)&&c.overlayStop(a),c.helpOverlay===!0&&c.$apply(function(){b=!0,c.helpOverlay=!1})}),c.$watch("helpOverlay",function(a,c){a!==c&&(b===!0?b=!1:a===!0?$(d).chardinJs("start"):a===!1&&$(d).chardinJs("stop"))})}}}]); \ No newline at end of file +/*! angular-help-overlay 2017-07-16 */ +!function(){function a(a){var b=!1;return{restrict:"A",scope:{helpOverlay:"=",overlayStart:"&overlayStartCallback",overlayStop:"&overlayStopCallback"},link:function(a,c,d){$(document).on("chardinJs:start",function(c){angular.isFunction(a.overlayStart)&&a.overlayStart(c),a.helpOverlay===!1&&a.$apply(function(){b=!0,a.helpOverlay=!0})}),$(document).on("chardinJs:stop",function(c){angular.isFunction(a.overlayStop)&&a.overlayStop(c),a.helpOverlay===!0&&a.$apply(function(){b=!0,a.helpOverlay=!1})}),a.$watch("helpOverlay",function(a,d){a!==d&&(b===!0?b=!1:a===!0?$(c).chardinJs("start"):a===!1&&$(c).chardinJs("stop"))})}}}angular.module("angularHelpOverlay",[]).directive("helpOverlay",a),a.$inject=["$document"]}(); \ No newline at end of file diff --git a/src/angular-help-overlay.js b/src/angular-help-overlay.js index f1cda98..b39ebe9 100644 --- a/src/angular-help-overlay.js +++ b/src/angular-help-overlay.js @@ -1,53 +1,65 @@ /*global angular:false */ +!(function () { -angular.module('angularHelpOverlay', []).directive('helpOverlay', ['$document', function ($document) { - var noop = false; // Special flag in case we get an a chardinJs change event outside of our control. - return { - restrict: 'A', - scope: { - helpOverlay: '=', - overlayStart: '&overlayStartCallback', - overlayStop: '&overlayStopCallback' - }, - link: function (scope, element, attrs) { - - $(document).on('chardinJs:start', function (event) { - if (angular.isFunction(scope.overlayStart)) { - scope.overlayStart(event); - } - - if (scope.helpOverlay === false) { - scope.$apply(function () { - noop = true; - scope.helpOverlay = true; - }); - } - }); - - $(document).on('chardinJs:stop', function (event) { - if (angular.isFunction(scope.overlayStop)) { - scope.overlayStop(event); - } - - if (scope.helpOverlay === true) { - scope.$apply(function () { - noop = true; - scope.helpOverlay = false; - }); - } - }); - - scope.$watch('helpOverlay', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (noop === true) { - noop = false; - } else if (newValue === true) { - $(element).chardinJs('start'); - } else if (newValue === false) { - $(element).chardinJs('stop'); + angular.module('angularHelpOverlay', []) + .directive('helpOverlay', HelpOverlay); + + HelpOverlay.$inject = ['$document']; + + //angular.module('angularHelpOverlay', []).directive('helpOverlay', ['$document', function ($document) { + + function HelpOverlay($document) { + var noop = false; // Special flag in case we get an a chardinJs change event outside of our control. + return { + restrict: 'A', + //controller: HelpOverlayController, + //controllerAs: 'vm', + scope: { + helpOverlay: '=', + overlayStart: '&overlayStartCallback', + overlayStop: '&overlayStopCallback' + }, + link: function (scope, element, attrs) { + + $(document).on('chardinJs:start', function (event) { + if (angular.isFunction(scope.overlayStart)) { + scope.overlayStart(event); } - } - }); - } - }; -}]); + + if (scope.helpOverlay === false) { + scope.$apply(function () { + noop = true; + scope.helpOverlay = true; + }); + } + }); + + $(document).on('chardinJs:stop', function (event) { + if (angular.isFunction(scope.overlayStop)) { + scope.overlayStop(event); + } + + if (scope.helpOverlay === true) { + scope.$apply(function () { + noop = true; + scope.helpOverlay = false; + }); + } + }); + + scope.$watch('helpOverlay', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (noop === true) { + noop = false; + } else if (newValue === true) { + $(element).chardinJs('start'); + } else if (newValue === false) { + $(element).chardinJs('stop'); + } + } + }); + } + }; + } + +})();