├── .gitignore ├── build.bat ├── license.txt ├── readme.md ├── src ├── Example │ ├── Controllers │ │ ├── ColorController.cs │ │ └── HomeController.cs │ ├── Example.csproj │ ├── Global.asax │ ├── Global.asax.cs │ ├── Helpers.cs │ ├── Models │ │ ├── Color.cs │ │ └── ColorRepository.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scripts │ │ ├── app │ │ │ ├── Event.js │ │ │ └── namespace.js │ │ ├── color-picker │ │ │ ├── ColorPickerViewModel.js │ │ │ ├── ColorViewModel.js │ │ │ ├── helpers.js │ │ │ ├── page.js │ │ │ └── slider.js │ │ └── lib │ │ │ ├── Class.js │ │ │ ├── jquery-ui.js │ │ │ ├── jquery.js │ │ │ ├── jquery.tmpl.js │ │ │ ├── jquery.unobtrusive-ajax.js │ │ │ ├── jquery.validate-vsdoc.js │ │ │ ├── jquery.validate.js │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ ├── knockout.js │ │ │ └── module.txt │ ├── Styles │ │ ├── app │ │ │ └── site.css │ │ ├── base │ │ │ ├── forms.css │ │ │ ├── reset.css │ │ │ ├── typography.css │ │ │ └── validation.css │ │ ├── color-picker │ │ │ ├── color-picker.css │ │ │ ├── images │ │ │ │ └── color_swatch.png │ │ │ └── saved-colors.css │ │ └── jquery-ui │ │ │ ├── images │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ └── ui-icons_cd0a0a_256x240.png │ │ │ └── jquery-ui.css │ ├── Views │ │ ├── Home │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Fork.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _Tweet.cshtml │ │ ├── Web.config │ │ └── _ViewStart.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ └── Web.config.orig ├── Knapsack.Shell │ ├── Knapsack.Shell.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── app.config ├── Knapsack.UnitTests │ ├── CoffeeScript │ │ └── CoffeeScriptCompiler.cs │ ├── Configuration │ │ └── KnapsackSection.cs │ ├── Knapsack.UnitTests.csproj │ ├── Module.cs │ ├── ModuleContainer.cs │ ├── ModuleContainerBuilder.cs │ ├── ModuleManifest.cs │ ├── ModuleWriter.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReferenceBuilder.cs │ ├── Resource.cs │ ├── UnresolvedCoffeeScriptParser.cs │ ├── UnresolvedCssParser.cs │ ├── UnresolvedJavaScriptParser.cs │ ├── UnresolvedModule.cs │ ├── UnresolvedResource.cs │ ├── Utilities │ │ ├── ByteArrayExtensions.cs │ │ └── JavaScriptUtilities.cs │ ├── Web │ │ ├── BufferStream.cs │ │ ├── ExceptionCachedManager.cs │ │ ├── KnapsackHttpHandler.cs │ │ ├── Mvc │ │ │ └── HtmlHelperExtensions.cs │ │ └── PageHelper.cs │ └── packages.config ├── Knapsack.sln ├── Knapsack │ ├── CoffeeScript │ │ ├── CoffeeScriptCompiler.cs │ │ ├── CompileException.cs │ │ └── ICoffeeScriptCompiler.cs │ ├── Configuration │ │ ├── KnapsackSection.cs │ │ ├── ModuleCollection.cs │ │ ├── ModuleElement.cs │ │ └── ModuleMode.cs │ ├── IModuleWriter.cs │ ├── IReferenceBuilder.cs │ ├── IUnresolvedResourceParser.cs │ ├── Knapsack.csproj │ ├── Knapsack.nuspec │ ├── Module.cs │ ├── ModuleContainer.cs │ ├── ModuleContainerBuilder.cs │ ├── ModuleDifference.cs │ ├── ModuleManifest.cs │ ├── ModuleManifestReader.cs │ ├── ModuleManifestWriter.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── ReferenceBuilder.cs │ ├── Resource.cs │ ├── Resources │ │ └── coffeescript.js │ ├── ScriptModuleContainerBuilder.cs │ ├── ScriptModuleWriter.cs │ ├── StylesheetModuleContainerBuilder.cs │ ├── StylesheetModuleWriter.cs │ ├── UnresolvedCoffeeScriptParser.cs │ ├── UnresolvedCssParser.cs │ ├── UnresolvedJavaScriptParser.cs │ ├── UnresolvedModule.cs │ ├── UnresolvedModuleBuilder.cs │ ├── UnresolvedResource.cs │ ├── UnresolvedScriptModuleBuilder.cs │ ├── UnresolvedStylesheetModuleBuilder.cs │ ├── Utilities │ │ ├── ByteArrayExtensions.cs │ │ ├── Graph.cs │ │ ├── JavaScriptUtilities.cs │ │ └── StreamExtensions.cs │ ├── Views │ │ └── Web.config.transform │ ├── Web.config.transform │ ├── Web │ │ ├── BufferStream.cs │ │ ├── ExceptionCachedManager.cs │ │ ├── IManager.cs │ │ ├── IPageHelper.cs │ │ ├── KnapsackHttpHandler.cs │ │ ├── KnapsackHttpModule.cs │ │ ├── Manager.cs │ │ ├── Mvc │ │ │ └── HtmlHelperExtensions.cs │ │ └── PageHelper.cs │ └── packages.config └── packages │ ├── AjaxMin.4.13.4076.28499 │ ├── AjaxMin.4.13.4076.28499.nupkg │ └── lib │ │ └── AjaxMin.dll │ ├── Jurassic.2.1.0 │ ├── Jurassic.2.1.0.nupkg │ └── lib │ │ └── net40 │ │ └── Jurassic.dll │ ├── Moq.4.0.10827 │ ├── License.txt │ ├── Moq.4.0.10827.nupkg │ ├── Moq.chm │ └── lib │ │ ├── NET35 │ │ ├── Moq.dll │ │ ├── Moq.pdb │ │ └── Moq.xml │ │ ├── NET40 │ │ ├── Moq.dll │ │ ├── Moq.pdb │ │ └── Moq.xml │ │ └── Silverlight4 │ │ ├── Castle.Core.dll │ │ ├── Moq.Silverlight.dll │ │ ├── Moq.Silverlight.pdb │ │ └── Moq.Silverlight.xml │ ├── Should.1.1.12.0 │ ├── Should.1.1.12.0.nupkg │ └── lib │ │ └── Should.dll │ └── repositories.config └── tools ├── EULA.txt ├── HTML.xslt ├── ILRepack.exe ├── ILRepack.pdb ├── NUnitXml.xslt ├── xunit.console.clr4.exe ├── xunit.console.clr4.exe.config ├── xunit.console.clr4.x86.exe ├── xunit.console.clr4.x86.exe.config ├── xunit.console.exe ├── xunit.console.exe.config ├── xunit.console.x86.exe ├── xunit.console.x86.exe.config ├── xunit.dll ├── xunit.dll.tdnet ├── xunit.extensions.dll ├── xunit.extensions.xml ├── xunit.gui.clr4.exe ├── xunit.gui.clr4.x86.exe ├── xunit.gui.exe ├── xunit.gui.x86.exe ├── xunit.installer.exe ├── xunit.runner.msbuild.dll ├── xunit.runner.tdnet.dll ├── xunit.runner.utility.dll ├── xunit.runner.utility.xml └── xunit.xml /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | *.user 4 | *.suo 5 | *.cache 6 | build/ -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | mkdir build 2 | del /S /Q build\* 3 | 4 | 5 | mkdir build\nuget 6 | nuget pack -Symbols src\Knapsack\Knapsack.csproj -OutputDirectory build\nuget 7 | 8 | 9 | mkdir build\shell 10 | msbuild /p:Configuration=Release src\Knapsack.Shell\Knapsack.Shell.csproj 11 | tools\ilrepack.exe /out:build\shell\knapsack.exe src\Knapsack.Shell\bin\Release\Knapsack.Shell.exe src\Knapsack\bin\Release\Knapsack.dll src\Knapsack\bin\Release\AjaxMin.dll src\Knapsack\bin\Release\Jurassic.dll -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Andrew Davey (andrew@equin.co.uk) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | This project has moved to https://github.com/andrewdavey/cassette -------------------------------------------------------------------------------- /src/Example/Controllers/ColorController.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Web.Mvc; 3 | using Example.Models; 4 | 5 | namespace Example.Controllers 6 | { 7 | public class ColorController : Controller 8 | { 9 | // Demo code - please don't do this for real! 10 | static ColorRepository colors = new ColorRepository(); 11 | 12 | public ActionResult List() 13 | { 14 | return Json( 15 | colors.Select(color => new 16 | { 17 | url = Url.RouteUrl("Color", new { id = color.Id }), 18 | red = color.Red, 19 | green = color.Green, 20 | blue = color.Blue 21 | }), 22 | JsonRequestBehavior.AllowGet 23 | ); 24 | } 25 | 26 | [HttpPost, ActionName("list")] 27 | public ActionResult Add(byte red, byte green, byte blue) 28 | { 29 | var newColor = colors.Add(red, green, blue); 30 | 31 | var colorUrl = Url.RouteUrl("Color", new { id = newColor.Id }); 32 | Response.StatusCode = 201; // Created 33 | Response.AddHeader("Location", colorUrl); 34 | return new EmptyResult(); 35 | } 36 | 37 | [HttpDelete, ActionName("item")] 38 | public void Delete(int id) 39 | { 40 | colors.Delete(id); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Example/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace Example.Controllers 4 | { 5 | public class HomeController : Controller 6 | { 7 | public ActionResult Index() 8 | { 9 | return View(new 10 | { 11 | colorsUrl = Url.RouteUrl("Colors") 12 | }); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Example/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Example.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/Example/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace Example 9 | { 10 | // Note: For instructions on enabling IIS6 or IIS7 classic mode, 11 | // visit http://go.microsoft.com/?LinkId=9394801 12 | 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 16 | { 17 | filters.Add(new HandleErrorAttribute()); 18 | } 19 | 20 | public static void RegisterRoutes(RouteCollection routes) 21 | { 22 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 23 | 24 | routes.MapRoute( 25 | "Color", 26 | "colors/{id}", 27 | new { controller = "Color", action = "item" } 28 | ); 29 | routes.MapRoute( 30 | "Colors", 31 | "colors", 32 | new { controller = "Color", action = "list" } 33 | ); 34 | routes.MapRoute( 35 | "Default", // Route name 36 | "{controller}/{action}/{id}", // URL with parameters 37 | new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 38 | ); 39 | 40 | } 41 | 42 | protected void Application_Start() 43 | { 44 | AreaRegistration.RegisterAllAreas(); 45 | 46 | RegisterGlobalFilters(GlobalFilters.Filters); 47 | RegisterRoutes(RouteTable.Routes); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/Example/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | using System.Web.Script.Serialization; 4 | 5 | namespace Example 6 | { 7 | public static class Helpers 8 | { 9 | public static IHtmlString AssignPageViewData(this HtmlHelper html, object obj) 10 | { 11 | var serializer = new JavaScriptSerializer(); 12 | var json = serializer.Serialize(obj); 13 | 14 | return new HtmlString( 15 | "" 18 | ); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Example/Models/Color.cs: -------------------------------------------------------------------------------- 1 | namespace Example.Models 2 | { 3 | public class Color 4 | { 5 | public int Id { get; set; } 6 | public byte Red { get; set; } 7 | public byte Green { get; set; } 8 | public byte Blue { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/Example/Models/ColorRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Example.Models 5 | { 6 | public class ColorRepository : IEnumerable 7 | { 8 | List colors = new List(); 9 | 10 | public Color Add(byte red, byte green, byte blue) 11 | { 12 | var id = 1 + (colors.Any() ? colors.Max(c => c.Id) : 0); 13 | var color = new Color 14 | { 15 | Id = id, 16 | Red = red, 17 | Green = green, 18 | Blue = blue 19 | }; 20 | colors.Add(color); 21 | return color; 22 | } 23 | 24 | public void Delete(int id) 25 | { 26 | var color = colors.FirstOrDefault(c => c.Id == id); 27 | if (color != null) 28 | { 29 | colors.Remove(color); 30 | } 31 | } 32 | 33 | public IEnumerator GetEnumerator() 34 | { 35 | return colors.GetEnumerator(); 36 | } 37 | 38 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 39 | { 40 | return GetEnumerator(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Example/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Example")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Example")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d61d3081-55c9-4225-a690-7f34c5cf33f9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Example/Scripts/app/Event.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | (function () { 5 | 6 | this.Example.Event = Class.extend({ 7 | 8 | init: function () { 9 | this.handlers = []; 10 | }, 11 | 12 | addHandler: function (handler) { 13 | this.handlers.push(handler); 14 | }, 15 | 16 | raise: function () { 17 | var eventArgs = arguments; 18 | this.handlers.forEach(function (handler) { 19 | handler.apply(null, eventArgs); 20 | }); 21 | } 22 | 23 | }); 24 | 25 | }).call(this); -------------------------------------------------------------------------------- /src/Example/Scripts/app/namespace.js: -------------------------------------------------------------------------------- 1 | // Global namespace for this application's scripts. 2 | this.Example = {}; -------------------------------------------------------------------------------- /src/Example/Scripts/color-picker/ColorPickerViewModel.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | 8 | // Immediate anonymous function wraps entire file to prevent code leaking into global scope. 9 | (function () { 10 | 11 | // Locally reference external objects and functions. (Optional, but can save on lots of typing!) 12 | var helpers = this.Example.helpers; 13 | var ColorViewModel = this.Example.ColorViewModel; 14 | 15 | // Add a new class to the application's global namespace 16 | this.Example.ColorPickerViewModel = Class.extend({ 17 | 18 | // Constructor of the view model object 19 | init: function (pageViewData) { 20 | this.colorsUrl = pageViewData.colorsUrl; 21 | 22 | // Observable properties 23 | this.red = ko.observable(0); 24 | this.green = ko.observable(0); 25 | this.blue = ko.observable(0); 26 | this.color = ko.dependentObservable(this.getCurrentColorHex, this); 27 | this.savedColors = ko.observableArray([]); 28 | 29 | this.downloadColors(); 30 | }, 31 | 32 | downloadColors: function () { 33 | var colorPicker = this; 34 | $.get( 35 | this.colorsUrl, 36 | function (colors) { 37 | colors.forEach(function (colorData) { 38 | colorPicker.addColor(colorData); 39 | }); 40 | } 41 | ); 42 | }, 43 | 44 | getCurrentColorHex: function () { 45 | return helpers.getColorHexString( 46 | this.red(), 47 | this.green(), 48 | this.blue() 49 | ); 50 | }, 51 | 52 | random: function () { 53 | var color = helpers.randomColor(); 54 | 55 | this.red(color.red); 56 | this.green(color.green); 57 | this.blue(color.blue); 58 | }, 59 | 60 | save: function () { 61 | var data = { 62 | red: this.red(), 63 | blue: this.blue(), 64 | green: this.green() 65 | }; 66 | $.ajax({ 67 | type: "post", 68 | url: this.colorsUrl, 69 | data: data, 70 | complete: function (xhr) { 71 | // Expect the server to return with status code 201 Created 72 | // and a URL for the new color resource. 73 | data.url = xhr.getResponseHeader("Location"); 74 | this.addColor(data); 75 | } .bind(this) 76 | }); 77 | }, 78 | 79 | addColor: function (colorData) { 80 | var viewModel = new ColorViewModel(colorData); 81 | viewModel.onDeleted.addHandler(this.onColorDeleted.bind(this)); 82 | this.savedColors.push(viewModel); 83 | }, 84 | 85 | onColorDeleted: function (colorViewModel) { 86 | this.savedColors.remove(colorViewModel); 87 | } 88 | 89 | }); 90 | 91 | }).call(this); -------------------------------------------------------------------------------- /src/Example/Scripts/color-picker/ColorViewModel.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | 7 | (function () { 8 | 9 | var helpers = this.Example.helpers; 10 | var Event = this.Example.Event; 11 | 12 | this.Example.ColorViewModel = Class.extend({ 13 | 14 | init: function (viewData) { 15 | this.url = viewData.url; 16 | this.color = helpers.getColorHexString( 17 | viewData.red, 18 | viewData.green, 19 | viewData.blue 20 | ); 21 | this.onDeleted = new Event(); 22 | }, 23 | 24 | deleteColor: function () { 25 | $.ajax({ 26 | type: "delete", 27 | url: this.url 28 | }); 29 | this.onDeleted.raise(this); 30 | } 31 | 32 | }); 33 | 34 | }).call(this); -------------------------------------------------------------------------------- /src/Example/Scripts/color-picker/helpers.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | (function () { 4 | 5 | // Private functions. Only used by this file; not exposed globally. 6 | function convertNumberToHexString(number) { 7 | return ('0' + number.toString(16)).substr(-2); 8 | } 9 | 10 | function randomByte() { 11 | // Random number between 0 and 255. 12 | return Math.floor(Math.random() * 256); 13 | } 14 | 15 | // Public helper functions 16 | this.Example.helpers = { 17 | 18 | getColorHexString: function (red, green, blue) { 19 | return "#" + 20 | convertNumberToHexString(red) + 21 | convertNumberToHexString(green) + 22 | convertNumberToHexString(blue); 23 | }, 24 | 25 | randomColor: function () { 26 | return { 27 | red: randomByte(), 28 | green: randomByte(), 29 | blue: randomByte() 30 | }; 31 | } 32 | 33 | }; 34 | 35 | }).call(this); -------------------------------------------------------------------------------- /src/Example/Scripts/color-picker/page.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | $(function () { 6 | // Entry point of page code. 7 | // Initialize KnockoutJS to data bind a view model to the UI. 8 | ko.applyBindings( 9 | // The view page must assign a global viewData property 10 | // for us to use here. 11 | new Example.ColorPickerViewModel(window.pageViewData) 12 | ); 13 | }); -------------------------------------------------------------------------------- /src/Example/Scripts/color-picker/slider.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | (function () { 6 | 7 | // Extend knockout with a custom binding handler. 8 | // This displays a jQuery UI slider control which is bound to the 9 | // value of an observable view model property. 10 | 11 | this.ko.bindingHandlers['slider'] = { 12 | 13 | init: function (element, valueAccessor) { 14 | initialValue = ko.utils.unwrapObservable(valueAccessor()); 15 | // Create the jQuery UI slider. 16 | $(element).slider({ 17 | min: 0, 18 | max: 255, 19 | value: initialValue, 20 | // On slide, update the view model property. 21 | slide: function (event, ui) { 22 | valueAccessor()(ui.value); 23 | } 24 | }); 25 | }, 26 | 27 | update: function (element, valueAccessor) { 28 | // When the view model property changes, update the slider. 29 | var value = ko.utils.unwrapObservable(valueAccessor()); 30 | $(element).slider('option', 'value', value); 31 | } 32 | 33 | }; 34 | 35 | }).call(this); -------------------------------------------------------------------------------- /src/Example/Scripts/lib/Class.js: -------------------------------------------------------------------------------- 1 | /* Simple JavaScript Inheritance 2 | * By John Resig http://ejohn.org/ 3 | * MIT Licensed. 4 | */ 5 | // Inspired by base2 and Prototype 6 | (function () { 7 | var initializing = false, fnTest = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/; 8 | // The base Class implementation (does nothing) 9 | this.Class = function () { }; 10 | 11 | // Create a new Class that inherits from this class 12 | Class.extend = function (prop) { 13 | var _super = this.prototype; 14 | 15 | // Instantiate a base class (but only create the instance, 16 | // don't run the init constructor) 17 | initializing = true; 18 | var prototype = new this(); 19 | initializing = false; 20 | 21 | // Copy the properties over onto the new prototype 22 | for (var name in prop) { 23 | // Check if we're overwriting an existing function 24 | prototype[name] = typeof prop[name] == "function" && 25 | typeof _super[name] == "function" && fnTest.test(prop[name]) ? 26 | (function (name, fn) { 27 | return function () { 28 | var tmp = this._super; 29 | 30 | // Add a new ._super() method that is the same method 31 | // but on the super-class 32 | this._super = _super[name]; 33 | 34 | // The method only need to be bound temporarily, so we 35 | // remove it when we're done executing 36 | var ret = fn.apply(this, arguments); 37 | this._super = tmp; 38 | 39 | return ret; 40 | }; 41 | })(name, prop[name]) : 42 | prop[name]; 43 | } 44 | 45 | // The dummy class constructor 46 | function Class() { 47 | // All construction is actually done in the init method 48 | if (!initializing && this.init) 49 | this.init.apply(this, arguments); 50 | } 51 | 52 | // Populate our constructed prototype object 53 | Class.prototype = prototype; 54 | 55 | // Enforce the constructor to be what we expect 56 | Class.constructor = Class; 57 | 58 | // And make this class extendable 59 | Class.extend = arguments.callee; 60 | 61 | return Class; 62 | }; 63 | })(); -------------------------------------------------------------------------------- /src/Example/Scripts/lib/module.txt: -------------------------------------------------------------------------------- 1 | jquery.js 2 | jquery-ui.js 3 | jquery.unobtrusive-ajax.js 4 | jquery.validate.js 5 | jquery.validate.unobtrusive.js 6 | Class.js 7 | jquery.tmpl.js 8 | knockout.js -------------------------------------------------------------------------------- /src/Example/Styles/app/site.css: -------------------------------------------------------------------------------- 1 | /* 2 | @reference "../base/reset.css"; 3 | @reference "../base/typography.css"; 4 | */ 5 | 6 | body { 7 | color: #232323; 8 | background-color: #fff; 9 | padding: 40px; 10 | } 11 | 12 | .about { 13 | width: 40em; 14 | margin-bottom: 2em; 15 | } 16 | 17 | #footer { 18 | padding-top: 40px; 19 | clear: left; 20 | } -------------------------------------------------------------------------------- /src/Example/Styles/base/forms.css: -------------------------------------------------------------------------------- 1 | /* Styles for basic forms 2 | -----------------------------------------------------------*/ 3 | 4 | fieldset 5 | { 6 | border:1px solid #ddd; 7 | padding:0 1.4em 1.4em 1.4em; 8 | margin:0 0 1.5em 0; 9 | } 10 | 11 | legend 12 | { 13 | font-size:1.2em; 14 | font-weight: bold; 15 | } 16 | 17 | textarea 18 | { 19 | min-height: 75px; 20 | } 21 | 22 | .editor-label 23 | { 24 | margin: 1em 0 0 0; 25 | } 26 | 27 | .editor-field 28 | { 29 | margin:0.5em 0 0 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/Example/Styles/base/reset.css: -------------------------------------------------------------------------------- 1 | * { margin: 0; padding: 0 } -------------------------------------------------------------------------------- /src/Example/Styles/base/typography.css: -------------------------------------------------------------------------------- 1 | /* 2 | @reference "reset.css"; 3 | */ 4 | 5 | body { 6 | font-size: 75%; 7 | font-family: Verdana, Tahoma, Arial, "Helvetica Neue", Helvetica, Sans-Serif; 8 | } 9 | 10 | h1 { 11 | margin-bottom: 1em; 12 | } 13 | 14 | p { 15 | margin-bottom: 1em; 16 | line-height: 1.4em; 17 | } -------------------------------------------------------------------------------- /src/Example/Styles/base/validation.css: -------------------------------------------------------------------------------- 1 | /* Styles for validation helpers 2 | -----------------------------------------------------------*/ 3 | .field-validation-error 4 | { 5 | color: #ff0000; 6 | } 7 | 8 | .field-validation-valid 9 | { 10 | display: none; 11 | } 12 | 13 | .input-validation-error 14 | { 15 | border: 1px solid #ff0000; 16 | background-color: #ffeeee; 17 | } 18 | 19 | .validation-summary-errors 20 | { 21 | font-weight: bold; 22 | color: #ff0000; 23 | } 24 | 25 | .validation-summary-valid 26 | { 27 | display: none; 28 | } -------------------------------------------------------------------------------- /src/Example/Styles/color-picker/color-picker.css: -------------------------------------------------------------------------------- 1 | /* @reference "../jquery-ui/jquery-ui.css"; */ 2 | 3 | .color-picker { 4 | float: left; 5 | margin-right: 30px; 6 | } 7 | 8 | .color-picker h2 { 9 | background-image: url(images/color_swatch.png); 10 | background-position: left center; 11 | background-repeat: no-repeat; 12 | padding-left: 20px; 13 | } 14 | 15 | .color-picker tr { 16 | height: 30px; 17 | } 18 | 19 | .color-picker th { 20 | text-align: left; 21 | } 22 | 23 | .color-sliders { 24 | height: 120px; 25 | padding: 10px; 26 | } 27 | 28 | .color-slider { 29 | width: 255px; 30 | margin-left: 10px; 31 | margin-right: 10px; 32 | } 33 | 34 | .chosen-color { 35 | width: 50px; 36 | height: 50px; 37 | border: solid 1px #000; 38 | margin: 10px; 39 | float: left; 40 | } 41 | 42 | .chosen-color-hex { 43 | float: left; 44 | height: 50px; 45 | margin: 10px; 46 | line-height: 50px; 47 | } -------------------------------------------------------------------------------- /src/Example/Styles/color-picker/images/color_swatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/color-picker/images/color_swatch.png -------------------------------------------------------------------------------- /src/Example/Styles/color-picker/saved-colors.css: -------------------------------------------------------------------------------- 1 | .saved-colors { 2 | float: left; 3 | margin-right: 30px; 4 | } 5 | 6 | .saved-colors li { 7 | list-style-type: none; 8 | line-height: 20px; 9 | height: 20px; 10 | margin-bottom: 2px; 11 | } 12 | 13 | .saved-colors .color-box { 14 | width: 20px; 15 | height: 20px; 16 | display: inline-block; 17 | vertical-align: top; 18 | } -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /src/Example/Styles/jquery-ui/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewdavey/knapsack/ebbaee9734e44e0d196679366ca4098793462030/src/Example/Styles/jquery-ui/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /src/Example/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model object 2 | @{ 3 | ViewBag.Title = "Example Web App"; 4 | 5 | Html.ReferenceScript("scripts/color-picker"); 6 | Html.ReferenceStylesheet("styles/color-picker"); 7 | } 8 |
9 |

Color Picker

10 | 11 | 12 | 13 | @* We've added a 'slider' binding to Knockout's built-in object. See slider.js *@ 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 42 | 43 |
Red
16 | 17 |
Green
Blue
Color 32 |
33 |
34 |
39 | 40 | 41 |
44 |
45 |
46 |

Saved Colors

47 |

48 | Choose some colors... 49 |

50 |
    51 |
    52 | 53 | 54 | 61 | 62 | 63 | @Html.AssignPageViewData(Model) -------------------------------------------------------------------------------- /src/Example/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | Error 9 | 10 | 11 |

    12 | Sorry, an error occurred while processing your request. 13 |

    14 | 15 | -------------------------------------------------------------------------------- /src/Example/Views/Shared/_Fork.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | // This is an example of an external script reference. Knapsack will generate the