Skip to content

Instantly share code, notes, and snippets.

@orip
orip / jQuery.validate.requiredIfVisible.js
Created June 28, 2010 16:12
make a field required only if it's visible
// jQuery.validate.requiredIfVisible.js
// Copyright (c) 2010 Ori Peleg, http://orip.org, distributed under the MIT license
(function($) {
$.validator.addMethod(
"requiredIfVisible",
function(value, element, params) {
function isVisible(e) {
// the element and all of its parents must be :visible
// inspiration: http://remysharp.com/2008/10/17/jquery-really-visible/
return e.is(":visible") && e.parents(":not(:visible)").length == 0;
jq('div').live('pagebeforeshow', function(event, ui){
var page = jq(event.target);
var url = page.attr('data-refresh');
if(url){
var ajax = {};
ajax.url = url;
ajax.type = 'GET';
// force certain pages to be refreshed every time. mark such pages with
// 'data-cache="never"'
//
jQuery('div').live('pagehide', function(event, ui){
var page = jQuery(event.target);
if(page.attr('data-cache') == 'never'){
page.remove();
};
});
@MrUzu
MrUzu / mobile-meta-html5.html
Created June 24, 2011 14:29
WebApp meta for Icons and Startup screens
<!-- HTML5 DOCTYPE, IMPORTANT -->
<!DOCTYPE html>
<html dir="ltr" lang="en-EN">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<!-- VIEWPORT, AVOID BROWSER NAV BAR, AND HANDHELD DECLARATIONS -->
@battlehorse
battlehorse / multi_dashboard.html
Created September 26, 2011 14:28
A Google Charts dashboard setup where multiple datatables are used to power a single 'logical' dashboard.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['controls']});
@mgmartel
mgmartel / bp-sort-members-by-last-name.php
Last active December 11, 2023 03:23
Sort BuddyPress users by last name in the members directory. Updated for BP 1.7.
<?php
// Sort BuddyPress users by last name
//
// Use this Gist to sort members alphabetically by last name in the
// members directory. Follow the instructions below and drop the code
// in your functions.php or your functions plugin.
//
// Updated to work with BP 1.7. See earlier revisions of this gist for
// earlier versions of BP.