Skip to content

Instantly share code, notes, and snippets.

View paceaux's full-sized avatar
🌐
Obsessing with languagey things

Paceaux paceaux

🌐
Obsessing with languagey things
View GitHub Profile
@paceaux
paceaux / dabblet.css
Last active August 29, 2015 14:19
property order
/**
* property order
*/
html{
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
}
p {
background: rgba(100,100,100,.2);
@paceaux
paceaux / testvh.js
Created February 19, 2015 21:26
Test if a browser supports VH. Based on the idea from vminpoly: https://github.com/saabi/vminpoly/blob/master/vminpoly.js
supportsVh = function () {
var detector = document.createElement('div'),
winHeight = parseInt(window.innerHeight / 10, 10),
testHeight;
detector.style.height = '10vh'; // set an arbitrarily chosen height
document.getElementsByTagName('body')[0].appendChild(detector); // add the element
testHeight = parseInt(window.getComputedStyle(detector, null).height, 10); //get the computed style of the element
document.getElementsByTagName('body')[0].removeChild(detector); // now remove the element
@paceaux
paceaux / stateSelect
Created February 8, 2015 17:44
select Box with all 50 states.
<select class="fieldset__field__select " id="js-state" name="state" title="Select your state" >
<option>State</option>
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
@paceaux
paceaux / StylusFlexFoundation
Created February 5, 2015 04:19
Stylus Flexbox Foundation
[class*="flex"]
display:flex
&[class*="col"]
flex-direction: column;
&[class*="row"]
flex-direction: row;
for prop in space-between space-around center flex-start flex-end
&[class*=\"justify--{prop}\"]
@paceaux
paceaux / uiFrame.js
Created January 5, 2015 18:16
return a Tridion view frame as an object
var uiFrame = function (viewName) {
var frameIndex = 0, tridionView;
while (windowFrame = window.top.frames[frameIndex++])
{
if ( (tridionView = windowFrame.$display && windowFrame.$display.getView() ) && tridionView.getId() === viewName)
{
return tridionView;
}
}
console.log(tridionView);
@paceaux
paceaux / removeClassByPartialName.js
Last active October 28, 2015 20:43
Use this if you want to remove a class name from an element, but you don't know the full class name (ie, you only have a partial class name)
DOMTokenList.prototype.removeByPartial = function (className) {
for (var i = 0; i< this.length; i++) {
if (this[i].indexOf(className) !== -1) {
this.remove(this[i]);
}
}
};
@paceaux
paceaux / dabblet.css
Created December 31, 2014 17:40
Flexboxing lists
/**
* Flexboxing lists
*/
ul{
display:flex;
flex-direction: column;
margin: 0;
padding: 0;
height: 100vh;
@paceaux
paceaux / frameMediator.js
Created December 31, 2014 04:21
A mediator between you, the console, Anguilla, and Tridion
var AnguillaMediator = function() {
this._getAnguillaFrame = function() {
if (navHappy.isNavigating) {
return window.top.frames[1];
} else {
return window.top;
}
};
this.aFrame = this._getAnguillaFrame();
String.prototype.replaceAt = function () {
var rlen = arguments[2] == null ? 1 : arguments[2];
return this.substring(0, arguments[0]) + arguments[1] + this.substring(arguments[0] + rlen);
};
var currentItem = SDL.Client.UI.ApplicationHost.ViewModels.Navigation.currentNavigationItem();
var navHappy = {
init: function () {
this.newSrc = this.getNewSrc();
},
getCurrentItem: function () {
@paceaux
paceaux / form
Last active August 29, 2015 14:11
This makes a safe Form Object with information about all of the forms in a web page. Protects the JS from the Data
//wrap it all in an anonymous function
//This keeps our code safe from other JavaScript,and we don't polute the global namespace
(function() {
//create the encapsulating variable
var taForm;
//add a namespacing function so that we can inject modules to it
taForm = {
namespace: function(ns_string) {
var parts = ns_string.split('.'),