From a5ec8f618e7b9f51e511840a0168b7996dea3b7d Mon Sep 17 00:00:00 2001 From: Dan Croak Date: Tue, 7 Jul 2009 20:14:17 -0400 Subject: [PATCH] added under construction (mile marker for jQuery) plugin --- app/views/layouts/application.html.erb | 1 + public/javascripts/jquery.hotkeys.js | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/javascripts/jquery.under_construction.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/stylesheets/under_construction.css | 18 ++++++++++++++++++ vendor/plugins/under_construction/readme.textile | 26 ++++++++++++++++++++++++++ vendor/plugins/under_construction/script/jquery.under_construction.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vendor/plugins/under_construction/stylesheets/under_construction.css | 18 ++++++++++++++++++ 7 files changed, 439 insertions(+), 0 deletions(-) create mode 100644 public/javascripts/jquery.hotkeys.js create mode 100644 public/javascripts/jquery.under_construction.js create mode 100644 public/stylesheets/under_construction.css create mode 100644 vendor/plugins/under_construction/readme.textile create mode 100644 vendor/plugins/under_construction/script/jquery.under_construction.js create mode 100644 vendor/plugins/under_construction/stylesheets/under_construction.css diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d698b1b..9ced7fb 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,6 +5,7 @@ CHANGEME <%= stylesheet_link_tag 'screen', :media => 'all', :cache => true %> + <%# stylesheet_link_tag 'under_construction' %>
diff --git a/public/javascripts/jquery.hotkeys.js b/public/javascripts/jquery.hotkeys.js new file mode 100644 index 0000000..9a8f2de --- /dev/null +++ b/public/javascripts/jquery.hotkeys.js @@ -0,0 +1,244 @@ +/* +(c) Copyrights 2007 - 2008 + +Original idea by by Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ + +jQuery Plugin by Tzury Bar Yochay +tzury.by@gmail.com +http://evalinux.wordpress.com +http://facebook.com/profile.php?id=513676303 + +Project's sites: +http://code.google.com/p/js-hotkeys/ +http://github.com/tzuryby/hotkeys/tree/master + +License: same as jQuery license. + +USAGE: + // simple usage + $(document).bind('keydown', 'Ctrl+c', function(){ alert('copy anyone?');}); + + // special options such as disableInIput + $(document).bind('keydown', {combi:'Ctrl+x', disableInInput: true} , function() {}); + +Note: + This plugin wraps the following jQuery methods: $.fn.find, $.fn.bind and $.fn.unbind +*/ + +(function (jQuery){ + // keep reference to the original $.fn.bind, $.fn.unbind and $.fn.find + jQuery.fn.__bind__ = jQuery.fn.bind; + jQuery.fn.__unbind__ = jQuery.fn.unbind; + jQuery.fn.__find__ = jQuery.fn.find; + + var hotkeys = { + version: '0.7.9', + override: /keypress|keydown|keyup/g, + triggersMap: {}, + + specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', + 20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del', + 35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', + 109: '-', + 112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', + 120:'f9', 121:'f10', 122:'f11', 123:'f12', 191: '/'}, + + shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", + "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<", + ".":">", "/":"?", "\\":"|" }, + + newTrigger: function (type, combi, callback) { + // i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}} + var result = {}; + result[type] = {}; + result[type][combi] = {cb: callback, disableInInput: false}; + return result; + } + }; + // add firefox num pad char codes + //if (jQuery.browser.mozilla){ + // add num pad char codes + hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99: + '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9', 106: '*', + 107: '+', 109: '-', 110: '.', 111 : '/' + }); + //} + + // a wrapper around of $.fn.find + // see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d + jQuery.fn.find = function( selector ) { + this.query = selector; + return jQuery.fn.__find__.apply(this, arguments); + }; + + jQuery.fn.unbind = function (type, combi, fn){ + if (jQuery.isFunction(combi)){ + fn = combi; + combi = null; + } + if (combi && typeof combi === 'string'){ + var selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString(); + var hkTypes = type.split(' '); + for (var x=0; x"); + + //set the height + var height = jQuery(this).outerHeight(); + var width = jQuery(this).outerWidth(); + + jQuery(overlay_element).height(height); + jQuery(overlay_element).width(width); + + //set the position + var pos = jQuery(this).position(); + + jQuery(overlay_element).css("top", pos.top); + jQuery(overlay_element).css("left", pos.left); + + //add the class that sets opacity and background color + jQuery(overlay_element).addClass("overlay_for_pending"); + + //todo: replace this with a delimited class to indicate what milestone it is + jQuery(overlay_element).html(""); + + //insert after the element in question + jQuery("body").append(overlay_element); + }); + }, + + toggleDisplayOfPendingElements : function() { + if(jQuery(".pending").hasClass("not_visible")) { + this.showPendingElements(); + } + else { + this.hidePendingElements(); + } + }, + + toggleOverlayOfPendingElements : function() { + if(jQuery(".overlay_for_pending").length > 0) { + this.hideOverlayOfPendingElements(); + } + else { + this.overlayPendingElements(); + } + }, + + +} + diff --git a/public/stylesheets/under_construction.css b/public/stylesheets/under_construction.css new file mode 100644 index 0000000..43a6d71 --- /dev/null +++ b/public/stylesheets/under_construction.css @@ -0,0 +1,18 @@ +.not_visible { + display: none !important; +} + +.not_visible.whiteout { + visibility: hidden !important; + display: block !important; +} + +.overlay_for_pending { + opacity: 0.7; + filter:alpha(opacity=70); + background-color: #000; + background-image: none; + position: absolute; + z-index: 999; +} + diff --git a/vendor/plugins/under_construction/readme.textile b/vendor/plugins/under_construction/readme.textile new file mode 100644 index 0000000..17c59ac --- /dev/null +++ b/vendor/plugins/under_construction/readme.textile @@ -0,0 +1,26 @@ +h1. Under Construction + +Show what's in development on your web applications. Inspired by Thoughtbot's MileMarker + +h2. Requirements + +* JQuery + +h2. Example Usage + +"View the demo":http://dpickett.github.com/under_construction/demo.html + +h2. How to Use + +Put the script and stylesheets in your project. Give elements that aren't built yet the class of "pending". You can toggle an overlay or display of these elements using toggleOverlayOfPendingElements() and toggleDisplayOfPendingElements() respectively. + +Works great with the "hotkeys plugin":http://code.google.com/p/js-hotkeys/ + +h2. MIT License + +h2. TODO + +* Mechanism on the overlay to show when/or in what iteration the feature will be unlocked +* Improved Documentation +* QUnit Testing +* Browser Testing diff --git a/vendor/plugins/under_construction/script/jquery.under_construction.js b/vendor/plugins/under_construction/script/jquery.under_construction.js new file mode 100644 index 0000000..3ad79ca --- /dev/null +++ b/vendor/plugins/under_construction/script/jquery.under_construction.js @@ -0,0 +1,66 @@ +jQuery.under_construction = { + hidePendingElements : function() { + jQuery(".pending").each(function(i){ + jQuery(this).addClass("not_visible"); + }); + }, + + showPendingElements : function() { + jQuery(".pending").removeClass("not_visible"); + }, + + hideOverlayOfPendingElements : function() { + jQuery(".overlay_for_pending").remove(); + }, + + overlayPendingElements : function() { + jQuery(".pending").each(function(i){ + + //clone the element so that we can overlay it + var overlay_element = jQuery("
"); + + //set the height + var height = jQuery(this).outerHeight(); + var width = jQuery(this).outerWidth(); + + jQuery(overlay_element).height(height); + jQuery(overlay_element).width(width); + + //set the position + var pos = jQuery(this).position(); + + jQuery(overlay_element).css("top", pos.top); + jQuery(overlay_element).css("left", pos.left); + + //add the class that sets opacity and background color + jQuery(overlay_element).addClass("overlay_for_pending"); + + //todo: replace this with a delimited class to indicate what milestone it is + jQuery(overlay_element).html(""); + + //insert after the element in question + jQuery("body").append(overlay_element); + }); + }, + + toggleDisplayOfPendingElements : function() { + if(jQuery(".pending").hasClass("not_visible")) { + this.showPendingElements(); + } + else { + this.hidePendingElements(); + } + }, + + toggleOverlayOfPendingElements : function() { + if(jQuery(".overlay_for_pending").length > 0) { + this.hideOverlayOfPendingElements(); + } + else { + this.overlayPendingElements(); + } + }, + + +} + diff --git a/vendor/plugins/under_construction/stylesheets/under_construction.css b/vendor/plugins/under_construction/stylesheets/under_construction.css new file mode 100644 index 0000000..43a6d71 --- /dev/null +++ b/vendor/plugins/under_construction/stylesheets/under_construction.css @@ -0,0 +1,18 @@ +.not_visible { + display: none !important; +} + +.not_visible.whiteout { + visibility: hidden !important; + display: block !important; +} + +.overlay_for_pending { + opacity: 0.7; + filter:alpha(opacity=70); + background-color: #000; + background-image: none; + position: absolute; + z-index: 999; +} + -- libgit2 0.21.2