Created
May 18, 2012 23:03
-
-
Save paceaux/2728020 to your computer and use it in GitHub Desktop.
Konami Contenteditable plugin
This file contains hidden or 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.kedit = function() { | |
var konami_keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; | |
var konami_index = 0; | |
this.keydown(function(e){ | |
if(e.keyCode === konami_keys[konami_index++]){ | |
if(konami_index === konami_keys.length){ | |
$(document).unbind('keydown', arguments.callee); | |
$('article, aside, header, footer, p, li, span').dblclick(function(e){ | |
var $this = $(this); | |
$this.attr("contenteditable", true).css({'outline':'2px dotted #333'}); | |
$this.focusout(function(e){ | |
$this.attr("contenteditable", false).css({'outline':'none'}); | |
}); | |
}); | |
} | |
}else{ | |
konami_index = 0; | |
} | |
}); | |
}; | |
})( jQuery ); | |
$(document).kedit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a very basic jquery plugin that uses the Konami code to "unlock" your ability to edit any content on the page. After the Konami code, you can double click most elements to edit them. The Konami code, BTW, is up up down down left right left right b a