index.html 65.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
<!DOCTYPE html>



<html lang="en">
<head>

    


    


<title>
        W20 manual - Basics    
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta name="robots" content="noindex,nofollow">



<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,700,300,400" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Bitter:700" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/unify/css/style.css">
<link rel="stylesheet" href="/assets/unify/plugins/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/css/style.css">



<script type="application/ld+json">
{
  "@context" : "http://schema.org",
  "@type" : "SoftwareApplication",
  "name" : "SeedStack",
  "image" : "http://www.seedstack.org/img/logos/seedstack-logo-round.svg",
  "publisher" : {
    "@type" : "Organization",
    "name" : "Open-Source Software"
  },
  "applicationCategory" : "development stack"
}
</script>



<link rel="search" type="application/opensearchdescription+xml" href="http://beta.seedstack.org/opensearch.xml" title="SeedStack" />



<link rel="apple-touch-icon" sizes="57x57" href="/img/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/img/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/img/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/img/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/img/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/img/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/img/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/img/favicons/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/img/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/img/favicons/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="/img/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/img/favicons/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/img/favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/img/favicons/manifest.json">
<meta name="apple-mobile-web-app-title" content="SeedStack">
<meta name="application-name" content="SeedStack">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="msapplication-TileImage" content="/img/favicons/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">



<script type="text/javascript">
    window.seedstack = {
        state: {}
    };
</script>


</head>
<body class="homepage">
    
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5R5FP9"
                  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5R5FP9');</script>


    <div id="header">
        <div class="header">
    <div class="container">
        <a class="logo" href="/">SeedStack</a>
        <div class="topbar hidden-xs hidden-sm">
            <ul class="loginbar pull-right">
                <li><i class="fa fa-github"></i> <a target="_blank" href="https://github.com/seedstack">GitHub</a></li>
                <li class="topbar-devider"></li>
                <li><i class="fa fa-keyboard-o"></i> <a style="cursor: pointer;" onclick="seedstack.ui.openHelp();">Shortcuts</a></li>
            </ul>
        </div>
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="fa fa-bars"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse navbar-responsive-collapse" data-role="navigation" style="pointer-events: none;">
        <div class="container">
            <ul class="nav navbar-nav" style="pointer-events: auto;">
                <li>
                    <a href="/getting-started">Getting started</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
                        Documentation
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="/docs/seed">Java framework</a></li>
                        <li><a href="/docs/w20">Web framework</a></li>
                        <li><a href="/docs/business">Business framework</a></li>
                        <li><a href="/guides">Guides</a></li>
                    </ul>
                </li>
                <li>
                    <a href="/addons">Add-ons</a>
                </li>
                <li>
                    <a href="/posts">Blog</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
                        More
                    </a>
                    <ul class="dropdown-menu">
                        <li><a target="_blank" href="https://github.com/seedstack/samples">Samples <i style="margin-top: 3px" class="pull-right fa fa-github"></i></a></li>
                        <li><a href="/project">Project</a></li>
                        <li><a href="/glossary">Glossary</a></li>
                        <li><a href="/tags">Tags</a></li>
                    </ul>
                </li>
                <li>
                    <i class="search fa fa-search search-btn"></i>
                    <div class="search-open">
                        <form method="GET" action="/search">
                            <div class="input-group animated fadeInDown">
                                <input id="search-field" type="text" class="form-control" placeholder="Search" name="q">
                                <span class="input-group-btn">
                                    <button class="btn-u" type="submit">Go</button>
                                </span>
                            </div>
                        </form>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>

<div class="channel-marker beta">
    <div class="container">
        <span><strong>BETA documentation.</strong> <small>You may want go to the <a href="http://seedstack.org">stable documentation</a> instead.</small></span>
    </div>
</div>


        
<div class="title-header small">
    <div class="container">
        <div class="row">
            <div class="col-md-9 col-sm-12">
                <h2>Web framework</h2>
                <p class="hidden-xs">Also known as W20, the Web framework is built upon a powerful RequireJS/AngularJS mix to help you develop single page applications.</p>
            </div>
            <div class="col-md-3 hidden-sm hidden-xs">
                <div class="header-image-wrapper">
                    <img class="header-image" src="/img/logos/w20-logo.svg">
                </div>
            </div>
        </div>
    </div>
</div>
<div class="title-subheader">
    <div class="container">
        <ul>
            <li><h3 class=''><i class="fa fa-play-circle"></i> <a href="/docs/w20">Introduction</a></h3></li>
            <li><h3 class='active'><i class="fa fa-book"></i> <a href="/docs/w20/manual">Manual</a></h3></li>
            <li><h3><i class="fa fa-info-circle"></i> <a href="/jsdoc" target="_blank">JSDoc</a></h3></li>
            <li><h3><i class="fa fa-tag"></i> <a href="https://github.com/seedstack/w20/releases" target="_blank">Releases</a></h3></li>
            <li><h3><i class="fa fa-github"></i> <a href="https://github.com/seedstack/w20" target="_blank">Source</a></h3></li>
        </ul>
    </div>
</div>

    </div>
    <div id="content" class="container">
        <div class="row">
    <div class="col-md-9">
        <div class="content-wrapper">
            <div class="doc-content">
                

<p>This manual will provide you with a deeper understanding of the fundamentals of W20.</p>

<h1 id="fragments-and-configuration">Fragments and configuration</h1>

<p>W20 and its applications are organized around the idea of <strong>fragments</strong>.</p>

