Closed (fixed)
Project:
Code Filter
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
14 Mar 2011 at 15:30 UTC
Updated:
5 Jan 2013 at 18:50 UTC
I want codefilter to provide a more controlled interface like:
http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
The javascript is:
Drupal.behaviors.fancycode = function(context) {
$("div.codeblock", context).each(function(){
var contentwidth = $(this).contents().width();
var blockwidth = $(this).width();
if(contentwidth > blockwidth) {
$(this).hover(function() {
// 870px - 12px padding on either side - 2px for border on either side
$(this).animate({ width: "844px"}, 250, function() { $(this).css('overflow-x', 'auto'); });
}, function() {
$(this).css('overflow-x', 'hidden').animate({ width: blockwidth }, 250);
});
}
});
But not sure where to best insert the codeblock div.
Comments
Comment #1
mgiffordThe codeblock div gets spit out with multi-line objects, not single line, so that explained a piece of this.
Other relevant code from the great folks at Lullabot:
Comment #2
mgiffordOr possibly...
http://www.viget.com/inspire/simple-jquery-solution-to-a-simple-problem/
http://digwp.com/2009/07/making-an-expanding-code-box/
Comment #3
cameron tod commentedI like this. Taking a look.
Comment #4
cameron tod commentedI have got this working locally, but in Drupal 7, the default packaged themes all wrap code in codefilter blocks, so the whole thing is a bit moot.
I might still backport for D6, and I might have a look at setting this as a configurable option. When on, codefilter would disable wrapping for code blocks, and attach the JS.
Comment #5
cameron tod commentedI have added this functionality. You can see a demo of it here:
http://camerontodtest.devcloud.acquia-sites.com/node/6
There is now a configurable option on the codefilter settings, which allows you to enable Javascript expansion:
http://f.cl.ly/items/0B230C0t2a3b3b0l2G2E/Screen%20Shot%202012-12-15%20a...
Let me know if this suits, and please test it if you can!
Comment #6
cameron tod commentedComment #7
cameron tod commentedComment #8
mgiffordIt doesn't look (to me) like the expansion code is in the demo working. I'm looking at it in Firefox and the code goes way off the screen and a mouse-over does nothing.
Am I missing something? Let me know if you need a screenshot.
Great addition btw to make it configurable.
Comment #9
cameron tod commentedComment #10
cameron tod commentedI was trying to be too clever and load the JS/CSS when the text was processed. I have now moved this into the .info file, so it should work. Give it another shot.
http://camerontodtest.devcloud.acquia-sites.com/node/6
Comment #11
mgiffordIt works better, but when I first load the page it still looks wrong. It only behaves properly once there's been a mouseover.
This is in FF on a mac.
Comment #12
cameron tod commentedSo when you say it looks wrong, do you mean that the code breaks out of it's box, and after a hover, it is contained but truncated?
Comment #13
cameron tod commentedBecause if that's the case, I've just pushed a fix :)
Take a look!
Comment #14
mgiffordThat works great.. Looks good!
Comment #15
cameron tod commentedGreat! This is all committed on the dev branch. I'm gonna try and clear out the bug queue a bit more and write some tests. Once that is all done, there will be a 1.1 release, which this will be a part of.
Comment #16
cameron tod commentedTests are now added.