diff --git a/README.md b/README.md index 49083f0..d089dc2 100644 --- a/README.md +++ b/README.md @@ -43,17 +43,18 @@ The directive itself is called *modal-dialog*. The only required attribute is `s There are a few options that be configured inline with attributes. -| Option | Default | Description | -| -------------- | ------- | ----------------------------------------------------------------- | -| dialog-title | null | Title placed in the header of the modal dialog. | -| width | 50% | Width of the dialog. Can be specified in px or %. | -| height | 50% | Height of the dialog. Can be specified in px or %. | -| on-close | null | Call a function when the dialog is closed. Ex: `on-close='foo()'` | +| Option | Default | Description | +| ---------------- | ------- | ----------------------------------------------------------------- | +| dialog-title | null | Title placed in the header of the modal dialog. | +| width | 50% | Width of the dialog. Can be specified in px or %. | +| height | 50% | Height of the dialog. Can be specified in px or %. | +| on-close | null | Call a function when the dialog is closed. Ex: `on-close='foo()'` | +| mantain-position | false | It keeps dialog current position | **Example:** ```html - +

Dialog content goes in here

``` diff --git a/demo.html b/demo.html index 7168aaa..ffbac47 100644 --- a/demo.html +++ b/demo.html @@ -12,7 +12,7 @@
- +

This is some html content

diff --git a/dist/ng-modal.js b/dist/ng-modal.js index 6879162..54e78c1 100644 --- a/dist/ng-modal.js +++ b/dist/ng-modal.js @@ -34,7 +34,8 @@ scope: { show: '=', dialogTitle: '@', - onClose: '&?' + onClose: '&?', + mantainPosition: '=' }, replace: true, transclude: true, @@ -56,10 +57,12 @@ return scope.show = false; }; scope.$watch('show', function(newVal, oldVal) { - if (newVal && !oldVal) { - document.getElementsByTagName("body")[0].style.overflow = "hidden"; - } else { - document.getElementsByTagName("body")[0].style.overflow = ""; + if (!scope.mantainPosition || scope.mantainPosition === '') { + if (newVal && !oldVal) { + document.getElementsByTagName("body")[0].style.overflow = "hidden"; + } else { + document.getElementsByTagName("body")[0].style.overflow = ""; + } } if ((!newVal && oldVal) && (scope.onClose != null)) { return scope.onClose(); diff --git a/dist/ng-modal.min.js b/dist/ng-modal.min.js index 61a0b6e..410f26c 100644 --- a/dist/ng-modal.min.js +++ b/dist/ng-modal.min.js @@ -1 +1 @@ -(function(){var a;a=angular.module("ngModal",[]),a.provider("ngModalDefaults",function(){return{options:{closeButtonHtml:"X"},$get:function(){return this.options},set:function(a,b){var c,d,e;if("object"==typeof a){e=[];for(c in a)d=a[c],e.push(this.options[c]=d);return e}return this.options[a]=b}}}),a.directive("modalDialog",["ngModalDefaults","$sce",function(a,b){return{restrict:"E",scope:{show:"=",dialogTitle:"@",onClose:"&?"},replace:!0,transclude:!0,link:function(c,d,e){var f,g;return f=function(){return c.closeButtonHtml=b.trustAsHtml(a.closeButtonHtml)},g=function(){return c.dialogStyle={},e.width&&(c.dialogStyle.width=e.width),e.height?c.dialogStyle.height=e.height:void 0},c.hideModal=function(){return c.show=!1},c.$watch("show",function(a,b){return document.getElementsByTagName("body")[0].style.overflow=a&&!b?"hidden":"",!a&&b&&null!=c.onClose?c.onClose():void 0}),f(),g()},template:"

\n
\n
\n \n
\n
\n
\n
\n
\n
"}}])}).call(this); \ No newline at end of file +(function(){var a;a=angular.module("ngModal",[]),a.provider("ngModalDefaults",function(){return{options:{closeButtonHtml:"X"},$get:function(){return this.options},set:function(a,b){var c,d,e;if("object"==typeof a){e=[];for(c in a)d=a[c],e.push(this.options[c]=d);return e}return this.options[a]=b}}}),a.directive("modalDialog",["ngModalDefaults","$sce",function(a,b){return{restrict:"E",scope:{show:"=",dialogTitle:"@",onClose:"&?",mantainPosition:"="},replace:!0,transclude:!0,link:function(c,d,e){var f,g;return f=function(){return c.closeButtonHtml=b.trustAsHtml(a.closeButtonHtml)},g=function(){return c.dialogStyle={},e.width&&(c.dialogStyle.width=e.width),e.height?c.dialogStyle.height=e.height:void 0},c.hideModal=function(){return c.show=!1},c.$watch("show",function(a,b){return c.mantainPosition&&""!==c.mantainPosition||(a&&!b?document.getElementsByTagName("body")[0].style.overflow="hidden":document.getElementsByTagName("body")[0].style.overflow=""),!a&&b&&null!=c.onClose?c.onClose():void 0}),f(),g()},template:"
\n
\n
\n \n
\n
\n
\n
\n
\n
"}}])}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index e82d4cc..08e034e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngModal", - "version": "1.2.2" + "version": "1.2.2", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-coffee": "~0.7", diff --git a/src/ng-modal.coffee b/src/ng-modal.coffee index 65da273..9ae772f 100644 --- a/src/ng-modal.coffee +++ b/src/ng-modal.coffee @@ -30,6 +30,7 @@ app.directive 'modalDialog', ['ngModalDefaults', '$sce', (ngModalDefaults, $sce) show: '=' dialogTitle: '@' onClose: '&?' + mantainPosition: '=' replace: true transclude: true link: (scope, element, attrs) -> @@ -45,10 +46,11 @@ app.directive 'modalDialog', ['ngModalDefaults', '$sce', (ngModalDefaults, $sce) scope.show = false scope.$watch('show', (newVal, oldVal) -> - if newVal && !oldVal - document.getElementsByTagName("body")[0].style.overflow = "hidden"; - else - document.getElementsByTagName("body")[0].style.overflow = ""; + if !scope.mantainPosition || scope.mantainPosition == '' + if newVal && !oldVal + document.getElementsByTagName("body")[0].style.overflow = "hidden"; + else + document.getElementsByTagName("body")[0].style.overflow = ""; if (!newVal && oldVal) && scope.onClose? scope.onClose() )