Skip to content

Commit 2b29dfd

Browse files
committed
Add 'Create a Build' option
1 parent 2eb7273 commit 2b29dfd

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

index.html

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<link rel="stylesheet" href="lib/calendar/fullcalendar.css" >
3030
<link rel="stylesheet" href="css/app.css" >
3131
</head>
32-
<body data-spy="scroll">
32+
<body data-spy="scroll" ng-controller="MainCtrl">
3333
<header class="navbar navbar-fixed-top">
3434
<div class="navbar-inner">
3535
<div class="container">
@@ -117,7 +117,7 @@ <h1>
117117
</h1>
118118
<p>The companion suite to the <strong><a href="http://angularjs.org">AngularJS</a></strong> framework.</p>
119119
<p class="btn-group">
120-
<a class="btn btn-large" href="https://github.com/angular-ui/angular-ui"><i class="icon-github"></i> Code on Github</a><a class="btn btn-large btn-primary" href="https://github.com/angular-ui/angular-ui/tags"><i class="icon-download-alt icon-white"></i> Download</a>
120+
<a class="btn btn-large" href="https://github.com/angular-ui/angular-ui"><i class="icon-github"></i> Code on Github</a><a class="btn btn-large btn-primary" href="https://github.com/angular-ui/angular-ui/tags"><i class="icon-download-alt icon-white"></i> Download</a><a class="btn btn-large" ng-click="showBuildModal()">Create a Build</a>
121121
</p>
122122
</div>
123123
<div class="bs-docs-social">
@@ -1201,5 +1201,26 @@ <h3>How?</h3>
12011201
})();
12021202

12031203
</script>
1204+
1205+
<div ui-modal class="fade" ng-model="buildModalShown">
1206+
<div class="modal-header"><h2>Create a Custom Build</h2></div>
1207+
<div class="modal-body">
1208+
<div ng-show="buildErrorText">
1209+
<h3 style="text-align: center;">{{buildErrorText</h3>
1210+
</div>
1211+
<div ng-hide="buildErrorText">
1212+
<h3 style="text-align: center;">Select the modules you wish to download:</h3>
1213+
<select style="width: 100%;" ui-select2 multiple
1214+
ui-options="{multiple: true}"
1215+
ng-model="selectedModules">
1216+
<option ng-repeat="m in modules" value="{{m}}">{{m | inflector:'humanize'}}</option>
1217+
</select>
1218+
</div>
1219+
</div>
1220+
<div class="modal-footer">
1221+
<a class="btn btn-primary" ng-disabled="!selectedModules.length" ng-click="selectedModules.length && downloadBuild()"><i class="icon-download-alt icon-white"></i> Download {{selectedModules.length}} Modules</a>
1222+
<a class="btn" ng-click="buildModalShown = false">Cancel</a>
1223+
</div>
1224+
</div>
12041225
</body>
12051226
</html>

js/app.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ angular.module('demoApp', ['ui'], function($locationProvider) {
2424
};
2525
}]);
2626

27+
function MainCtrl($scope, $http, orderByFilter) {
28+
var url = "http://50.116.42.77:3001";
29+
$scope.selectedModules = [];
30+
//iFrame for downloading
31+
var $iframe = $("<iframe>").css('display','none').appendTo(document.body);
32+
33+
$scope.showBuildModal = function() {
34+
$scope.buildModalShown = true;
35+
//Load modules if they aren't loaded yet
36+
if (!$scope.modules) {
37+
$http.get(url + "/api/angular-ui").then(function(response) {
38+
$scope.modules = response.data.modules;
39+
}, function() {
40+
$scope.buildGetErrorText = "Error retrieving build files from server.";
41+
});
42+
}
43+
};
44+
45+
$scope.downloadBuild = function() {
46+
var downloadUrl = url + "/api/angular-ui/download?";
47+
angular.forEach($scope.selectedModules, function(module) {
48+
downloadUrl += "modules=" + module + "&";
49+
});
50+
$iframe.attr('src','');
51+
$iframe.attr('src', downloadUrl);
52+
$scope.buildModalShown = false;
53+
};
54+
}
55+
2756
function CodeMirrorCtrl($scope) {
2857
$scope.codeMirrorModel = "var helloWorld = 'Success!';";
2958
}
@@ -170,4 +199,4 @@ function CalendarCtrl($scope) {
170199
$scope.events.splice(index,1);
171200
}
172201
}
173-
/* EOF */
202+
/* EOF */

0 commit comments

Comments
 (0)