Skip to content

Instantly share code, notes, and snippets.

View samnajian's full-sized avatar
🏠
Working from home

Sam Najian samnajian

🏠
Working from home
View GitHub Profile
@samnajian
samnajian / change-svg-fill-color.js
Created September 27, 2017 15:17
Trick to change svg fill color
document.addEventListener('DOMContentLoaded', function() {
/**
* Refrence to object element that has svg as data attribute
**/
const obj = document.querySelector('object');
const svg = obj.contentDocument.querySelector("svg");
svg.style.fill = "red" // change fill color to red
}, false);
@samnajian
samnajian / flatten_array.js
Last active July 18, 2016 08:09
Flattern array in JS
function flatten_array( arr ){
/**
* Checks if _arr is an array
* @param Array|Mixed _arr variable to check
* @return Bool whether _arr is an array
*/
const is_array = ( _arr ) => {
return typeof _arr === "object" && typeof _arr.concat === "function";
};
'post_image_variants' => '[{\"vid\":\"variant-1415709668089-1002\",\"label\":\"Full Center\",\"group\":{\"margin_left\":\"0\",\"margin_right\":\"0\",\"col\":\"18\",\"row\":\"54\",\"left\":\"0\",\"float\":\"none\",\"height\":\"270\",\"width_cls\":\"c18\",\"left_cls\":\"ml0\",\"clear_cls\":\"\"},\"image\":{\"order\":\"0\",\"col\":\"24\",\"top\":\"0\",\"left\":\"0\",\"row\":\"40\",\"clear\":\"true\",\"height\":\"200\",\"width_cls\":\"c24\",\"left_cls\":\"ml0\",\"clear_cls\":\"clr\",\"top_cls\":\"mt0\"},\"caption\":{\"show\":\"1\",\"order\":\"1\",\"col\":\"24\",\"top\":\"0\",\"left\":\"0\",\"row\":\"10\",\"clear\":\"true\",\"height\":\"50\",\"width_cls\":\"c24\",\"left_cls\":\"ml0\",\"clear_cls\":\"clr\",\"top_cls\":\"mt0\"}},{\"vid\":\"variant-1415709681741-1955\",\"label\":\"Full Left\",\"group\":{\"margin_left\":\"-3\",\"margin_right\":\"0\",\"col\":\"18\",\"row\":\"54\",\"left\":\"0\",\"float\":\"none\",\"height\":\"270\",\"width_cls\":\"c21\",\"left_cls\":\"ml0\",\"clear_cls\":\"\"},\"image\":{\"order\":\"0
/*global ugalleries */
/* @ TODO: need to add [+] button and make sure it triggers the appropriate event..
//Adding [+] control
var $upfrontObjectContent = this.$el.find('.upfront-object-content');
if(this.$el.find('a.add-gallery-item').length < 1) {
$('<b class="upfront-entity_meta add_item upfront-ui"><a href="#" class="upfront-icon-button a.add-gallery-item add-item"></a></b>').insertBefore($upfrontObjectContent);
}
*/
<?php
$header = upfront_create_region(
array(
"name" => "header",
"title" => "Header",
"type" => "wide",
"scope" => "local",
"position" => 1,
"allow_sidebar" => true
),
<?php
$header = upfront_create_region(
array(
"name" => "header",
"title" => "Header",
"type" => "wide",
"scope" => "local"
),
array(
"row" => 24,
<?php $typography = '{}';
$layout_style = '';
$theme_fonts = '';
$theme_colors = '';
$layout_properties = '[{\"name\":\"layout_style\",\"value\":\"#usearch #usearch-archive-search .upfront-object-content{\\n width:630px;\\n}\\ninput.search-field{\\n width:530px;\\n height:50px;\\n float:left;\\n padding:0;\\n border:none;\\n line-height:50px;\\n padding-left:22px;\\n}\\nbutton.search-button{\\n float:left;\\n border:none;\\n height:50px;\\n width:50px;\\n width:;\\n text-indent:9999px;\\n overflow:hidden;\\n\\n}\"}]';
<?php $typography = '{}';
$layout_style = '#usearch #usearch-archive-search .upfront-object-content{
width:630px;
}
input.search-field{
width:530px;
height:50px;
float:left;
padding:0;
border:none;
<?php
include_once get_template_directory() . '/library/class_upfront_debug.php';
include_once get_template_directory() . '/library/class_upfront_server.php';
include_once get_template_directory() . '/library/class_upfront_theme.php';
class Uf_fixer extends Upfront_ChildTheme {
public function initialize() {
$this->add_actions_filters();
$this->populate_pages();
@samnajian
samnajian / javascript_resources.md
Created December 18, 2013 21:50 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage