Skip to main content
Topic: may we... (Read 8120 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

may we...

...have bigger code blocks or something like this? O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: may we...

Reply #1

I thought you could drag the code blocks  to a larger size?

I don't have any objection to this, it looks like you open the code block in a popup window when clicked? 

Maybe an icon on the block that when clicked expanded the block .. that way you could tie the event to that specific block and avoid doing the search the entire page for objects with a class of xyz and then add events to all those objects parents.parents (since most often they will not exist anyway)

Re: may we...

Reply #2

I don't see any handle to resize the code blocks...is that something lost at some point?

 emanuele iz not good with javascript...
I added an "expand" link next to "select" and then used jQuery just for fun. :P
Bugs creator.
Features destroyer.
Template killer.

Re: may we...

Reply #3

Quote from: emanuele – I don't see any handle to resize the code blocks...is that something lost at some point?
Don't know  O:-)  ... lets add a big code block so we can see what it does !
Code: [Select]
$(document).ready(function() {
// menu drop downs
$('ul.dropmenu, ul.quickbuttons').superfish({delay : 600, speed: 200, sensitivity : 8, interval : 50, timeout : 1});

// tooltips
$('.preview').SiteTooltip();

// find all nested linked images and turn off the border
$('a.bbc_link img.bbc_img').parent().css('border', '0');

$expand_link = $('.codeexpand');
if ($expand_link.length != 0)
{
$expand_link.click(function () {
var text = $(this).parent().parent().find('.bbc_code');

contentOverlayDiv(text.html());
});
}

});

function contentOverlayDiv(box_content, sHeader, sIcon)
{
// Set up our div details
var sAjax_indicator = '<div class="centertext"><img src="' + smf_images_url + '/loading.gif" ></div>';
var sIcon = smf_images_url + '/' + (typeof(sIcon) == 'string' ? sIcon : 'helptopics.png');
var sHeader = typeof(sHeader) == 'string' ? sHeader : code_popup_heading_text;

// Create the div that we are going to load
var oContainer = new smc_Popup({heading: sHeader, content: sAjax_indicator, icon: sIcon, css: {position: '', margin: '5%', width: '90%', height: '90%'}});

var oPopup_body = $('#' + oContainer.popup_id).find('.popup_content');

oPopup_body.html(box_content);
oPopup_body.css({"max-height": '90%'});
}

// The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves.
function smf_codeBoxFix()
{
var codeFix = document.getElementsByTagName('code');
for (var i = codeFix.length - 1; i >= 0; i--)
{
if (is_webkit && codeFix[i].offsetHeight < 20)
codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + 'px';

else if (is_ff && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
codeFix[i].style.overflow = 'scroll';

else if ('currentStyle' in codeFix[i] && codeFix[i].currentStyle.overflow == 'auto' && (codeFix[i].currentStyle.height == '' || codeFix[i].currentStyle.height == 'auto') && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0))
codeFix[i].style.height = (codeFix[i].offsetHeight + 24) + 'px';
}
}

// Add a fix for code stuff?
if (is_ie || is_webkit || is_ff)
addLoadEvent(smf_codeBoxFix);

// Toggles the element height and width styles of an image.
function smc_toggleImageDimensions()
{
var oImages = document.getElementsByTagName('IMG');
for (oImage in oImages)
{
// Not a resized image? Skip it.
if (oImages[oImage].className == undefined || oImages[oImage].className.indexOf('bbc_img resized') == -1)
continue;

oImages[oImage].style.cursor = 'pointer';
oImages[oImage].onclick = function() {
this.style.width = this.style.height = this.style.width == 'auto' ? null : 'auto';
};
}
}

// Add a load event for the function above.
addLoadEvent(smc_toggleImageDimensions);

// Adds a button to a certain button strip.
function smf_addButton(sButtonStripId, bUseImage, oOptions)
{
var oButtonStrip = document.getElementById(sButtonStripId);
var aItems = oButtonStrip.getElementsByTagName('span');

// Remove the 'last' class from the last item.
if (aItems.length > 0)
{
var oLastSpan = aItems[aItems.length - 1];
oLastSpan.className = oLastSpan.className.replace(/\s*last/, 'position_holder');
}

// Add the button.
var oButtonStripList = oButtonStrip.getElementsByTagName('ul')[0];
var oNewButton = document.createElement('li');
if ('sId' in oOptions)
oNewButton.id = oOptions.sId
setInnerHTML(oNewButton, '<a href="' + oOptions.sUrl + '" ' + ('sCustom' in oOptions ? oOptions.sCustom : '') + '><span class="last"' + ('sId' in oOptions ? ' id="' + oOptions.sId + '_text"': '') + '>' + oOptions.sText + '</span></a>');

oButtonStripList.appendChild(oNewButton);
}

In FF it has the little handle in the lower right of the code box ...

Re: may we...

Reply #4

Ahh...it's something for the elite... (FF and webkit)
Bugs creator.
Features destroyer.
Template killer.

Re: may we...

Reply #5

Not showing in Opera or other?

Re: may we...

Reply #6

Yep.
Not even in IE.
Bugs creator.
Features destroyer.
Template killer.

Re: may we...

Reply #7

Yeah those idiots don't support resize. However, there is an Opera plugin for it.

https://addons.opera.com/en/extensions/details/textarea-resizer/

Unfortunately it still isn't smart enough to work on divs. That's what you get for using antiquated/dumb browsers. Serves you right. Damned if I'm going for a load of bloat just to deal with browsers that are as dumb as IE. :P

Better idea: grab the code from that Opera plugin and add support for divs and a few other tags, then liberate the minions of Opera by posting it on their plugins site.

ETA: Oh and personally, I'd be dumping the resize code from SCE and relying on css resize there too. I don't want to build software for 1983.
Last Edit: December 27, 2012, 02:39:37 pm by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: may we...

Reply #8

Hey just looking through the code for that Opera plugin. Apache license. Repo is here: http://code.google.com/p/textarea-resizer/source/browse/#svn%2Ftrunk

It looks like it would be extremely easy to add support for divs and a few other handy elements. Just a matter of sticking them in the existing arrays.

ETA: Basic guidelines n stuff here: http://dev.opera.com/articles/view/opera-extension-code-examples/

The author might even add divs himself if someone asks nicely.
Last Edit: December 27, 2012, 03:36:56 pm by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P