Skip to content

Commit f024fb0

Browse files
committed
Updates to example to get gist working again
1 parent ea1e63e commit f024fb0

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

examples/example.html

+29-24
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<div class="container-fluid">
9494
<!-- Brand and toggle get grouped for better mobile display -->
9595
<div class="navbar-header">
96-
<a class="navbar-brand glyphicon glyphicon-home" href="/"></a>
96+
<a class="navbar-brand glyphicon glyphicon-home" href="./"></a>
9797
</div>
9898

9999

@@ -147,7 +147,8 @@ <h3>The Generated Form</h3>
147147
sf-form="form"
148148
sf-schema="schema"
149149
ng-submit="submitForm(ngform,modelData)"
150-
sf-options="{ formDefaults: { ngModelOptions: { timezone: '+0430' } }}">
150+
sf-options="{ formDefaults: { ngModelOptions: { timezone: '+0430' } }}"
151+
class="ng-cloak">
151152
</form>
152153

153154
<div ng-show="ngform.$valid"><em>Form is valid</em></div>
@@ -220,7 +221,7 @@ <h3>Schema</h3>
220221
<script type="text/javascript" src="../dist/angular-schema-form-bootstrap.js"></script>
221222
<script type="text/javascript" src="add-on/calculate.js"></script>
222223
<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>
224225
<script type="text/javascript" src="../bower_components/angular-schema-form-tinymce/bootstrap-tinymce.js"></script>
225226

226227
<script type="text/javascript">
@@ -267,27 +268,30 @@ <h3>Schema</h3>
267268
$scope.hasFlash = swfobject.hasFlashPlayerVersion('9');
268269

269270
// Load data from gist.
270-
if ($location.path().length > 4) {
271+
if (window.location.hash.length > 4) {
271272
$scope.navbarMode = 'loaded';
272-
var gistId = $location.path().replace('/','');
273+
var gistId = window.location.hash.replace(/[\#\/]*/g, '');
273274
$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];
281293
}
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+
);
291295
} else {
292296
$scope.selectedTest = $scope.tests[0];
293297
}
@@ -372,14 +376,15 @@ <h3>Schema</h3>
372376
}
373377
};
374378

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) {
376381
$scope.error = null;
377-
$location.path('/' + data.id);
382+
$location.hash(data.id);
378383
$scope.savedGistData = {
379384
data: data,
380385
url: $location.absUrl()
381386
};
382-
}).error(function() {
387+
}, function() {
383388
$scope.error = 'Failed to save gist.';
384389
});
385390
};

0 commit comments

Comments
 (0)