|
93 | 93 | <div class="container-fluid"> |
94 | 94 | <!-- Brand and toggle get grouped for better mobile display --> |
95 | 95 | <div class="navbar-header"> |
96 | | - <a class="navbar-brand glyphicon glyphicon-home" href="/"></a> |
| 96 | + <a class="navbar-brand glyphicon glyphicon-home" href="./"></a> |
97 | 97 | </div> |
98 | 98 |
|
99 | 99 |
|
@@ -147,7 +147,8 @@ <h3>The Generated Form</h3> |
147 | 147 | sf-form="form" |
148 | 148 | sf-schema="schema" |
149 | 149 | ng-submit="submitForm(ngform,modelData)" |
150 | | - sf-options="{ formDefaults: { ngModelOptions: { timezone: '+0430' } }}"> |
| 150 | + sf-options="{ formDefaults: { ngModelOptions: { timezone: '+0430' } }}" |
| 151 | + class="ng-cloak"> |
151 | 152 | </form> |
152 | 153 |
|
153 | 154 | <div ng-show="ngform.$valid"><em>Form is valid</em></div> |
@@ -220,7 +221,7 @@ <h3>Schema</h3> |
220 | 221 | <script type="text/javascript" src="../dist/angular-schema-form-bootstrap.js"></script> |
221 | 222 | <script type="text/javascript" src="add-on/calculate.js"></script> |
222 | 223 | <script type="text/javascript" src="../bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"></script> |
223 | | -<script type="text/javascript" src="../bower_components/angular-schema-form-colorpicker/bootstrap-colorpicker.min.js"></script> |
| 224 | +<script type="text/javascript" src="../bower_components/angular-schema-form-colorpicker/bootstrap-colorpicker.js"></script> |
224 | 225 | <script type="text/javascript" src="../bower_components/angular-schema-form-tinymce/bootstrap-tinymce.js"></script> |
225 | 226 |
|
226 | 227 | <script type="text/javascript"> |
@@ -267,27 +268,30 @@ <h3>Schema</h3> |
267 | 268 | $scope.hasFlash = swfobject.hasFlashPlayerVersion('9'); |
268 | 269 |
|
269 | 270 | // Load data from gist. |
270 | | - if ($location.path().length > 4) { |
| 271 | + if (window.location.hash.length > 4) { |
271 | 272 | $scope.navbarMode = 'loaded'; |
272 | | - var gistId = $location.path().replace('/',''); |
| 273 | + var gistId = window.location.hash.replace(/[\#\/]*/g, ''); |
273 | 274 | $scope.loading = true; |
274 | | - $http.get('https://api.github.com/gists/' + gistId).success(function(res) { |
275 | | - $scope.error = null; |
276 | | - $scope.tests.unshift({name: 'Gist'}); |
277 | | - $scope.selectedTest = $scope.tests[0]; |
278 | | - $scope.loadedData = { |
279 | | - created: moment(res.created_at).fromNow(), |
280 | | - user: res.user !== null ? res.user.login : 'Anonymous' |
| 275 | + $http.get('https://api.github.com/gists/' + gistId) |
| 276 | + .then(function(response) { |
| 277 | + $scope.error = null; |
| 278 | + $scope.tests.unshift({name: 'Gist'}); |
| 279 | + $scope.selectedTest = $scope.tests[0]; |
| 280 | + $scope.loadedData = { |
| 281 | + created: moment(response.data.created_at).fromNow(), |
| 282 | + user: response.data.user !== null ? response.data.user.login : 'Anonymous' |
| 283 | + } |
| 284 | + $scope.loading = false; |
| 285 | + $scope.schemaJson = response.data.files['schema.json'].content; |
| 286 | + $scope.formJson = response.data.files['form.json'].content; |
| 287 | + $scope.modelData = JSON.parse(response.data.files['model.json'].content); |
| 288 | + }, |
| 289 | + function() { |
| 290 | + $scope.loadedData = 'dummy'; |
| 291 | + $scope.error = 'Failed to load gist.'; |
| 292 | + $scope.selectedTest = $scope.tests[0]; |
281 | 293 | } |
282 | | - $scope.loading = false; |
283 | | - $scope.schemaJson = res.files['schema.json'].content; |
284 | | - $scope.formJson = res.files['form.json'].content; |
285 | | - $scope.modelData = JSON.parse(res.files['model.json'].content); |
286 | | - }).error(function() { |
287 | | - $scope.loadedData = 'dummy'; |
288 | | - $scope.error = 'Failed to load gist.'; |
289 | | - $scope.selectedTest = $scope.tests[0]; |
290 | | - }); |
| 294 | + ); |
291 | 295 | } else { |
292 | 296 | $scope.selectedTest = $scope.tests[0]; |
293 | 297 | } |
@@ -372,14 +376,15 @@ <h3>Schema</h3> |
372 | 376 | } |
373 | 377 | }; |
374 | 378 |
|
375 | | - $http.post('https://api.github.com/gists', gist).success(function(data) { |
| 379 | + $http.post('https://api.github.com/gists', gist) |
| 380 | + .then(function(data) { |
376 | 381 | $scope.error = null; |
377 | | - $location.path('/' + data.id); |
| 382 | + $location.hash(data.id); |
378 | 383 | $scope.savedGistData = { |
379 | 384 | data: data, |
380 | 385 | url: $location.absUrl() |
381 | 386 | }; |
382 | | - }).error(function() { |
| 387 | + }, function() { |
383 | 388 | $scope.error = 'Failed to save gist.'; |
384 | 389 | }); |
385 | 390 | }; |
|
0 commit comments