Advertisement

10.13.2008 at 07:16PM PDT, ID: 23811523
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Need to get tabs to work in a mootools slider that i developed.

Asked by l_mcnamara in JavaScript, Scripting Languages, JavaScript Frameworks

Tags: , ,

I've constructed a slider which activates when a href is clicked by the user.  It slides in from the bottom of the page with slight animation.
I need to get a tab system working within this slider.  So far i've had no luck.

Interestingly the tabs will work outside of the slider but as soon as I place the tabs inside the slider div, they won't work.

Please take a look at the url i provided for a (kind of) working sample - you'll see what i want to achieve:
http://www.iselectmedia.com/development/mooSlide/

Ill attach code snippets.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
/*********************  HTML FILE *******************/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="mint" language="javascript" type="text/javascript"></script>
<script src="mootools.js" language="javascript" type="text/ecmascript"></script>
<script src="mootabs1.2.js" type="text/javascript" charset="utf-8"></script>
 
<link rel="stylesheet" href="mootabs1.2.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
 
</head>
<body>
<div id="content">
	<a title="" href="images/blank.gif" rev="mycontent" rel="designSlide">click</a>
	<div id="mycontent">
        <div id="myTabs">
            <ul class="mootabs_title">
                <li title="My Work">Tab 1</li>
                <li title="About Me">Tab 2</li>
            </ul>				
            <div id="My Work" class="mootabs_panel">
                <h1>Tab 1</h1>
                Lorem ipsum dolor sit amet, consectetur adipisicing elit.					
            </div>                        
            <div id="About Me" class="mootabs_panel">
                <h1>Tab 2</h1>
                Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.					
            </div>        
        </div>
        <script type="text/javascript" charset="utf-8">
			window.addEvent('domready', init);
			function init() {
			myTabs1 = new mootabs('myTabs');
			}
		</script>
	</div>
<script src="mooSlideX.js" language="javascript" type="text/ecmascript"></script>
</body>
</html>
/*********************  END HTML FILE *******************/
 
 
/*********************  MOOTABS1.2.JS FILE *******************/
var mootabs = new Class({
	
	initialize: function(element, options) {
		this.options = Object.extend({
			width:				'95%',
			height:				'100px',
			changeTransition:	Fx.Transitions.Bounce.easeOut,
			duration:			1000,
			mouseOverClass:		'active',
			activateOnLoad:		'first',
			useAjax: 			false,
			ajaxUrl: 			'',
			ajaxOptions: 		{method:'get'},
			ajaxLoadingText: 	'Loading...'
		}, options || {});
		
		this.el = $(element);
		this.elid = element;
		
		this.el.setStyles({
			height: this.options.height,
			width: this.options.width
		});
		
		this.titles = $$('#' + this.elid + ' ul.mootabs_title li');
		this.panelHeight = this.el.getSize().size.y - (this.titles[0].getSize().size.y + 4);
		this.panels = $$('#' + this.elid + ' .mootabs_panel');
 
		
		this.panels.setStyle('height', this.panelHeight);
		
		this.titles.each(function(item) {
			item.addEvent('click', function(){
					item.removeClass(this.options.mouseOverClass);
					this.activate(item);
				}.bind(this)
			);
			
			item.addEvent('mouseover', function() {
				if(item != this.activeTitle)
				{
					item.addClass(this.options.mouseOverClass);
				}
			}.bind(this));
			
			item.addEvent('mouseout', function() {
				if(item != this.activeTitle)
				{
					item.removeClass(this.options.mouseOverClass);
				}
			}.bind(this));
		}.bind(this));
		
		
		if(this.options.activateOnLoad != 'none')
		{
			if(this.options.activateOnLoad == 'first')
			{
				this.activate(this.titles[0], true);
			}
			else
			{
				this.activate(this.options.activateOnLoad, true);	
			}
		}
	},
	
	activate: function(tab, skipAnim){
		if(! $defined(skipAnim))
		{
			skipAnim = false;
		}
		if($type(tab) == 'string') 
		{
			myTab = $$('#' + this.elid + ' ul li').filterByAttribute('title', '=', tab)[0];
			tab = myTab;
		}
		
		if($type(tab) == 'element')
		{
			var newTab = tab.getProperty('title');
			this.panels.removeClass('active');
			
			this.activePanel = this.panels.filterById(newTab)[0];
			
			this.activePanel.addClass('active');
			
			if(this.options.changeTransition != 'none' && skipAnim==false)
			{
				this.panels.filterById(newTab).setStyle('height', 0);
				var changeEffect = new Fx.Elements(this.panels.filterById(newTab), {duration: this.options.duration, transition: this.options.changeTransition});
				changeEffect.start({
					'0': {
						'height': [0, this.panelHeight]
					}
				});
			}
			
			this.titles.removeClass('active');
			
			tab.addClass('active');
			
			this.activeTitle = tab;
			
			if(this.options.useAjax)
			{
				this._getContent();
			}
		}
	},
	
	_getContent: function(){
		this.activePanel.setHTML(this.options.ajaxLoadingText);
		var newOptions = {update: this.activePanel.getProperty('id')};
		this.options.ajaxOptions = Object.extend(this.options.ajaxOptions, newOptions || {});
		var tabRequest = new Ajax(this.options.ajaxUrl + '?tab=' + this.activeTitle.getProperty('title'), this.options.ajaxOptions);
		tabRequest.request();
	},
	
	addTab: function(title, label, content){
		//the new title
		var newTitle = new Element('li', {
			'title': title
		});
		newTitle.appendText(label);
		this.titles.include(newTitle);
		$$('#' + this.elid + ' ul').adopt(newTitle);
		newTitle.addEvent('click', function() {
			this.activate(newTitle);
		}.bind(this));
		
		newTitle.addEvent('mouseover', function() {
			if(newTitle != this.activeTitle)
			{
				newTitle.addClass(this.options.mouseOverClass);
			}
		}.bind(this));
		newTitle.addEvent('mouseout', function() {
			if(newTitle != this.activeTitle)
			{
				newTitle.removeClass(this.options.mouseOverClass);
			}
		}.bind(this));
		//the new panel
		var newPanel = new Element('div', {
			'style': {'height': this.options.panelHeight},
			'id': title,
			'class': 'mootabs_panel'
		});
		if(!this.options.useAjax)
		{
			newPanel.setHTML(content);
		}
		this.panels.include(newPanel);
		this.el.adopt(newPanel);
	},
	
	removeTab: function(title){
		if(this.activeTitle.title == title)
		{
			this.activate(this.titles[0]);
		}
		$$('#' + this.elid + ' ul li').filterByAttribute('title', '=', title)[0].remove();
		
		$$('#' + this.elid + ' .mootabs_panel').filterById(title)[0].remove();
	},
	
	next: function(){
		var nextTab = this.activeTitle.getNext();
		if(!nextTab) {
			nextTab = this.titles[0];
		}
		this.activate(nextTab);
	},
	
	previous: function(){
		var previousTab = this.activeTitle.getPrevious();
		if(!previousTab) {
			previousTab = this.titles[this.titles.length - 1];
		}
		this.activate(previousTab);
	}
});
/*********************  END MOOTABS1.2.JS FILE *******************/
 
 
/*********************  MOOTABS1.2 CSS FILE *******************/
.mootabs_title {
	list-style-image: none;
	list-style-type: none;
	margin: 0px;
	padding: 0px;
	height: 24px;
}
 
