iPortalX Wiki

Code Snippets

Modified: Wed, 30 Jan 2008 00:23 by admin - Categorized as: iPortalX
Edit

Code for iPortalX and MooTools

These Snippets are for add-ons for iPortalX.





Edit

Highlighted Menu Items

This one makes the menu items highlighted when mouse over.

You would need to change the colors...

// when dom is ready, execute code
window.addEvent('domready', function() {
	$$('.MenuLink','.SubMenuLink').each(function(el) {

		el.getParent().addEvents({
			'mouseenter': function() {
				// highlight table cell color
				el.getParent().tween('background-color','#4A4A4A');
			},
			'mouseleave': function() {
				// original table cell color
				el.getParent().tween('background-color','#333333');
			}
		});

		el.addEvents({
			'mouseenter': function() {
				// highlight link color
				el.tween('color','#FFD461');
			},
			'mouseleave': function() {
				// original link color
				el.tween('color','#C0C0C0');
			}
		});
	});
});
// End Window OnLoad

Edit

Join Pop Up

This code was created for g-h-o-s-t.net for when a visitor is lurking around the site. It prompts them to join with a little sticky note. View Image Here

This code uses a image map to make the close box and "Join Now" part of the image clickable. It also has a custom postion instead of poping into the center of the page.

// Join Pop Up
var joinPopUp = function() {
	// if join image already shown, dont do it again
	if (Cookie.get('joinPopUp')) return false;

	var container = new Element('div').adopt(
		new Element('img', {
			'src': 'images/join.png',
			'usemap': '#joinPopUp',
			'styles': {
				'border': '0px'
			}
		}),

		new Element('map', {
			'name': 'joinPopUp'
		}).adopt(
			// make the Join Now part of the image clickable with a image map
			new Element('area', {
				'shape': 'rect',
				'coords': '84,217,289,282',
				'styles': {
					'cursor': 'pointer'
				},
				'events': {
					// click event
					'click': function(event) {

						// change page
						window.location='http://www.g-h-o-s-t.net/forum/register.asp';
					}
				}
			}),
			// make the close button clickble with an image map
			new Element('area', {
				'shape': 'rect',
				'coords': '235,20,277,63',
				'styles': {
					'cursor': 'pointer'
				},
				'events': {
					// click event
					'click': function(event) {

						// stop click
						event.stop();

						// close the notification box
						joinPopUp.fireEvent('doClose');
					}
				}
			})

		)
	);

	// join popup create
	var joinPopUp = new imageBox({
		'id': 'radioBox',
		'doPostion': {
			'top': 100,
			'left': 100
		}
	}).adopt(container).fireEvent('doOpen', false);

	// set add to not show for 7 days
	Cookie.set('joinPopUp', true, {
		'duration': 0
	})
};

// when dom is ready, execute code
window.addEvent('domready', function() {
	// delay join pop up by 3 seconds.
	joinPopUp.delay(3000);
};


Somewhere in the portal (suggested place is header_inc.asp) you would had a blnGuest check and use a Javascript include with the code above.





Edit

IE 6 Upgrade Warning

People really need to upgrade to IE7... its free, its faster, and its more secure. This code adds a "Upgrade to IE 7" warning on top and bottom of a page.

// when dom is ready, execute code
window.addEvent('domready', function() {

	if (Browser.Engine.trident4) {
		new Element('div', {
			'styles': {
				'border': '1px dashed #ff0000',
				'background': '#f2d6d6',
				'padding': 10,
				'color': '#8b0000',
				'font-weight': 'bold',
				'text-align': 'center'
			},
			'html': 'You are running Internet Explorer 6. You really should upgrade for security reasons. <a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx" style="color: #8b0000;">Click Here to Upgrade</a>'
		}).inject(document.body, 'top').clone(true).inject(document.body, 'bottom');
	};
});

ScrewTurn Wiki version 2.0.33. Some of the icons created by FamFamFam.