<h2 id="what-is-a-fragment">What is a fragment ?</h2>

<p>A W20 application is made of several fragments that brings different concerns to the application.
A fragment is a collection of web resources (JavaScript <a href="http://en.wikipedia.org/wiki/Asynchronous_module_definition">AMD modules</a>, stylesheets, HTML templates&hellip;)
that often but not necessarily depends on each other. The dependency between modules inside a fragment is orchestrated by the use of
the <a href="http://requirejs.org/">RequireJS</a> library.</p>

<p>Think of a fragment as a coherent set of resources linked together for the purpose of <strong>organization</strong> and <strong>reusability</strong>.
By including and configuring a fragment you can bring the corresponding aspect and/or asset to your web application without having to worry about
the intrinsic details of the fragment itself. Inside a fragment, the module dependency system guarantees that the dependencies of a module will be loaded before the module
itself. This is especially important for large applications that often require an important number of JavaScript modules.</p>

<h2 id="fragments-vs-modules">Fragments vs modules</h2>

<p>When we talk about a module, we refer to a JavaScript AMD module, as used in the RequireJS library. That is, to say thing shortly, a .js file
whose content is wrapped in a <code>define</code> call (AMD modules are explained in greater detail further down). A fragment on the other hand is a collection of modules.
It is described by a manifest which exposes configuration properties. When you include and configure a fragment in your application you can generally choose
which modules to activate inside of it.</p>

<h2 id="fragment-manifest">Fragment manifest</h2>

<p>Each fragment contains a JSON manifest that serves as a descriptor for the fragment configuration possibilities. The fragment manifest has two main goals:</p>

<ol>
<li>To expose the available modules of the fragment and their available configuration options. It is important to understand that the fragment manifest does
not configure the fragment. It exposes what configuration will be possible according to a configuration schema. In the next section we will see how to
actually configure the fragment when you declare it inside your application manifest.</li>
<li>To allow the declaration of additional RequireJS configuration. On application start, each RequireJS configuration of each fragments, if present, are merged
together.</li>
</ol>

<p>The properties of a fragment manifest are:</p>

<ul>
<li><code>id</code>: a mandatory string with no space which identifies the fragment. No fragment with the same id can be included at the same time in an application.</li>
<li><code>name</code>: an optional name for the fragment.</li>
<li><code>description</code>: an optional description of the fragment.</li>
<li><code>requireConfig</code>: an optional object with the properties of a RequireJS configuration object. In the example below we add a simple RequireJS configuration
for module mapping (this allow to &laquo;map&raquo; a module to a name, which can be used for creating aliases or for module substitution). For an exhaustive list and
description of the RequireJS configuration options, please have a look  at its <a href="http://requirejs.org/docs/api.html">API</a>.
Remember that this configuration will be merged with all the other declared fragment configuration on application start.</li>
</ul>

