diff --git a/src/Nancy.Demo.Samples/Views/contributors.sshtml b/src/Nancy.Demo.Samples/Views/contributors.sshtml index b627112..c8482ec 100644 --- a/src/Nancy.Demo.Samples/Views/contributors.sshtml +++ b/src/Nancy.Demo.Samples/Views/contributors.sshtml @@ -26,7 +26,7 @@

Contributors

-
+
-
+ -@EndSection& +@EndSection @Section['Scripts'] - function ContributorModel(data, onRemoved) { - var self = this - - self.avatarUrl = data.AvatarUrl; - self.id = data.Id, - self.name = data.Name; - self.url = data.Url; - self.username = data.Username; - - self.fullName = ko.computed(function () { - return self.username + ' (' + self.name + ')'; - }); - - self.deleteUrl = ko.computed(function () { - return '/contributors/' + self.username; - }); - - self.remove = function(data, event) { - $.ajax({ - type: 'DELETE', - url: '/contributors/' + self.username, - success: function() { - onRemoved(self); - } - }); - }; - - }; - - function ContributorsViewModel() { - var self = this; - - self.contributors = ko.observableArray(); - - $.getJSON("/api/contributors", function (response) { - var mapped = $.map(response, function (repo) { - return new ContributorModel(repo, self.onContributorRemoved); - }); - self.contributors(mapped); - }); - - self.onContributorRemoved = function(contributor) { - self.contributors.remove(contributor); - } - }; - - ko.applyBindings(new ContributorsViewModel()); + $(function() { + ko.applyBindings(new ContributorsViewModel()); + }); + + function ContributorModel(data, onRemoved) { + var self = this + + self.avatarUrl = data.AvatarUrl; + self.id = data.Id, + self.name = data.Name; + self.url = data.Url; + self.username = data.Username; + + self.fullName = ko.computed(function () { + return self.username + ' (' + self.name + ')'; + }); + + self.deleteUrl = ko.computed(function () { + return '/contributors/' + self.username; + }); + + self.remove = function(data, event) { + $.ajax({ + type: 'DELETE', + url: '/contributors/' + self.username, + success: function() { + onRemoved(self); + } + }); + }; + + }; + + function ContributorsViewModel() { + var self = this; + + self.contributors = ko.observableArray(); + + $.getJSON("/api/contributors", function (response) { + var mapped = $.map(response, function (repo) { + return new ContributorModel(repo, self.onContributorRemoved); + }); + self.contributors(mapped); + }); + + self.onContributorRemoved = function(contributor) { + self.contributors.remove(contributor); + } + }; @EndSection \ No newline at end of file diff --git a/src/Nancy.Demo.Samples/Views/index.sshtml b/src/Nancy.Demo.Samples/Views/index.sshtml index 48e37ac..66b74e6 100644 --- a/src/Nancy.Demo.Samples/Views/index.sshtml +++ b/src/Nancy.Demo.Samples/Views/index.sshtml @@ -2,30 +2,30 @@ @Section['Content'] -
-
+
+
- - - - -
-

- -

- -
- version by -
-
- -
+ + + + +
+

+ +

+ +
+ version by +
+
+ +

- +

Last updated:

- +
Packages used in this sample
@@ -41,65 +41,59 @@
-
+
-
- Read more -
-
+
+ Read more +
+
@EndSection @Section['Scripts'] - function viewRenderComplete() { - hljs.tabReplace = ' '; - hljs.initHighlighting(); - - $(".open").click(function () { - $.fancybox({ content: $('
').addClass('list-widget').html($('.content', $(this).parent()).html()) }); - }); - }; - - function DemoModel(data) { - var self = this - - self.author = data.Author; - self.description = data.Description; - self.gravatar = data.Gravatar; - self.hasNuget = data.HasNuget; - self.lastCommit = data.LastCommit; - self.name = data.Name; + $(function() { + hljs.tabReplace = ' '; + ko.applyBindings(new DemosViewModel()); + }); + + function DemoModel(data) { + var self = this + + self.author = data.Author; + self.description = data.Description; + self.gravatar = data.Gravatar; + self.hasNuget = data.HasNuget; + self.lastCommit = data.LastCommit; + self.name = data.Name; self.packages = data.Packages; - self.readMe = data.Readme; - self.url = data.Url; - self.version = data.Version; + self.readMe = data.Readme; + self.url = data.Url; + self.version = data.Version; - self.authorUrl = ko.computed(function () { - return 'http://github.com/' + self.author; - }); + self.authorUrl = ko.computed(function () { + return 'http://github.com/' + self.author; + }); self.nugetUrl = ko.computed(function() { return 'http://nuget.org/packages/' + self.name; }); - self.demoName = ko.computed(function () { - return self.name.replace('Nancy.Demo.', ''); - }); - }; - - function DemosViewModel() { - var self = this; + self.demoName = ko.computed(function () { + return self.name.replace('Nancy.Demo.', ''); + }); + }; - self.demos = ko.observableArray(); + function DemosViewModel() { + var self = this; - $.getJSON("/api/demos", function (response) { - var mapped = $.map(response, function (demo) { - return new DemoModel(demo); - }); - self.demos(mapped); - }); - }; + self.demos = ko.observableArray(); - ko.applyBindings(new DemosViewModel()); + $.getJSON("/api/demos", function (response) { + var mapped = $.map(response, function (demo) { + return new DemoModel(demo); + }); + self.demos(mapped); + }); + }; @EndSection \ No newline at end of file diff --git a/src/Nancy.Demo.Samples/Views/master.sshtml b/src/Nancy.Demo.Samples/Views/master.sshtml index 1085722..d8514f4 100644 --- a/src/Nancy.Demo.Samples/Views/master.sshtml +++ b/src/Nancy.Demo.Samples/Views/master.sshtml @@ -1,90 +1,90 @@  - - Nancy.Demo.Samples - - - - - - - - - - - - - -
- @Section['Content'] -
- - - - - - +
+
+
+ +
+ @Section['Content'] +
+ + + + + + @@ -178,21 +178,22 @@ }; ko.bindingHandlers.highlight = { - update: function (element, valueAccessor) { - var value = hljs.highlightAuto(ko.utils.unwrapObservable(valueAccessor())).value; - $(element).html(value); - } - }; + update: function (element, valueAccessor) { + var value = ko.utils.unwrapObservable(valueAccessor()) || ''; + var highlighted = hljs.highlightAuto(value).value; + $(element).html(highlighted); + } + }; ko.bindingHandlers.masonry = { update: function(element, valueAccessor, allBindingsAccessor) { var $element = $(element), list = ko.utils.unwrapObservable(allBindingsAccessor().foreach) masonry = ko.utils.unwrapObservable(valueAccessor()) - + if ($element.data('masonry')) $element.masonry('destroy') - + if (!list.length) return @@ -202,5 +203,5 @@ - + \ No newline at end of file