.mootabs_title li {
	float: left;
	background-color: #000;
	padding: 2px 8px 2px 8px;
	margin-right: 2px;
	cursor: pointer;
	height: 18px;
	color:#fff;
	
}
 
.mootabs_title li.active {
	background-color: #aaa;
}
 
.mootabs_panel {
	display: none;
	background-color: #000;
	position: relative;
	width: 100%;
	top: 10px;
	clear: both;
	overflow: auto;
	
	
}
 
.mootabs_panel.active {
	background-color: #000;
	display: block;
}
/*********************  END MOOTABS1.2 CSS FILE *******************/
 
 
/*********************  MOOSLIDEX.JS FILE *******************/
window.addEvent('domready',function(){
 
	$$('a').each(function(x){
		y = x.getAttribute('rev');
	
		if(navigator.appVersion.indexOf('MSIE') != -1){
			if(y != ""){
				$(y).setStyle('visibility','hidden');
			}
		}else{
			if(y != null){
				$(y).setStyle('visibility','hidden');
			}
		}
	})
})
 
var xxx = new Array();
 
$$('a').each(function(el){
	if(el.getAttribute('rel') == "designSlide"){
		
		// preload images
		a = new Image();
		lnk = el.getAttribute('href');
		a.src = lnk;
		xxx.push(a);
	
		el.addEvent('click',function(x){		
		// old container still existing? remove it
		if($('container2') != false){
			$('container2').remove();
		}
		
		//go
		bd = document.body;
		windowHeight = 0;
		windowWidth = 0;
		title = el.getAttribute('title');
		titleSplitPos = title.indexOf("::");
		titleHead = title.substring(0,titleSplitPos);
		lengthContent = title.length + titleSplitPos
		titleContent = title.substring(titleSplitPos+2,lengthContent);
		addContent = el.getAttribute('rev');
		
 
	
		if($(addContent) != false){
			addContentCont = $(addContent).innerHTML;
			$(addContent).setStyle('visibility','hidden');	
		}
	
		nav = navigator.appName;
		windowHeight = window.getScrollTop() + window.getHeight();
		var x = new Event(x).stop();
		var hrefSrc = el.getAttribute('href');
		var preloadPrev = new Image();
		preloadPrev.src = hrefSrc;
		var imgWidth = preloadPrev.width;
		var imgHeight = preloadPrev.height;	
		var space = imgHeight;
		var top = windowHeight - 152;
		
		// create a new div with the width of the screen
		var container = new Element('div', {
					'styles': 
					{
						'display': 'block',
						'visibility':'hidden',
						'width': '99%',
						'height': 'auto',
						'background':'#000',
						'border': '1px solid #AAA',
						'padding-bottom':'20px',
						'left':'5px',
						'margin':'0px',
						'position': 'absolute',
						'top': top + 'px',
						'cursor':'default',
						'color':'#fff'
					}
			  })
			  
		container.setAttribute('id','container2');
			  
			  image = new Element('img', {
			  	'styles':
				{
					'border': 'none',
					'display':'block',
					'visibility': 'hidden',
					'float':'left',
					//'background': '#000 url(images/loading.gif) center center no-repeat',
					'margin-top':'20px',
					'margin-left':'20px',
					'height':'auto',
					'width': 'auto',
					'src': hrefSrc,
					'z-index':'1000'
				}			
			})
			
			  div = new Element('div', {
			    'styles':
				{
						'float':'left',
						'width':'95%',
						'height':'auto',
						'display':'block',
						'margin-top':'10px',
						'margin-left':'-15px'
		
				}
			})
			
			off = new Element('img', {
			  'styles':
			  	{
			  			'position':'absolute',
						'top':'10px',
						'right':'10px',
						'padding':'0px',
						'width':'33px',
						'height':'11px',
						'cursor':'pointer'//added this for functionality
						
						
				}
			
			})		
			  off.src="images/close.jpg";
			 off.addEvent('click',function(){
			 	  	 container.effect('opacity',{duration: 700, transition: Fx.Transitions.linear, wait:true}).start(0.9,0).chain(function(){
					 // var h = container.getStyle('height');																															  					//  image.remove();
					//  container.effect('height',{duration: 700, transition: Fx.Transitions.linear, wait:true}).start(h,0).chain(function(){
					  container.remove();
					  $('overlayed').effect('opacity',{duration: 300, transition: Fx.Transitions.linear, wait:true}).start(0.5,0);
					  $('overlayed').remove();
					 })
			 })
			  
			 div.setAttribute('id','info');			
			
			 if($(addContent) != false){
			 div.innerHTML = "<h1>" + titleHead + "</h1><p>" + titleContent + "</p>" + "<p>" + addContentCont + "</p>";
			 }else{
			 div.innerHTML = "<h1>" + titleHead + "</h1><p>" + titleContent + "</p>";
			 }
			 
			 // add overlay
			 /*winH = window.getScrollHeight();
			 winW = window.getScrollWidth();
			 overlayed = new Element('div', {
	          'styles':
			  {
				  	'width':winW,
					'height':winH,
					'position':'absolute',
					'background-color':'#000',
					'visibility':'hidden',
					'top':'0px'
					
			  }
			  })
			  overlayed.setAttribute('id','overlayed');			
			  overlayed.injectInside(document.body);*/
			  
			  image.src = preloadPrev.src;
			  
			  //overlayed.effect('opacity',{ duration: 200, transition:Fx.Transitions.linear, wait:true }).start(0,0.7);
			  container.injectInside(bd);
			  image.injectInside(container);
			  image.effect('opacity',{duration: 1200, transition: Fx.Transitions.linear, wait:true}).start(0,1);
		  	  container.effect('opacity',{duration: 0, transition: Fx.Transitions.linear, wait:true}).start(0,0.9);
			  container.effect('top',{duration: 500, transition: Fx.Transitions.Back.easeOut, wait:false}).start(windowHeight,top);
			  div.injectAfter(image);
			  div.effect('opacity',{duration: 0, transition: Fx.Transitions.linear, wait:true}).start(0,1);
			  off.injectInside(div);
			  //container.makeDraggable();
			 return false;
		})
	}
})
/*********************  END MOOSLIDEX.JS FILE *******************/
 
Keywords: Need to get tabs to work in a mootools …
 
Loading Advertisement...
 
[+][-]10.14.2008 at 07:01AM PDT, ID: 22711350

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.14.2008 at 04:08PM PDT, ID: 22716828

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Scripting Languages, JavaScript Frameworks
Tags: JavaScript, MooTools, All modern browers, primarily IE's, http://www.iselectmedia.com/developement/mooSlide/
Sign Up Now!
Solution Provided By: l_mcnamara
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628