Skip to content

Instantly share code, notes, and snippets.

View mojaray2k's full-sized avatar

Amen Moja Ra mojaray2k

  • Miami, Fl
View GitHub Profile
@mojaray2k
mojaray2k / Bootstrap 1
Created March 6, 2013 06:15
This is a fallback Script for Bootstrap CDN
//bootstrapfallback.js
//<!-- BOOTSTRAP JS WITH LOCAL FALLBACK-->
//<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
//<script> if(typeof($.fn.modal) === 'undefined') {document.write('<script src="//www.mysite.com/js/v/bootstrap-2.1.1.js"><\/script>')}</script>
//<!-- BOOTSTRAP CDN FALLBACK CSS-->
//<script>$(document).ready(function() {
var bodyColor = $('body').css("color"); if(bodyColor != 'rgb(51, 51, 51)') {$("head").prepend("<link rel='stylesheet' href='//www.mysite.com/css/fw/bootstrap-combined-2.1.1.css' type='text/css' media='screen'>");}
@mojaray2k
mojaray2k / JavaScript 6
Created March 6, 2013 06:20
You can use this script to load a local copy of your jquery file if you cannot get it from http://code.jquery.com/jquery-latest.min.js
//jquerycdnfallback.js
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='_assets/js/jquery-latest.min.js' type='text/javascript'%3E%3C/script%3E"));
}
@mojaray2k
mojaray2k / Images 1
Created March 11, 2013 19:31
Here is a script to detect if there is a landscape or portrait img on a region of a webpage
//img-oreintation.js
$(document).ready(function () {
$('.two-column-content img').each(function () {
$(this).addClass(this.width > this.height ? 'landscape' : 'portrait');
});
});
@mojaray2k
mojaray2k / JavaScript 5
Created March 13, 2013 18:19
Add a class when the text Value of two html elements are the same. This particular example is comparing the text of the Title Tag and and List Items in an Unordered list
//textcompare.js
$('ul.main-nav li').each(function () {
var title = $('title').text();
var mainlink = $(this).text();
if (title == mainlink) {
$(this).addClass('active');
}
});
@mojaray2k
mojaray2k / reserve-a-seat.html
Last active December 14, 2015 22:29
When an element is clicked remove the selected class from all elements and add it to the one clicked. Also, set the text contents of #elementSelected to the data-seat attribute (e.g. 2A, 4D) from the selected element (this), and then show the #confirm-seat div. In the selectSeat function unbind the click event from the seat that was clicked (thi…
<header class="seats-header">
<h1>Reserve a Seat</h1>
</header>
<section id="seats">
<div class="seating-chart">
<h3>- First Class -</h3>
<ol class="first-class">
<li class="row">
@mojaray2k
mojaray2k / AJAX 3
Created March 16, 2013 05:23
This is a jQuery Ajax Template 1
var fetchingFlights = null;
function showFlights(e){
$('tabs div').hide();
$(activeDiv).show();
var flight = $(this).data('flight');
var flightClass = $(this).data('class');
if(fetchingFlights.abort){
fetchingFlights.abort();
@mojaray2k
mojaray2k / AJAX 2
Created March 16, 2013 05:36
This is jQuery Ajax Template 2
<section id="confirm">
<div class="flight-review">
<table>
<tr>
<th>Base Price:</th>
<td id="price"></td>
</tr>
<tr>
<th>Gov Taxes:</th>
<td id="fees"></td>
@mojaray2k
mojaray2k / AJAX 1
Created March 16, 2013 05:52
This is a jQuery Ajax Template 3 - This example uses jsonp
$('#login form').submit(login);
function login(e){
e.preventDefault();
$('#login h4').slideUp();
//var email = $('#login #email').val();
//var password = $('#login #password').val();
var form = $(this).serialize();
@mojaray2k
mojaray2k / HTML 1
Last active December 15, 2015 06:58
This is an example of how to change the html source order using css3's display: box; box-orient (you can either assign vertical or horizontal), and box-ordinal-group: 1, box-ordinal-group: 2; etc. You can also see a better example at http://www.jordanm.co.uk/lab/contentchoreography
/*source-order.css*/
.middle-content > .main-content {
display:box;
display:-moz-box;
display:-webkit-box;
box-orient:vertical;
-moz-box-orient:vertical;
-webkit-box-orient:vertical;
}
.middle-content > .main-content > .span4{
@mojaray2k
mojaray2k / HTACCESS 3
Last active December 15, 2015 09:29
These are the lines of code you need to enable clean url's in Drupal
#This enables the urls to be cleaned
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>