To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Ticket #579 (closed task: fixed)

Opened 17 months ago

Last modified 16 months ago

Document the aUI function

Reported by: tboutell Owned by: johnnyoffline
Priority: major Milestone: 1.5
Component: apostrophePlugin Version: trunk
Keywords: js, 1.5rc Cc: geoffd, agilbert, wjohnald, tboutell, rickybanister, johnnyoffline, jake, dordille,
Symfony version: 1.4

Description

Please write a JS comment above the aUI function explaining exactly what it does and what the target is. This could help us move toward refactoring it.

Everything in aUI.js should probably migrate into a.js and be methods of the apostrophe object.

Change History

Changed 17 months ago by johnnyoffline

Most useful bits of aUI have been pulled out, repurposed, or migrated to a.js

There's not a whole lot left, it's mostly strange odds and ends we need for styling buttons, there are JS comments inline

Here is what's left:

function aUI(target)
{
	// Grab Target if Passed Through
	if (typeof(target) == 'undefined') // If Not Set
	{
		target = '';
	}
	else if (typeof(target) == 'object') // If jQuery object get id
	{
		target = "#"+ target.attr('id') +" ";
	}
	else // probably a string
	{
		target = target+" ";
	}

	var aBtns = $(target+' .a-btn, ' + target + ' .a-submit, ' + target + ' .a-cancel');
	aBtns.each(function() {
		var aBtn = $(this);

		// Setup Icons
		if (aBtn.is('a') && aBtn.hasClass('icon') && !aBtn.children('.icon').length) 
		{
			aBtn.prepend('<span class="icon"></span>');						
		};
		
		// Setup Flagging Buttons
		if(aBtn.hasClass('flag'))
		{
			if (!aBtn.children('.flag-label').length)
			{
				aBtn.attr('title','').wrapInner('<span class="flag-label"></span>');		
			}

			aBtn.hover(function () {
				aBtn.addClass('expanded');
			},function () {
				aBtn.removeClass('expanded');
			});	
		}
	
  });
	
	// Variants
	$('a.a-variant-options-toggle').click(function(){
		$(this).parents('.a-slots').children().css('z-index','699');
		$(this).parents('.a-slot').css('z-index','799');	
	});
	
	// Disabled Buttons
	$('.a-disabled').unbind('click').unbind('hover').click(function(event){
		event.preventDefault();
	}).attr('onclick','');

	// Cross Browser Opacity Settings
	$('.a-nav .a-archived-page').fadeTo(0,.5); // Archived Page Labels

	// Apply clearfix on controls and options
	$('.a-controls, .a-options').addClass('clearfix');

	// Add 'last' Class To Last Option
	$('.a-controls li:last-child').addClass('last'); 
	
	// You can define this function in your site.js to execute code whenenever apostrophe calls aUI();
	// We use this for refreshing progressive enhancements such as Cufon following an Ajax request.
	if (typeof(aOverrides) =="function")
	{ 
		aOverrides(); 	
	}
}

Changed 17 months ago by johnnyoffline

Tom,

Maybe we can look at this together for a few minutes to decide if / when / where any of this macaroni salad should live?

Changed 17 months ago by johnnyoffline

  • cc tboutell, rickybanister, johnnyoffline, jake, dordille, added
  • keywords js, 1.5rc added; js removed

Changed 17 months ago by tboutell

Here is the question as I see it:

"We need a little more magic than plain CSS can provide, especially on a cross-browser basis, and the only way to get there is to run a certain piece of JavaScript? on every page fetch and AJAX page update to guarantee that things work as they should."

If the answer is yes, then my suggestion would be to make sure everything in apostrophe.enhance() looks for a class name that expresses what the special sauce is going to do, in general terms. For instance, your a-disabled class seems powerful and general and entirely appropriate to be magicked into effect on every fetch.

On the other hand, a-variant-options-toggle looks like something that ought to be in an apostrophe.variantEnableOptionsToggle() method that gets invoked with a_js_call from a partial somewhere, unless you think that part of the code is doing something that might be useful for some less narrow purpose, in which case it should have a less narrow name.

Didn't you say earlier that jQuery has some way of binding to things that haven't been created yet by class etc.? If that's true then we might be able to dispense with remembering to call this from every ajax action.

Changed 17 months ago by rickybanister

  • type changed from defect to task

Changed 16 months ago by rickybanister

  • status changed from new to closed
  • resolution set to fixed

aUI has been dismantled and absorbed by the new javascript framework we have setup with the 1.5 release.

There's nothing to document.

Note: See TracTickets for help on using tickets.