This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IIFE | |
(function(){ /* code */ }()); // Crockford recommends this one | |
(function(){ /* code */ })(); // But this one works just as well | |
// if you use mootools and jQuery in compat mode and mootools exposes $ and jQuery jQuery like so: | |
<script src="mootools.js"></script> | |
<script src="jquery.js"></script> | |
var jQuery = jQuery.noConflict(); | |
// then you can use legacy code which uses jQuery like so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get language | |
$lang = JFactory::getLanguage()->getLocale()[4]; | |
if ($lang === 'en') { | |
... | |
} | |
//----------------------------------------------------------------------------------- | |
// inject it into javascript global namespace (e.g. in joomla template index.php) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changes must be made here: | |
app\design\adminhtml\default\default\template\page\header.phtml | |
skin\adminhtml\default\THEME\images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create array from NodeList without modifying NodeList Prototype | |
var arr = Array.prototype.slice.call( document.querySelectorAll('div') ); | |
// extend NodeList prototype... | |
NodeList.prototype.array = function() { | |
return Array.prototype.slice.call(this); | |
}; | |
// ...and use it as chained method | |
var arr = document.querySelectorAll('div').array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var users = [ | |
{name:'johndoe', password: 'secret', displayName: 'John Doe'}, | |
{name:'elladoe', password: 'secret', displayName: 'Ella Doe'}, | |
{name:'minidoe', password: 'secret', displayName: 'Mini Doe'} | |
]; | |
var username = 'johndoe'; | |
// return current user or null if not found | |
var user = users.map(function(user){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gets the current store's details | |
$store = Mage::app()->getStore(); | |
// Gets the current store's id | |
$storeId = Mage::app()->getStore()->getStoreId(); | |
// Gets the current store's code | |
$storeCode = Mage::app()->getStore()->getCode(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a').each(function(){ | |
var $this = $(this); | |
$this.attr('href',$this.attr('href') + '?tmpl=component'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jq = document.createElement('script'); | |
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
jQuery.noConflict(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// capitalize string | |
String.prototype.cap = function(){ | |
return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){return p1+p2.toUpperCase();}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!String.prototype.trim) { | |
String.prototype.trim = function () { | |
return this.replace(/^\s+|\s+$/g, ''); | |
}; | |
} |
NewerOlder