diff options
| author | Vojta Jina | 2012-01-06 19:19:31 -0800 | 
|---|---|---|
| committer | Vojta Jina | 2012-01-07 00:18:22 -0800 | 
| commit | 5c197660638b8f4f603ed087bedf88cb1c980832 (patch) | |
| tree | 00da63f40b3b3d7213fb4fe799c5cf7b7f9e52b0 /src | |
| parent | f2119c752425661e0ef4c772f14a3b6755b44525 (diff) | |
| download | angular.js-5c197660638b8f4f603ed087bedf88cb1c980832.tar.bz2 | |
feat(ng:include): enable/disable scrolling through autoscroll attribute
Diffstat (limited to 'src')
| -rw-r--r-- | src/widgets.js | 15 | 
1 files changed, 13 insertions, 2 deletions
diff --git a/src/widgets.js b/src/widgets.js index 155b8c08..63ddaf36 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -43,6 +43,13 @@   *                 instance of angular.module.ng.$rootScope.Scope to set the HTML fragment to.   * @param {string=} onload Expression to evaluate when a new partial is loaded.   * + * @param {string=} autoscroll Whether `ng:include` should call {@link angular.module.ng.$autoScroll + *                  $autoScroll} to scroll the viewport after the content is loaded. + * + *                  - If the attribute is not set, disable scrolling. + *                  - If the attribute is set without value, enable scrolling. + *                  - Otherwise enable scrolling only if the expression evaluates to truthy value. + *   * @example      <doc:example>        <doc:source jsfiddle="false"> @@ -84,7 +91,9 @@ angularWidget('ng:include', function(element){    var compiler = this,        srcExp = element.attr("src"),        scopeExp = element.attr("scope") || '', -      onloadExp = element[0].getAttribute('onload') || ''; //workaround for jquery bug #7537 +      onloadExp = element[0].getAttribute('onload') || '', //workaround for jquery bug #7537 +      autoScrollExp = element.attr('autoscroll'); +    if (element[0]['ng:compiled']) {      this.descend(true);      this.directives(true); @@ -123,7 +132,9 @@ angularWidget('ng:include', function(element){                if (childScope) childScope.$destroy();                childScope = useScope ? useScope : scope.$new();                compiler.compile(element)(childScope); -              $autoScroll(); +              if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { +                $autoScroll(); +              }                scope.$eval(onloadExp);              }            }).error(clearContent);  | 
