2014-11-05 00:02:36 +00:00
|
|
|
/*global define,Promise*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module defining ExampleDirective. Created by vwoeltje on 11/4/14.
|
|
|
|
*/
|
|
|
|
define(
|
|
|
|
[],
|
|
|
|
function () {
|
|
|
|
"use strict";
|
|
|
|
|
2014-11-05 22:05:14 +00:00
|
|
|
var HAS_EXTENSIONS = "A directive loaded these message from " +
|
|
|
|
"example extensions.",
|
2014-11-05 21:38:43 +00:00
|
|
|
NO_EXTENSIONS = "A directive tried to load example extensions," +
|
2014-11-05 22:05:14 +00:00
|
|
|
" but found none.",
|
|
|
|
MESSAGE = "I heard this from my partial constructor.";
|
2014-11-05 21:38:43 +00:00
|
|
|
|
2014-11-05 00:02:36 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-11-05 20:40:53 +00:00
|
|
|
function ExampleDirective(examples) {
|
|
|
|
// Build up a template from example extensions
|
|
|
|
var template = examples.length > 0 ?
|
2014-11-05 21:38:43 +00:00
|
|
|
HAS_EXTENSIONS : NO_EXTENSIONS;
|
2014-11-05 20:40:53 +00:00
|
|
|
|
2014-11-06 01:53:06 +00:00
|
|
|
template += "<ul>";
|
2014-11-05 22:05:14 +00:00
|
|
|
examples.forEach(function (E) {
|
|
|
|
template += "<li>";
|
|
|
|
if (typeof E === 'function') {
|
|
|
|
template += (new E(MESSAGE)).getText();
|
|
|
|
} else {
|
|
|
|
template += E.text;
|
|
|
|
}
|
|
|
|
template += "</li>";
|
2014-11-05 20:40:53 +00:00
|
|
|
});
|
|
|
|
template += "</ul>";
|
|
|
|
|
2014-11-05 00:02:36 +00:00
|
|
|
return {
|
2014-11-05 20:40:53 +00:00
|
|
|
template: template
|
2014-11-05 00:02:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExampleDirective;
|
|
|
|
}
|
|
|
|
);
|