<pre><code>{
    &quot;id&quot;: &quot;demo-fragment&quot;,
    &quot;requireConfig&quot;: {
        &quot;map&quot;: {
           &quot;*&quot;: {
             &quot;mappedModule&quot;: &quot;path/to/module/to/map&quot;
        }
    }
}
</code></pre>

<ul>
<li><code>modules</code>: an optional object whose keys are the name of the exposed modules of the fragment. The value of those keys is an object with
the module path and the configuration schema. The configuration schema contains the name of the configuration properties available for the module.
In the example below we expose a module &laquo;demoModule&raquo; inside a fragment with id &laquo;demo-fragment&raquo; and a configuration property named &laquo;demoConfig&raquo;
of type string for the module demoModule.</li>
</ul>

<pre><code>{
    &quot;id&quot;: &quot;demo-fragment&quot;,
    &quot;modules&quot;: {
        &quot;demoModule&quot;: {
             &quot;path&quot;: &quot;{demo-fragment}/modules/demoModule&quot;,
             &quot;autoload&quot; : true,
             &quot;configSchema&quot;: {
                 &quot;title&quot;: &quot;Demo module configuration&quot;,
                 &quot;type&quot;: &quot;object&quot;,
                 &quot;additionalProperties&quot;: false,
                 &quot;properties&quot;: {
                     &quot;demoConfig&quot;: {
                         &quot;description&quot;: &quot;A description of the demoConfig property&quot;,
                         &quot;type&quot;: &quot;string&quot;
                     }
                 }
             }
        }
    }
}
</code></pre>

<p>There is a few additional things to note in this last example:</p>

<ul>
<li>In the <code>path</code> property we used the fragment id enclosed in curly braces (<code>{demo-fragment}</code>). This alias is automatically registered based
on the fragment id and points to the location of the fragment manifest (it is a RequireJS mapping). You can (and should for reusability consideration)
use this alias in all other fragments
and in the application to refer to the fragment location.</li>
<li>The <code>autoload</code> attribute specify if the module should be loaded automatically or only if required by another module. By &laquo;required by another module&raquo;, we refer
to the AMD definition and the dependency management between modules as used in RequireJS (through the use of a <code>define</code> or <code>require</code> call). If not specified, the
module will not be autoloaded.</li>
<li>The <code>type</code> property of the &laquo;demoConfig&raquo; option has been specified as a string. This means that when the property will be given its value in the application
manifest, passing a type other than a string will raise an error. The other type available are object, array, boolean and number.</li>
<li>The <code>additionalProperties</code> property of the configuration schema specify if additional properties can be given when configuring this module in the application
manifest. In this example, trying to configure any other property than a &laquo;demoConfig&raquo; one for this module in the application manifest will raise an error.</li>
</ul>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>The configuration schema is optional. You can simply declare the module along with its path and eventually ask for it to be autoloaded (false if not specified). This
is often the case when you simply want to include a module that has no particular configuration in your business fragment.</p>

        </div>
    </div>
</div>

<p>W20 is packaged and distributed as multiple fragments. Your application will then be composed of those fragments and your own business fragments.
Now that we have a better understanding of the notion of fragment, we can proceed to the configuration step in which we actually include and configure those fragments
in our application.</p>

<h2 id="configuration">Configuration</h2>

<p>Application configuration happens in an application manifest. This manifest must be named <strong>w20.app.json</strong> because, in the absence of
a remote manifest, the framework will fall back to looking for a JSON file with this name at the application root.</p>

<p>The role of the application manifest is to reference fragments through their manifest URL and configure them specifically for the application.</p>

<h3 id="fragment-declaration">Fragment declaration</h3>

<p>To include a fragment in your application, specify the path of the fragment manifest as a key.</p>

<pre><code>{
    &quot;bower_components/w20/w20-core.w20.json&quot;: {}
}
</code></pre>

<p>The <code>w20-core</code> fragment will be loaded with all its modules whose <code>autoload</code> property is set to true. An alias <code>{w20-core}</code> is now
pointing to <code>bower_components/w20</code>, the location of the fragment manifest.</p>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p><code>bower_components</code> is the default name of the folder in which <a href="http://bower.io/">Bower</a> installs the web dependencies. Bower is one of the most popular
package manager for web application. It should be installed to ease application development and/or use the w20 application generator. W20 fragments are available
in the <a href="http://bower.io/search/?q=w20">Bower registry</a> and will be installed to the bower_components folder if you choose this way of installation.</p>

        </div>
    </div>
</div>

<h3 id="fragment-configuration">Fragment configuration</h3>

<p>Declaring a fragment like above can sometimes be enough. Autoloaded modules will be available and that may be sufficient.
However, most of the time, you will configure the fragment&rsquo;s modules according to your need or because an explicit configuration value is required.
To configure the modules of the fragment add a <code>modules</code> section:</p>

<pre><code>{
    &quot;bower_components/w20/w20-core.w20.json&quot; : {
        &quot;modules&quot;: {
            &quot;application&quot;: {
                &quot;id&quot;: &quot;my-app&quot;
            }
        }
    }
}
</code></pre>

<p>In the above configuration, the <code>application</code> module of <code>w20-core</code> will be configured with the corresponding object (defining
the unique identifier of the application in this case). This module is normally defined as automatically loaded so this
definition will only serve to configure it. To load a module that is not automatically loaded without configuration, just
specify it with an empty object:</p>

<pre><code>{
    &quot;bower_components/w20/w20-core.w20.json&quot;: {
        &quot;modules&quot;: {
            &quot;application&quot;: {
                &quot;id&quot;: &quot;my-app&quot;
            }
        }
    },

    &quot;bower_components/other-fragment/other-fragment.w20.json&quot;: {
        &quot;modules&quot;: {
            &quot;my-module&quot;: {}
        }
    }
}
</code></pre>

<p>In the example above &laquo;my-module&raquo; will be loaded without any configuration. If it was not declared and the module was not set to be autoloaded, &laquo;my-module&raquo;
would not be loaded on application start even if it belongs to the &laquo;other-fragment&raquo; fragment.</p>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>If a configuration JSON schema is provided for a specific module in the fragment manifest, the configuration specified
here will be validated against it. Also, if a default configuration is provided for a specific module in the fragment manifest, the configuration specified here
will be merged with it, overriding it. If no default configuration is provided, the configuration is provided as-is to the module.</p>

        </div>
    </div>
</div>

<h2 id="summary">Summary</h2>

<p><img src="img/fragments.png" alt="fragments-overview" /></p>

<h1 id="masterpage">Masterpage</h1>

<p>W20 uses <a href="https://angularjs.org/">AngularJS</a> as a core framework for application development.
Thus, its applications are <a href="https://en.wikipedia.org/wiki/Single-page_application">Single Page Application (SPA)</a>.
Only one HTML page is served with an outermost html doctype and a root tag <code>&lt;html&gt;&lt;/html&gt;</code>. This page is called the <strong>masterpage</strong>.
The masterpage serves two roles:</p>

<ol>
<li>Instruct the browser to load the RequireJS library with the w20 loader as the main module. The w20 loader is a module of the core fragment and
referenced in the <code>main</code> attribute of the script which loads RequireJS and who will take care of bootstrapping the application. A <code>w20-app</code> attribute is mandatory on the root
element of the masterpage. Application loading is explained in further details
in the following section.</li>
<li>Declare the unique <code>ng-view</code> element of the application which will include view templates. View change is handled through client-side
routing which associates an URL to a template. This template is rendered in the <code>ng-view</code> tag.</li>
</ol>

<pre><code>&lt;!doctype html&gt;
&lt;!-- Sample masterpage for a W20 app --&gt;
&lt;html data-w20-app&gt;
&lt;head&gt;
    &lt;title&gt;Application title&lt;/title&gt;
    &lt;script type=&quot;text/javascript&quot; 
            data-main=&quot;bower_components/w20/modules/w20&quot; 
            src=&quot;bower_components/requirejs/require.js&quot;&gt;
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div data-ng-view&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>You can notice that HTML attributes that are not part of the HTML specification (such as <code>w20-app</code> or <code>ng-view</code>) are prefixed with
&laquo;data-&raquo;. This allow to keep templates valid against HTML validator by defining those attributes as <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*">custom attributes</a>.</p>

        </div>
    </div>
</div>
<div class="callout callout-warning">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
            
                <i class="fa fa-exclamation-triangle icon-2x"></i>
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Note that the w20 module is referenced without the .js extension. It is a common mistake to include the .js extension while referring to module but this
is not accepted by RequireJS. The module file name is &laquo;w20.js&raquo; but it must be referenced by &laquo;w20&raquo; only.</p>

        </div>
    </div>
</div></p>

<p>Additional configuration can be provided:</p>

<ul>
<li><p>The <code>w20-app</code> attribute can be provided with the URL of the application manifest as the value:</p>

<pre><code>&lt;html data-w20-app=&quot;/resources/configuration&quot;&gt; ... &lt;/html&gt;
</code></pre>

<p>In that case, a request is made for retrieving the remote configuration. Without any value provided, the w20 loader will look
for a <code>w20.app.json</code> at the same level as the masterpage.</p></li>

<li><p>The <code>w20-app-version</code> attribute, when provided a value, will append this value as an extra query string to URLs of resources.
This is useful for cache busting.</p>

<pre><code>&lt;html data-w20-app data-w20-app-version=&quot;1.0.0&quot;&gt; ... &lt;/html&gt;
</code></pre></li>

<li><p>The <code>w20-timeout</code> attribute specify the number of seconds to wait before giving up on loading a script.
Setting it to 0 disables the timeout. The default if not specified is 7 seconds.</p>

<pre><code>&lt;html data-w20-app data-w20-timeout=&quot;3&quot;&gt; ... &lt;/html&gt;
</code></pre></li>

<li><p>The <code>w20-cors-with-credentials</code> attribute accept a boolean that specify if whether or not cross-site Access-Control requests should be made using credentials
such as cookies or authorization headers. By default the value is false.</p>

<pre><code>&lt;html data-w20-app data-w20-cors-with-credentials=&quot;true&quot;&gt; ... &lt;/html&gt;
</code></pre></li>
</ul>

<h1 id="core-fragment">Core fragment</h1>

<p>The core fragment of W20 is the most important fragment of the framework and the only one that is mandatory.
It provides the fundamental aspect of the framework, mainly:</p>

<ul>
<li>An <a href="http://en.wikipedia.org/wiki/Asynchronous_module_definition">AMD</a> infrastructure through <a href="http://requirejs.org/">RequireJS</a>,</li>
<li>An MVC runtime through <a href="https://angularjs.org/">AngularJS</a>,</li>
<li>Application loading and initialization through the <code>w20</code> module referenced in the masterpage,</li>
<li>A permission model which enables to reflect backend security,</li>
<li>Extensive culture support.</li>
<li>Support for HATEOAS</li>
</ul>

<p>No CSS framework is provided in the core fragment to let you free of this choice. However, you can simply add
an appropriate fragment of W20 to bring frameworks such as <a href="http://getbootstrap.com/">Twitter Bootstrap</a> (w20-bootstrap-3)
or <a href="https://material.angularjs.org/latest/">Angular Material</a> (w20-material). For additional information,
please consult the <a href="http://seedstack.org/docs/w20/manual/ui/">UI</a> section.</p>

<p>The rest of this manual will focus mainly on the core fragment. Additional fragments documentation can be found in the corresponding
section of the documentation.</p>

<p>The core fragment provides the <code>w20</code> module which is responsible for application initialization. Let&rsquo;s look at how a W20 application load
itself.</p>

<h1 id="application-loading">Application loading</h1>

<p>Once RequireJS is loaded, the <code>w20</code> module becomes the entry point of a W20 application as the main module.
Think of it as a &laquo;fragment loader&raquo;. Its initialization sequence is as follow:</p>

<ol>
<li>Loading and parsing of the application configuration (<code>w20.app.json</code> or remote configuration).</li>
<li>Loading and parsing of all the declared fragment manifests.</li>
<li>Computing of a global RequireJS configuration along with the list of all modules to load.</li>
<li>Loading of all modules needed at startup time at once.</li>
<li>Initialization of each loaded modules through their lifecycle callbacks (pre -&gt; run -&gt; post).</li>
</ol>

<p>The last phase should be a little bit unclear at this point because we did not introduce modules lifecycle yet.
We included it here to give you the full initialization sequence for future reference. Modules are documented in the next section.</p>

<h1 id="modules">Modules</h1>

<h2 id="amd">AMD</h2>

<p>JavaScript logic in W20 are defined in AMD modules. An AMD module is defined using the global function <code>define</code> exposed by RequireJS.
AMD module can be named but it is strongly recommended that you use anonymous AMD modules, each one living in its own JavaScript file.
They have the following form:</p>

<pre><code>define([
        // (1) list of the dependencies of this module
], function(/* (2) list of injected dependencies (in the same order as (1)) */) {
    
    // (3) module factory function body (private scope of the module)

    return {
        // (4) public signature of the module that can be injected 
        // when requested as a dependency of another module
    };
});
</code></pre>

<p>Let us expand a little bit on each part of this module definition:</p>

<ul>
<li>(1) The list of dependencies is composed of path to dependencies of this module, which are often themselves AMD modules.
The path can be an absolute path or a map key if a RequireJS mapping has been defined. Remember that fragments manifest location are
automatically aliased by their fragment id enclosed in curly braces. This means that you can reference a W20 fragment or your own one as
a dependency like this:</li>
</ul>

<pre><code>define([
'{w20-core}/modules/application', 
'{your-fragment}/modules/your-module'
], ... );
</code></pre>

<p>Please note that modules are referenced without their .js extension.</p>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Third party libraries location are also aliased. For instance AngularJS distribution location is aliased by <code>{angular}</code>.
This means that you can reference a dependency to angular.js with <code>{angular}/angular</code>.</p>

        </div>
    </div>
</div>

<ul>
<li><p>(2) The last parameter to the <code>define</code> function is the factory function. Its parameters are the public value returned by the dependencies defined in (1) in
the same order. That is, if we take the example above, the public value of the &laquo;application&raquo; module as first argument and the public value of &laquo;your-module&raquo; as
second argument.</p></li>

<li><p>(3) The body of the factory function constitute the private part of the module. This part is not available to other modules.</p></li>

<li><p>(4) The return value of a module is the public part it exposes to the world. The value of this return will be what will be injected
in other modules factory function if that module is a dependency of them.</p></li>
</ul>

<pre><code>define([
'{w20-core}/modules/application',
'{yourFragment}/modules/yourModule'
], function (applicationPublic, yourModulePublic) {
 
 var privateValue = 'I am a private string';
 
 return {
    publicValue: 'I am a public string'
 }

});
</code></pre>

<p>Now, if we suppose the module above to be named &laquo;demo.js&raquo; inside a fragment with id &laquo;example&raquo;, if this module is defined as a dependency of another,
the last one can access the publicValue property of the object.</p>

<pre><code>define([
    '{example}/modules/demo',
], function (demo) {

    console.info(demo.publicValue); // &quot;I am a public string&quot;

});
</code></pre>

<h2 id="module-configuration">Module configuration</h2>

<p>To access the configuration of a module it needs to depend on the <code>module</code> module. This special module is used to retrieve the module id, its location
and the value of its configuration options (those declared in the application manifest).
If we suppose a module &laquo;sample&raquo; with the following configuration:</p>

<pre><code>&quot;some-fragment/path/some-fragment.w20.json&quot;: {
    &quot;modules&quot;: {
        &quot;sample&quot;: {
            &quot;prop&quot;: &quot;Value of property one&quot;
        }
    }
}
</code></pre>

<p>The configuration is retrieved inside the &laquo;sample&raquo; module like this:</p>

<pre><code>define([
    'module',
], function (module) {

    var config = module &amp;&amp; module.config() || {};
    
    console.log(config.prop); // &quot;Value of property&quot;
});
</code></pre>

<p>The statement <code>module &amp;&amp; module.config() || {}</code> is the idiomatic way of safely retrieving the module configuration.</p>

<h2 id="lifecycle-callbacks">Lifecycle callbacks</h2>

<p>In the &laquo;Application loading&raquo; section we have seen that the initialization sequence ended with each loaded modules going
through their &laquo;lifecycle callbacks&raquo;. Actually this is only the case for modules that declares lifecycle callbacks. If a module does
not declare any lifecycle callback then it is simply loaded.</p>

<p>Lifecycle callbacks happens when all fragments have been collected and the RequireJS
configuration has been merged. There are 3 lifecycle callbacks which runs in the order: <code>pre</code>, <code>run</code> and <code>post</code>.</p>

<ul>
<li>All of them are optional.</li>
<li>It is guaranteed that every modules will run their <code>pre</code> callback before any other modules run their <code>run</code> callback.</li>
<li>It is guaranteed that every modules will run their <code>run</code> callback before any other modules run their <code>post</code> callback.</li>
<li>A module dependency will have its callback called before the module requiring it.</li>
</ul>

<p>To integrate a module into the lifecycle management of the application, you must add the following code to the public
signature of the module (i.e the return value of the factory function):</p>

<pre><code>return {
    ...

    lifecycle: {
        pre: function (modules, fragments, callback) {},
        run: function (modules, fragments, callback) {},
        post: function (modules, fragments, callback) {}
    }

    ...
};
</code></pre>

<p>You can omit the unsupported callbacks (for instance, just leaving the <code>pre</code> one). If the loader recognize one or more
lifecycle callbacks, they will be invoked during W20 initialization with the following arguments:</p>

<ul>
<li><code>modules</code> is an array of all public modules definitions,</li>
<li><code>fragments</code> an array of all loaded fragment manifests,</li>
<li><code>callback</code> is a function that <strong>MUST</strong> be called to notify the loader that any processing in this phase is done for
this module (including asynchronous processing). If a module do not call its callback, the whole initialization process
is blocked for a specified amount of time. After that, it is cancelled and a timeout error message is displayed.</li>
</ul>

<p>Lifecycle callbacks are useful hooks for application initialization. The <code>pre</code> callback for instance will run before AngularJS
initialization, the subject of the next section.</p>

<h1 id="angularjs-initialization">AngularJS initialization</h1>

<p>Before AngularJS initialization, it is guaranteed that:</p>

<ul>
<li>All AMD modules needed at startup are loaded,</li>
<li>Their factory functions have been run in the correct order,</li>
<li>Their <code>pre</code> lifecycle callbacks have been run and all modules have notified the loader that they have finished loading
their asynchronous resources if any.
<br /></li>
</ul>

<p>AngularJS initialization is done explicitly with the <code>angular.bootstrap()</code> function on the document element. It occurs
in the <code>run</code> lifecycle callback of the <code>application</code> module. From this moment AngularJS initialize normally; you can read more
about the initialization process <a href="https://docs.angularjs.org/guide/bootstrap">here</a>.</p>

<h1 id="angularjs-modules">AngularJS modules</h1>

<h2 id="amd-vs-angularjs-modules">AMD vs AngularJS modules</h2>

<p><a href="https://docs.angularjs.org/guide/module">AngularJS modules</a> are not to be confused with AMD modules. We said at the
begining of this guide that when we refer to a &laquo;module&raquo;, it is an AMD module. We will continue to do so and use the term &laquo;AngularJS module&raquo;
to refer to the notion of module in AngularJS.</p>

<p>From the AMD point of view, AngularJS modules have no meaning. However, AngularJS modules are fundamental for
structuring an application correctly.</p>

<h2 id="what-is-an-angularjs-module">What is an AngularJS module ?</h2>

<p>AngularJS modules allow to register services, factories, controllers, directives, providers and other concepts
such as configuration or run block. AngularJS modules are also fundamental for unit testing. Each AngularJS module can only be loaded once per injector.
Usually an AngularJS app has only one injector and AngularJS modules are only loaded once. Each test has its own injector and AngularJS modules are loaded multiple times.</p>

<h2 id="angularjs-module-dependencies">AngularJS module dependencies</h2>

<p>Wait a minute. Did we not already talk about dependencies between modules ? Yes, we did. We talked of dependencies between AMD modules.
But AngularJs modules can also list other AngularJS modules as their dependencies. Depending on an AngularJS module implies that the required AngularJS module
needs to be loaded before the requiring AngularJS module is loaded.</p>

<pre><code>// firstModule.js
define(['{angular}/angular'], function (angular) {
  var firstAngularModule = angular.module('first', []);
});

// secondModule.js
define(['{angular}/angular', 'firstModule'], function(angular) {
  var secondAngularModule = angular.module('second', ['first']);
});

</code></pre>

<p>In the example above the dependency between AngularJS modules is declared as an array in the second argument to the <code>angular.module</code> function. AngularJS maintains an injector
with a list of names and corresponding objects. An entry is added to the injector when a component is created and the object is returned whenever it is referenced using the registered name.</p>

<p>How does that fit with the dependency system between AMD modules ?  It is important to remember that the purpose of AMD modules and AngularJS modules is totally different.
The dependency injection system built into AngularJS deals with the objects needed in a component while dependency management in RequireJS deals with JavaScript files. In other word,
if an AngularJS modules depends on another AngularJS modules, this means that they must be loaded in the correct order. The <code>secondModule</code> depend on the <code>firstModule</code> to be loaded first.</p>

<h2 id="angularjs-modules-and-w20">AngularJS modules and W20</h2>

<p>To correctly initialize AngularJS, the <code>application</code> module must know all the top-level declared
AngularJS modules. To expose them properly, you must add the following code to the public signature of modules that
declare AngularJS modules:</p>

<pre><code>return {
    ...

    angularModules: [ 'angularModule1', 'angularModule2', ... ]

    ...
};
</code></pre>

<p>All <code>angularModules</code> arrays of AMD public signature modules are concatenated and the resulting array is passed to
the <code>angular.bootstrap()</code> function.</p>

<p><div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Note that you don&rsquo;t need to add the transitive AngularJS modules.</p>

        </div>
    </div>
</div></p>

<h1 id="integration-with-seedstack-backend">Integration with SeedStack backend</h1>

<p>While the web framework is compatible with any backend technology using the REST architecture, integration with a SeedStack backend
provide additional benefits such as:</p>

<ul>
<li>Masterpage templating and generation.</li>
<li>Configuration variable.</li>
<li>Default manifest configuration.</li>
<li>Configuration options available from Props/Properties format.</li>
<li>Automatic activation of fragments bundled in JAR.</li>
</ul>

<p>This bridge between SeedStack front and back end is provided by the <a href="http://seedstack.org/addons/w20-bridge/">W20-bridge addon</a></p>

            </div>
        </div>
    </div>
    <div class="col-md-3">
        
<div class="side-menu">
    
        
        <div class="list-group">
            <ul class="nav">
                
                
                
                    
                    <li>
                        <a href="/docs/w20/manual/" class="list-group-item  active ">
                            Basics
                        </a>
                        
                        
                            <nav id="TableOfContents">
<ul>
<li><a href="#fragments-and-configuration">Fragments and configuration</a>
<ul>
<li><a href="#what-is-a-fragment">What is a fragment ?</a></li>
<li><a href="#fragments-vs-modules">Fragments vs modules</a></li>
<li><a href="#fragment-manifest">Fragment manifest</a></li>
<li><a href="#configuration">Configuration</a>
<ul>
<li><a href="#fragment-declaration">Fragment declaration</a></li>
<li><a href="#fragment-configuration">Fragment configuration</a></li>
</ul></li>
<li><a href="#summary">Summary</a></li>
</ul></li>
<li><a href="#masterpage">Masterpage</a></li>
<li><a href="#core-fragment">Core fragment</a></li>
<li><a href="#application-loading">Application loading</a></li>
<li><a href="#modules">Modules</a>
<ul>
<li><a href="#amd">AMD</a></li>
<li><a href="#module-configuration">Module configuration</a></li>
<li><a href="#lifecycle-callbacks">Lifecycle callbacks</a></li>
</ul></li>
<li><a href="#angularjs-initialization">AngularJS initialization</a></li>
<li><a href="#angularjs-modules">AngularJS modules</a>
<ul>
<li><a href="#amd-vs-angularjs-modules">AMD vs AngularJS modules</a></li>
<li><a href="#what-is-an-angularjs-module">What is an AngularJS module ?</a></li>
<li><a href="#angularjs-module-dependencies">AngularJS module dependencies</a></li>
<li><a href="#angularjs-modules-and-w20">AngularJS modules and W20</a></li>
</ul></li>
<li><a href="#integration-with-seedstack-backend">Integration with SeedStack backend</a></li>
</ul>
</nav>
                            <script>
                                seedstack.state.previousPage = '';
                            </script>
                            
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/routing/" class="list-group-item ">
                            Routing
                        </a>
                        
                            <script>
                                seedstack.state.nextPage = '\/docs\/w20\/manual\/routing\/';
                            </script>
                            
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/security/" class="list-group-item ">
                            Security
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/culture/" class="list-group-item ">
                            Culture
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/hypermedia/" class="list-group-item ">
                            Hypermedia
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/ui/" class="list-group-item ">
                            UI
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/w20/manual/testing/" class="list-group-item ">
                            Testing
                        </a>
                        
                        
                    </li>
                    
                
            </ul>
        </div>
        
    
    
    <div class="list-group">
        <ul class="nav">
            <li class="list-group-item"><div style="margin-bottom: 10px;"><i class="fa fa-tag"></i> Tags</div>
                <div class="tags">
                    
                    <a class="label label-default" href="/tags/configuration">Configuration</a>
                    
                    <a class="label label-default" href="/tags/fragment">Fragment</a>
                    
                    <a class="label label-default" href="/tags/manifest">Manifest</a>
                    
                    <a class="label label-default" href="/tags/lifecycle">Lifecycle</a>
                    
                    <a class="label label-default" href="/tags/module">Module</a>
                    
                    <a class="label label-default" href="/tags/startup">Startup</a>
                    
                    <a class="label label-default" href="/tags/angular">Angular</a>
                    
                </div>
            </li>
        </ul>
    </div>
    
    <div class="list-group">
        <ul class="nav">
            
                <li><a class="list-group-item" href="https://github.com/seedstack/website/edit/beta/content/docs/w20/manual/index.md" target="_blank"><i class="fa fa-edit"></i> Contribute to this BETA page</a></li>
            
        </ul>
    </div>
</div>

    </div>
</div>

    </div>
    <div id="footer">
        <div class="footer-v3">
    <div class="footer">
        <div class="container">
            <div class="row">
                <div class="col-md-4 md-margin-bottom-40">
                    <div class="headline"><h2>About</h2></div>
                    <p class="margin-bottom-25 md-margin-bottom-40">SeedStack is an Open-Source enterprise-class development stack for building modern and robust applications.</p>
                </div>

                <div class="col-md-4 md-margin-bottom-40">
                    <div class="posts">
                        <div class="headline"><h2>License</h2></div>
                        <p>
                            Code licensed under the <a href="https://www.mozilla.org/MPL/2.0" target="_blank">Mozilla Public License 2.0</a>.
                            <br/>
                            Documentation licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.
                        </p>
                    </div>
                </div>

                <div class="col-md-4 map-img">
                    <div class="headline"><h2>Contact us</h2></div>
                    <address>
                        <p>
                            IRC channel <a href="irc://chat.freenode.net/seedstack">#seedstack on Freenode community</a>
                            <br/>
                            Google group <a href="https://groups.google.com/forum/#!forum/seedstack">seedstack@googlegroups.com</a>
                        </p>
                    </address>

                    <div class="headline"><h2>Stay in touch</h2></div>
                    <div style="margin-bottom: 20px;">
                        <a class="twitter-follow-button"
                           href="https://twitter.com/seedstack"
                           data-show-count="true"
                           data-lang="en">
                            Follow @seedstack
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    </div>
    <div id="hotkeys-modal" class="modal">
    <div class="modal-dialog" style="min-width: 960px !important;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">Keyboard shortcuts <a id="show-all-shortcuts" style="cursor: pointer;" onclick="seedstack.ui.showAllShortcuts();">(Show all)</a></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-4">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Global shortcuts</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>?</kbd>
                                </td>
                                <td>Show this help dialog</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>/</kbd>
                                </td>
                                <td>Focus the search field</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>alt</kbd> <kbd></kbd>
                                </td>
                                <td>Go to previous menu item</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>alt</kbd> <kbd></kbd>
                                </td>
                                <td>Go to next menu item</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>S</kbd>
                                </td>
                                <td>Go to Seed framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>W</kbd>
                                </td>
                                <td>Go to W20 framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>B</kbd>
                                </td>
                                <td>Go to Business framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>A</kbd>
                                </td>
                                <td>Go to add-ons</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>G</kbd>
                                </td>
                                <td>Go to guides</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Seed framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>t</kbd>
                                </td>
                                <td>Go to testing</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>s</kbd>
                                </td>
                                <td>Go to security</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>c</kbd>
                                </td>
                                <td>Go to cryptography</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>w</kbd>
                                </td>
                                <td>Go to Web</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>r</kbd>
                                </td>
                                <td>Go to REST</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>o</kbd>
                                </td>
                                <td>Go to operations</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>T</kbd>
                                </td>
                                <td>Go to transactions</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Business framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>m</kbd>
                                </td>
                                <td>Go to model</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>l</kbd>
                                </td>
                                <td>Go to lifecycle</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>e</kbd>
                                </td>
                                <td>Go to events</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>p</kbd>
                                </td>
                                <td>Go to policies</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>a</kbd>
                                </td>
                                <td>Go to assemblers</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>f</kbd>
                                </td>
                                <td>Go to finders</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>P</kbd>
                                </td>
                                <td>Go to pagination</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>W20 framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>s</kbd>
                                </td>
                                <td>Go to security</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>c</kbd>
                                </td>
                                <td>Go to culture</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>h</kbd>
                                </td>
                                <td>Go to hypermedia</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>u</kbd>
                                </td>
                                <td>Go to UI</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="versions-modal" class="modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 id="versions-title" class="modal-title">Fetching components...</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <table id="versions-table" class="table table-striped table-hover table-bordered">
                            <tr>
                                <th>Component</th>
                                <th>Version</th>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/github.min.css">

    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lunr.js/0.5.9/lunr.min.js"></script>
<script src="/assets/unify/plugins/smoothScroll.js"></script>
<script src="/js/xml2json.js"></script>
<script src="/js/jquery.highlight.js"></script>
<script src="/js/seedstack.js"></script>
<script>
    $(document).ready(function () {
        var $search = $('.search-btn');

        $('.search').click(function () {
            if ($search.hasClass('fa-search')) {
                seedstack.ui.openSearch();
            } else {
                seedstack.ui.closeSearch();
            }
        });

        $('pre code').each(function (i, block) {
            hljs.highlightBlock(block);
        });

        $('.side-menu').affix({
            offset: {
                top: $('#header').height() + 20,
                bottom: $('#footer').height() + 40
            }
        });

        Mousetrap.bind('/', function () {
            seedstack.ui.openSearch();
            return false;
        });

        Mousetrap.bind('alt+up', function () {
            if (seedstack.state.previousPage) {
                window.location = seedstack.state.previousPage;
            }
            return false;
        });

        Mousetrap.bind('alt+down', function () {
            if (seedstack.state.nextPage) {
                window.location = seedstack.state.nextPage;
            }
            return false;
        });

        Mousetrap.bind('?', function () {
            seedstack.ui.openHelp();
            return false;
        });

        Mousetrap.bind('esc', function () {
            seedstack.ui.closeHelp();
            seedstack.ui.closeSearch();
            return false;
        });

        var originalCallback = Mousetrap.stopCallback;
        Mousetrap.stopCallback = function (e, element, combo) {
            if (combo === 'esc') {
                return false;
            }

            return originalCallback(e, element, combo);
        };

        function bindShortcuts(value) {
            $.each(value, function (sequence, item) {
                if (typeof item === 'string') {
                    Mousetrap.bind("g " + sequence, function () {
                        window.location = item;
                        return false;
                    });
                } else if (typeof item === 'object') {
                    Mousetrap.bind("g " + sequence, function () {
                        window.location = item.path;
                        return false;
                    });
                    if (item.shortcuts && location.pathname.indexOf(item.path) === 0) {
                        bindShortcuts(item.shortcuts);
                    }
                }
            });
        }

        function resolveVersions() {
            var $versionsTitle = $('#versions-title');
            if (!seedstack.versions) {
                $.ajax({
                    dataType: 'text',
                    url: '/distribution.pom.xml'
                }).done(function (data) {
                    var pom = new X2JS().xml_str2json(data);

                    if (pom.project && pom.project.properties && pom.project.version) {
                        var $versions = $('#versions-table');
                        var versions = {};

                        $versionsTitle.text("SeedStack " + pom.project.version);

                        $.each(pom.project.properties, function (name, value) {
                            if (/\.version$/.test(name)) {
                                versions[name.substr(0, name.indexOf('.version'))] = value;

                                $versions.append(
                                        '<tr>' +
                                        '<td>' +
                                        name.substr(0, 1).toUpperCase() + name.substr(1, name.indexOf('.version') - 1).replace(/-/g, ' ') +
                                        '</td>' +
                                        '<td>' + value + '</td>' +
                                        '</tr>');
                            }
                        });

                        $('.loginbar').prepend(
                                '<li class="hidden-xs hidden-sm"><i class="fa fa-tag"></i> <a style="cursor: pointer;" onclick="seedstack.ui.openVersions();">Version ' + pom.project.version + '</a></li>' +
                                '<li class="topbar-devider"></li>'
                        );

                        seedstack.versions = versions;
                    }
                }).error(function () {
                    console.error("SeedStack version could not be resolved");
                });
            }
        }

        bindShortcuts(seedstack.ui.shortcuts);

        resolveVersions();

        $('[data-toggle="tooltip"]').tooltip();

        $('#hotkeys-modal, #versions-modal').bind('hidden.bs.modal', function () {
            $("html").css("margin-right", "0px");
        }).bind('show.bs.modal', function () {
            $("html").css("margin-right", "-15px");
        });

        var query = seedstack.strings.parseQueryString(location);
        if (query.h && query.h.length > 0) {
            $('.doc-content').highlight(query.h);
            if (query.scroll) {
                $('html, body').animate({
                    scrollTop: $('span[class=highlight]:first').offset().top - 20
                }, 250);
            }
        }
    });
</script>
<script>window.twttr = (function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {};
    if (d.getElementById(id))return t;
    js = d.createElement(s);
    js.id = id;
    js.src = "https://platform.twitter.com/widgets.js";
    fjs.parentNode.insertBefore(js, fjs);
    t._e = [];
    t.ready = function (f) {
        t._e.push(f);
    };
    return t;
}(document, "script", "twitter-wjs"));</script>

</body>
</html>