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
function ellipsis(string, length) { | |
return string.length > length ? (string.substr(0, length - 3) + '...') : string; | |
} |
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
function calculate_savings(cost, sale) { | |
cost *= 100; | |
sale *= 100; | |
return ((cost - sale) / 100).toFixed(2); | |
} |
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 $phone1 = $('input#phone1'); | |
var $phone2 = $('input#phone2'); | |
var $phone3 = $('input#phone3'); | |
$phone1.change(function() { | |
if ($phone1.val().length == 3) // if they've typed 3 characters | |
$phone2.focus(); // select the next field | |
}); | |
$phone2.change(function() { |
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
(function($) { | |
$.fn.defaultText = function(settings) { | |
var defaults = { 'color' : '#ccc', | |
'default_text' : 'Default Text' | |
}; | |
if (settings) $.extend(defaults, settings); | |
this.each(function() { | |
$this = $(this); |
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 (typeof console == 'undefined' && typeof console.log == 'undefined') console = { log : function(message) { alert(message) } } |
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 fix_has_layout = function(container) { | |
var elements = $('*', container || document); | |
elements.each(function(element) { | |
if (element.css('display') == 'block') | |
element.css('zoom', 1); | |
}); | |
} | |
$(function() { |
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
(function($) { // this ensures that the plugin doesn't conflict with other code and is recommended for jQuery plugins: http://docs.jquery.com/Plugins/Authoring | |
$.fn.slideshow = function(settings) { // declare the plugin function accepting a single argument 'settings' to override any of the defaults | |
var config = { 'delay' : 4000, 'active_class' : 'active', 'navigation_selector' : '#navigation a' }; // some defaults which can be overridden by 'settings' above | |
if (settings) $.extend(config, settings); // merge the defaults with the settings passed in above | |
this.each(function() { // for each jQuery object matching the selector (e.g. $('ul#some-list > li').each(function() {}); would call the function inside passing in each element as 'this') | |
var $this = $(this); // to prevent recreating a jQuery object every time I need $(this) | |
$this.css('position', 'relative'); // set the slide wrapper as relative |
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
(function($) { | |
$.fn.scroller = function(settings) { | |
var config = { 'delay' : 4000, 'prev_selector' : '#prev', 'next_selector' : '#next', 'should_loop' : false }; | |
if (settings) $.extend(config, settings); | |
this.each(function() { | |
var $this = $(this); | |
var current = 0; |
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 head = document.getElementsByTagName('head')[0]; | |
var meta = document.createElement('meta'); | |
meta.setAttribute('http-equiv', 'X-UA-Compatible'); | |
meta.setAttribute('content', 'IE=EmulateIE7'); | |
head.appendChild(meta); |
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 json_escape = function(value) { | |
if (value.replace) | |
return value.replace(/\//g, '\\/') | |
else | |
return value | |
} | |
var json_to_html = function(json, level) { | |
level = level || 0 | |
OlderNewer