Revision: 66911
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 20, 2014 04:15 by rickygri
Initial Code
$(function() { /*** Template ***/ /* Object.create shiv */ if(typeof Object.create !== "function") { Object.create = function (o) { function F() {} F.prototype = o; return new F(); }; } var myObject = { option1: null, option2: null, option3: 0, /* * All styles will be added to the DOM, so go nuts. * 3D transforms are added to transitions */ styles: { "slides": '#feature-images ul li, #feature-caption ul li { -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); }', }, init: function() { this.reset(); for (var prop in this.styles) { if (this.styles.hasOwnProperty(prop)) { // Append all properties in styles // object as CSS node this.appendStyle(this.styles[prop]); } } }, /* * This function adds styles to the DOM * as a CSS node */ appendStyle: function(style) { var css = document.createElement('style'); css.type = 'text/css'; if (css.styleSheet) css.styleSheet.cssText = style; else css.appendChild(document.createTextNode(style)); document.getElementsByTagName("head")[0].appendChild(css); }, reset: function() { } }; var xyz = Object.create(myObject); xyz.init(); // feature.setActive(2); });
Initial URL
http://www.adobe.com/devnet/html5/articles/javascript-object-creation.html
Initial Description
A template for a javascript object with a object.create shiv to condense into object prototypes
Initial Title
Javascript object template
Initial Tags
javascript, object
Initial Language
JavaScript