Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.

Commit ab92f5a

Browse files
bekospkozlowski-opensource
authored andcommitted
demo(all): use modal for download process
Closes angular-ui#1494
1 parent 0754ad7 commit ab92f5a

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

misc/demo/assets/app.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
99
var $iframe = angular.element('<iframe>').css('display','none');
1010
$document.find('body').append($iframe);
1111

12+
var downloadFileFromUrl = function(downloadUrl) {
13+
$iframe.attr('src', '');
14+
$iframe.attr('src', downloadUrl);
15+
};
16+
1217
$scope.showBuildModal = function() {
1318
var modalInstance = $modal.open({
1419
templateUrl: 'buildModal.html',
@@ -27,8 +32,28 @@ function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
2732
angular.forEach(selectedModules, function(module) {
2833
downloadUrl += "modules=" + module + "&";
2934
});
30-
$iframe.attr('src','');
31-
$iframe.attr('src', downloadUrl);
35+
downloadFileFromUrl(downloadUrl);
36+
});
37+
};
38+
39+
$scope.showDownloadModal = function() {
40+
var modalInstance = $modal.open({
41+
templateUrl: 'downloadModal.html',
42+
controller: 'DownloadCtrl'
43+
});
44+
45+
modalInstance.result.then(function(options) {
46+
var downloadUrl = ['http://angular-ui.github.io/bootstrap/ui-bootstrap-'];
47+
if (options.tpls) {
48+
downloadUrl.push('tpls-');
49+
}
50+
downloadUrl.push(options.version);
51+
if (options.minified) {
52+
downloadUrl.push('.min');
53+
}
54+
downloadUrl.push('.js');
55+
56+
downloadFileFromUrl(downloadUrl.join(''));
3257
});
3358
};
3459
}
@@ -54,3 +79,19 @@ var SelectModulesCtrl = function($scope, $modalInstance, modules) {
5479
$modalInstance.dismiss();
5580
};
5681
};
82+
83+
var DownloadCtrl = function($scope, $modalInstance) {
84+
$scope.options = {
85+
minified: true,
86+
tpls: true
87+
};
88+
89+
$scope.download = function (version) {
90+
$scope.options.version = version;
91+
$modalInstance.close($scope.options);
92+
};
93+
94+
$scope.cancel = function () {
95+
$modalInstance.dismiss();
96+
};
97+
}

misc/demo/index.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h1>
7171

7272
<p>
7373
<a class="btn btn-outline-inverse btn-lg" href="https://github.com/angular-ui/bootstrap"><i class="icon-github"></i>Code on Github</a>
74-
<a class="btn btn-outline-inverse btn-lg" href="https://github.com/angular-ui/bootstrap/tree/gh-pages">
74+
<a class="btn btn-outline-inverse btn-lg" ng-click="showDownloadModal()">
7575
<i class="glyphicon glyphicon-download-alt"></i> Download <small>(<%= pkg.version%>)</small>
7676
</a>
7777
<a class="btn btn-outline-inverse btn-lg" ng-click="showBuildModal()"><i class="glyphicon glyphicon-wrench"></i> Create a Build</a>
@@ -220,6 +220,37 @@ <h1><%= module.displayName %><small>
220220
<script src="assets/rainbow-generic.js"></script>
221221
<script src="assets/rainbow-javascript.js"></script>
222222
<script src="assets/rainbow-html.js"></script>
223+
<script type="text/ng-template" id="downloadModal.html">
224+
<div class="modal-header"><h4 class="modal-title">Download Angular UI Bootstrap</h4></div>
225+
<div class="modal-body">
226+
<form class="form-horizontal">
227+
<div class="form-group">
228+
<label class="col-sm-3 control-label"><strong>Build</strong></label>
229+
<div class="col-sm-9">
230+
<span class="btn-group">
231+
<button type="button" class="btn btn-default" ng-model="options.minified" btn-radio="true">Minified</button>
232+
<button type="button" class="btn btn-default" ng-model="options.minified" btn-radio="false">Uncompressed</button>
233+
</span>
234+
<small class="help-block">Use <b>Minified</b> version in your deployed application. <b>Uncompressed</b> source code is useful only for debugging and development purpose.</small>
235+
</div>
236+
</div>
237+
<div class="form-group">
238+
<label class="col-sm-3 control-label"><strong>Include Templates</strong></label>
239+
<div class="col-sm-9">
240+
<span class="btn-group">
241+
<button type="button" class="btn btn-default" ng-model="options.tpls" btn-radio="true">Yes</button>
242+
<button type="button" class="btn btn-default" ng-model="options.tpls" btn-radio="false">No</button>
243+
</span>
244+
<small class="help-block">Whether you want to include the <i>default templates</i>, bundled with most of the directives. These templates are based on Twitter Bootstrap's markup and CSS.</small>
245+
</div>
246+
</div>
247+
</form>
248+
</div>
249+
<div class="modal-footer">
250+
<a class="btn btn-default" ng-click="cancel()">Cancel</a>
251+
<a class="btn btn-primary" ng-click="download('<%= pkg.version%>')"><i class="glyphicon glyphicon-download-alt"></i> Download <%= pkg.version %></a>
252+
</div>
253+
</script>
223254
<script type="text/ng-template" id="buildModal.html">
224255
<div class="modal-header">
225256
<h4>

0 commit comments

Comments
 (0)