1- angular . module ( 'bootstrapDemoApp' , [ 'ui.bootstrap' , 'plunker' ] , function ( $httpProvider ) {
1+ angular . module ( 'bootstrapDemoApp' , [ 'ui.bootstrap' , 'plunker' , 'ngTouch' ] , function ( $httpProvider ) {
22 FastClick . attach ( document . body ) ;
33 delete $httpProvider . defaults . headers . common [ 'X-Requested-With' ] ;
4- } ) ;
4+ } ) . run ( [ '$location' , function ( $location ) {
5+ //Allows us to navigate to the correct element on initialization
6+ if ( $location . path ( ) !== '' && $location . path ( ) !== '/' ) {
7+ smoothScroll ( document . getElementById ( $location . path ( ) . substring ( 1 ) ) , 500 , function ( el ) {
8+ location . replace ( el . id ) ;
9+ } ) ;
10+ }
11+ } ] ) ;
512
6- function MainCtrl ( $scope , $http , $document , $modal , orderByFilter ) {
7- var url = "http://50.116.42.77:3001" ;
8- //iFrame for downloading
9- var $iframe = angular . element ( '<iframe>' ) . css ( 'display' , 'none' ) ;
10- $document . find ( 'body' ) . append ( $iframe ) ;
13+ var builderUrl = "http://50.116.42.77:3001" ;
1114
12- var downloadFileFromUrl = function ( downloadUrl ) {
13- $iframe . attr ( 'src' , '' ) ;
14- $iframe . attr ( 'src' , downloadUrl ) ;
15- } ;
16-
15+ function MainCtrl ( $scope , $http , $document , $modal , orderByFilter ) {
1716 $scope . showBuildModal = function ( ) {
1817 var modalInstance = $modal . open ( {
1918 templateUrl : 'buildModal.html' ,
2019 controller : 'SelectModulesCtrl' ,
2120 resolve : {
2221 modules : function ( ) {
23- return $http . get ( url + "/api/bootstrap" ) . then ( function ( response ) {
22+ return $http . get ( builderUrl + "/api/bootstrap" ) . then ( function ( response ) {
2423 return response . data . modules ;
2524 } ) ;
2625 }
2726 }
2827 } ) ;
29-
30- modalInstance . result . then ( function ( selectedModules ) {
31- var downloadUrl = url + "/api/bootstrap/download?" ;
32- angular . forEach ( selectedModules , function ( module ) {
33- downloadUrl += "modules=" + module + "&" ;
34- } ) ;
35- downloadFileFromUrl ( downloadUrl ) ;
36- } ) ;
3728 } ;
38-
29+
3930 $scope . showDownloadModal = function ( ) {
4031 var modalInstance = $modal . open ( {
4132 templateUrl : 'downloadModal.html' ,
4233 controller : 'DownloadCtrl'
4334 } ) ;
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 ( '' ) ) ;
57- } ) ;
5835 } ;
5936}
6037
6138var SelectModulesCtrl = function ( $scope , $modalInstance , modules ) {
62-
6339 $scope . selectedModules = [ ] ;
6440 $scope . modules = modules ;
6541
@@ -78,20 +54,39 @@ var SelectModulesCtrl = function($scope, $modalInstance, modules) {
7854 $scope . cancel = function ( ) {
7955 $modalInstance . dismiss ( ) ;
8056 } ;
57+
58+ $scope . download = function ( selectedModules ) {
59+ var downloadUrl = builderUrl + "/api/bootstrap/download?" ;
60+ angular . forEach ( selectedModules , function ( module ) {
61+ downloadUrl += "modules=" + module + "&" ;
62+ } ) ;
63+ return downloadUrl ;
64+ } ;
8165} ;
8266
8367var DownloadCtrl = function ( $scope , $modalInstance ) {
8468 $scope . options = {
8569 minified : true ,
8670 tpls : true
8771 } ;
88-
72+
8973 $scope . download = function ( version ) {
90- $scope . options . version = version ;
91- $modalInstance . close ( $scope . options ) ;
74+ var options = $scope . options ;
75+
76+ var downloadUrl = [ 'ui-bootstrap-' ] ;
77+ if ( options . tpls ) {
78+ downloadUrl . push ( 'tpls-' ) ;
79+ }
80+ downloadUrl . push ( version ) ;
81+ if ( options . minified ) {
82+ downloadUrl . push ( '.min' ) ;
83+ }
84+ downloadUrl . push ( '.js' ) ;
85+
86+ return downloadUrl . join ( '' ) ;
9287 } ;
93-
88+
9489 $scope . cancel = function ( ) {
9590 $modalInstance . dismiss ( ) ;
9691 } ;
97- }
92+ }
0 commit comments