Skip to content

Instantly share code, notes, and snippets.

View naepalm's full-sized avatar

Janae Cram naepalm

View GitHub Profile
@naepalm
naepalm / Editors\Base.cshtml
Last active October 30, 2017 20:20
Grid view & controls for Skybrud's strongly typed models with Responsive BP
@model GridControl
@using Grid.Web
@using Skybrud.Umbraco.GridData
@try
{
<text>@Html.Partial(Model.EditorView(), Model)</text>
}
catch (Exception ex) {
<pre>@ex.ToString()</pre>
@naepalm
naepalm / Helpers.js
Last active August 3, 2017 22:46
Helper functions for react, such as price currency formatting.
var Helpers = {
/**
* @function formatMoney
* @param {number} n - The number to be formatted
* @param {string} d - The character to be used for the decimal. Defaults to ".".
* @param {string} t - the character to be used for the thousands separator. Defaults to ",".
* @param {int} c - the number of decimal places. Defaults to 2.
* @returns {string}
* @description Formats a number to a price
*/
@naepalm
naepalm / ExampleCode.cshtml
Last active August 3, 2017 16:35
The handy CheckboxListFor Html extension.
@using(Html.BeginUmbracoForm<ExampleSurfaceController>("SubmitForm", FormMethod.Post))
{
@Html.CheckBoxListFor(x => x.CheckboxListField, Model.CheckboxListSelectItems)
<button type="submit">Submit</button>
}
@naepalm
naepalm / GridExtensions.cs
Last active July 20, 2017 15:48
Grid extensions for use with Ditto, Skybrud, DocType Grid Editor, and the DocType Grid Editor Reusable Content package
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Our.Umbraco.Ditto;
using Offroadcode.Web.Models.Widgets;
using Skybrud.Umbraco.GridData;
using Skybrud.Umbraco.GridData.Values;
using Umbraco.Core.Models;
using Umbraco.Web;
@naepalm
naepalm / DocTypeGridEditorReusableContentExample.cshtml
Created June 8, 2017 20:19
An example for how a DocType Grid Editor partial view should look with the DTGE: Reusable Content Extension
@inherits UmbracoTemplatePage
@{
// Set a variable to use the default content if no linked content has been selected
var content = Model.Content;
// Check to see if there's a linked page value
if(Model.Content.HasProperty("dtgeLinkedId") && Model.Content.HasValue("dtgeLinkedId"))
{
// Run the linked page value through Umbraco.TypedContent() to get the IPublishedContent page
var dtgePage = Umbraco.TypedContent(Model.Content.GetPropertyValue("dtgeLinkedId"));
@naepalm
naepalm / ZoomAreaCropperView.cshtml
Last active May 26, 2017 16:58
A simple example of how to use the Zoom Area Cropper in a view.
@inherits UmbracoTemplatePage
@using ZoomAreaCropper.Models
@{
Layout = null;
}
@if (Model.Content.HasValue("photo"))
{
var photo = Model.Content.GetPropertyValue<ZoomAreaCropper>("photo");
if (photo.HasMedia)

Skrift headquarters resides in Bellingham, WA, at whatever restaurant or coffee house of choice suits Erica, Janae, and Kyle for their weekly meetings. At it's core, the magazine was contrived to bring the global Umbraco community together and find a localized place to promote uWestFest and other festivals around the world. Having worked together for seven years, each member of the team brings their own unique skills to Skrift's management. As a freelance UX designer, Erica is in charge of design, user testing, and statistics, Janae specializes in the C#, HTML, and CSS of the site as their resident code junkie, and Kyle puts his skills to use both as their Javascript guru and Editor In Chief (he's an award winning journalist and cartoonist, you know!*). Passionate about the web and Umbraco with skills developed working together in an agency bef

@naepalm
naepalm / TextOverImagePartial.cshtml
Created January 12, 2017 22:10
Files to easily render the Text Over Image Editor on the front.
@model TextOverImage.Models.ImageWithText
@{
// Use this code to render this partial in your template. Replace "banner" with whatever your property name is
// Make sure to include @using TextOverImage.Models at the top of your template
//@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
//{
// @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
//}
@naepalm
naepalm / TastyCookies.js
Last active August 23, 2016 21:06
Kyle's handy-dandy cookie scripts.
/**
* @class Cookie
* @description Helper functions for adding and deleting cookies.
*/
var Cookie = {
/**
* @method delete
* @param {string} cookieName - The name of the cookie to delete.
* @description Deletes the indicated cookie.
*/
@naepalm
naepalm / RazorServerDirectoryListingHelper.cshtml
Created August 17, 2016 16:45
Displays a list of directories and files on a server, for those nasty moments when you don't have access and are looking for something.
@helper RenderFolders(string dirPath, bool displaySubDirs = false)
{
try
{
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
<h4>@string.Format("Directory: {0}", dirPath.Substring(dirPath.LastIndexOf("\\") + 1))</h4>
<p>@(string.Format("{0} directories found.", dirs.Count))</p>
<ul>
@foreach (var dir in dirs)