Sha256: 510b5c117d14a189323c1d526ccef447f32437d68a7050cb4355595744b3ec31

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

app.directive('requestExamples', function(Examples, $timeout) {
  return {
    restrict: 'E',
    scope: {
      action: '=',
      resource: '=',
      version: '='
    },
    template: '<tabset><tab ng-repeat="example in examples" heading="{{example.displayName}}" select="select(example.template)"></tab></tabset>',
    link: function(scope, element) {
      scope.examples = Examples.forContext(scope.action, scope.version, scope.resource);
      var keys = _.keys(scope.examples);
      if (keys.length === 1) {
        scope.examples[keys[0]].template.then(function(templateFn) {
          $timeout(function() {
            element.empty().append(templateFn(scope));
          }, 100);
        });
      } else {
        scope.select = function(template) {
          template.then(function(templateFn) {
            $timeout(function() {
              element.find('.tab-content:eq(0)>.tab-pane.active:not(.initialized)').append(templateFn(scope)).addClass('initialized');
              template.then = _.noop;
            }, 100);
          });
        };
      }
    }
  };
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
praxis-2.0.pre.9 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.8 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.7 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.6 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.5 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.4 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.3 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.2 lib/api_browser/app/js/directives/request_examples.js
praxis-2.0.pre.1 lib/api_browser/app/js/directives/request_examples.js
praxis-0.22.pre.2 lib/api_browser/app/js/directives/request_examples.js
praxis-0.22.pre.1 lib/api_browser/app/js/directives/request_examples.js
praxis-0.21 lib/api_browser/app/js/directives/request_examples.js
praxis-0.20.1 lib/api_browser/app/js/directives/request_examples.js