Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit f453fac1386782944f161ba3c0a0465b6b16debb Spencer Steffen committed Jun 3, 2010
Showing with 867 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +129 −0 alert.js
  3. +99 −0 jquery.autodate.js
  4. +88 −0 jquery.bubbles.js
  5. +401 −0 jquery.sliders.js
  6. +148 −0 jquery.snow.js
@@ -0,0 +1,2 @@
+.DS_Store
+
@@ -0,0 +1,129 @@
+// Copyright 2010 Citrus Media Group
+// by Spencer Steffen
+// Drop down alert, to be used globally rather than instantianiously.
+//
+;var Alert = {
+ version: "0.1.2",
+ options: {
+ overlay: true,
+ speed: 'fast'
+ },
+ overlay_styles: {
+ display: 'none',
+ position: $.browser.msie ? 'absolute' : 'fixed',
+ backgroundColor: '#000',
+ width: '100%',
+ height: '100%',
+ top: 0,
+ left: 0,
+ opacity: 0,
+ zIndex: 12000
+ },
+ init: function(id) {
+ Alert.a = $(id || '#alert').hide().css('z-index', '12500').appendTo(document.body);
+ Alert.b = Alert.a.find('div.message');
+ return Alert.conceal();
+ },
+ show: function() {
+ if (!(Alert.a || Alert.b)) Alert.init();
+ var args = $.makeArray(arguments);
+ var overlay = Alert.options.overlay;
+ if (args[0] === false) {
+ overlay = false;
+ args.shift();
+ }
+ if (overlay) Alert.setupOverlay().showOverlay();
+ if (Alert.visible) return Alert.collide(args);
+
+ if (args && 0 < args.length) Alert.update(args)
+
+ var _top = $('body').scrollTop();
+
+ if (_top !== 0) Alert.scroll();
+
+ if (Alert.a.outerHeight() < _top) Alert.a.css('top', 0).show();
+ else Alert.reveal();
+
+ Alert.visible = true;
+
+ return Alert;
+ },
+ scroll: function() {
+ $('body').animate({
+ scrollTop: 0
+ }, Alert.options.speed);
+ return Alert;
+ },
+ hide: function() {
+ if (!Alert.visible) return Alert;
+ if (!Alert.a) return Alert;
+ else Alert.a.animate({ top: -Alert.a.outerHeight() }, Alert.options.speed, Alert.hideOverlay);
+ return Alert;
+ },
+ setupOverlay: function() {
+ if (Alert.o) return Alert;
+ $(document.body).append('<div id="overlay"></div>');
+ Alert.o = $('#overlay').css(Alert.overlay_styles).hide();
+ return Alert;
+ },
+ toggleOverlay: function() {
+ if (!Alert.o) Alert.setupOverlay();
+ if (Alert.o.css('display') === 'none') Alert.showOverlay();
+ else Alert.hideOverlay();
+ return Alert;
+ },
+ showOverlay: function() {
+ if (0 < Alert.o.css('opacity')) return Alert;
+ Alert.o.show().fadeTo(Alert.options.speed, 0.80, arguments[0] || function(){return;});
+ return Alert;
+ },
+ hideOverlay: function() {
+ if (!Alert.o) return Alert;
+ Alert.o.fadeTo(Alert.options.speed, 0, function() {
+ Alert.o.remove();
+ Alert.visible = false;
+ Alert.o = null;
+ });
+ return Alert;
+ },
+ update: function(args) {
+ if (args.length) {
+ var t,m,i = 0;
+ Alert.b.empty();
+ while(args[i]) {
+ if ($.isArray(args[i])) {
+ t = args[i][0];
+ m = args[i][1];
+ } else {
+ t = i == 0 ? 'h3' : 'p';
+ m = args[i];
+ }
+ Alert.b.append('<'+t+'>'+m+'</'+t+'>');
+ i++;
+ }
+ }
+ return Alert.conceal();
+ },
+ conceal: function() {
+ if (!Alert.a) return Alert;
+ Alert.a.hide().css('top', -Alert.a.outerHeight());
+ return Alert;
+ },
+ reveal: function() {
+ if (!Alert.a) return Alert;
+ console.log('reveal');
+ Alert.a.show().animate({top: "0px" }, Alert.options.speed, function() {
+ Alert.visible = true;
+ Alert.collision = false;
+ });
+ return Alert;
+ },
+ collide: function(args) {
+ if (!Alert.visible || Alert.collision) return;
+ Alert.collision = true;
+ Alert.a.animate({top: -Alert.a.outerHeight()},Alert.options.speed, function() {
+ Alert.update(args).reveal();
+ });
+ return Alert;
+ }
+};
@@ -0,0 +1,99 @@
+// Copyright 2010 Citrus Media Group
+// jQuery Autodate
+// by Spencer Steffen
+
+// Citrus Media Group
+// spencer@citrusme.com
+
+;(function(jQuery){
+ jQuery.fn.extend({
+ autodate:function(helper,options){
+
+ var self = this;
+ var input = $(this);
+ var helper = $(helper);
+ var form = input.parents('form:first');
+ var date = null;
+ var options = $.extend($.fn.autodate.defaults, options);
+ var set = false;
+
+ if (typeof(this.hasInit) === 'undefined') {
+ init();
+ this.hasInit = true;
+ } else {
+ updateDisplay();
+ }
+
+
+ return this;
+
+
+
+ function init() {
+ input.keyup(handleKeys);
+ input.focus(handleFocus);
+ input.blur(handleBlur);
+ form.submit(handleBlur);
+ updateDisplay();
+ }
+ function parseDate() {
+ return date = Date.parse(input.val());
+ }
+ function updateDisplay() {
+ if (parseDate()) showDate();
+ else showHelp();
+ }
+ function showDate() {
+ if (!date) return showHelp();
+ input.val(date.toString(options.date_format));
+ helper.html("");
+ set = true;
+ return true;
+ }
+ function showHelp() {
+ if (date) return showDate();
+ input.val(options.input_empty);
+ helper.html("");
+ return true;
+ }
+ function showDateInHelper() {
+ helper.text(date.toString(options.date_format));
+ }
+ function invalidInput() {
+ input.addClass("error").text(options.input_invalid);
+ helper.text(options.input_invalid);
+ }
+ function handleKeys(evt) {
+ var enter = evt.keyCode === 13;
+ if (enter && date && set) enter = false;
+ if (enter) updateDisplay();
+ if (!enter && 0 < input.val().length) {
+ parseDate();
+ if (date !== null) {
+ input.removeClass("error");
+ showDateInHelper();
+ } else {
+ invalidInput();
+ }
+ }
+ return !enter;
+ }
+ function handleFocus(evt) {
+ input.val("");
+ if (date) showDateInHelper();
+ }
+ function handleBlur(evt) {
+ if (date || parseDate()) showDate();
+ else invalidInput();
+ }
+ }
+ });
+
+ $.fn.autodate.defaults = {
+ date_format: "dddd, MMMM d, yyyy h:mm:ss tt",
+ empty_string: "Type a date above",
+ input_empty: "Enter any date here..",
+ input_invalid: "Please enter a valid date."
+ }
+
+})(jQuery);
@@ -0,0 +1,88 @@
+// Copyright 2010 Citrus Media Group
+// jQuery Bubbles ( like the download popup on http://panic.com/coda )
+// by Spencer Steffen
+
+// Citrus Media Group
+// spencer@citrusme.com
+
+
+;(function($) {
+
+ var version = "0.0.1";
+
+ $.fn.extend({
+
+ bubbles: function(info, options) {
+
+ options = options || $.fn.bubbles.defaults;
+
+ var self = $(this);
+ var info = $(info).css({ display: 'none', position: 'absolute', top: 'auto', right: 'auto', bottom: 'auto', left: 'auto' }).appendTo(document.body);
+
+
+ var distance = 10;
+ var time = 250;
+ var hideDelay = 300;
+ var hideDelayTimer = null;
+ var beingShown = false;
+ var shown = false;
+
+ self.click(function(evt) {
+ evt.preventDefault();
+ return false;
+ });
+
+ $([self.get(0), info.get(0)]).mouseover(function(evt){
+ // info.show();
+ if (hideDelayTimer) clearTimeout(hideDelayTimer);
+ if (beingShown || shown) {
+ // don't trigger the animation again
+ return;
+ } else {
+ // reset position of info box
+ beingShown = true;
+
+ info.css({
+ left: evt.pageX - (info.width() * 0.33),
+ top: evt.pageY - info.height(),
+ opacity: 0,
+ display: 'block'
+ }).animate({
+ top: '-=' + distance + 'px',
+ opacity: 1
+ }, time, 'swing', function() {
+ beingShown = false;
+ shown = true;
+ });
+ }
+ return false;
+
+ });
+
+
+ $([self.get(0), info.get(0)]).mouseout(function(){
+ if (hideDelayTimer) clearTimeout(hideDelayTimer);
+ hideDelayTimer = setTimeout(function () {
+ hideDelayTimer = null;
+ info.animate({
+ top: '-=' + distance + 'px',
+ opacity: 0
+ }, time, 'swing', function () {
+ shown = false;
+ info.css('display', 'none');
+ });
+
+ }, hideDelay);
+
+ return false;
+
+ });
+
+ }
+ });
+
+ $.fn.bubbles.defaults = {
+ speed: 100
+ }
+
+})(jQuery);
Oops, something went wrong.

0 comments on commit f453fac

Please sign in to comment.