root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / views / toggle-lt-bar.js @ cb6d8025
History | View | Annotate | Download (1.8 kB)
1 |
App.toggleLtBarView = Ember.View.extend({ |
---|---|
2 |
tagName: 'a', |
3 |
classNames: ['toggle-lt-bar'], |
4 |
templateName: 'toggle-lt-bar', |
5 |
|
6 |
didInsertElement: function() { |
7 |
var that = this; |
8 |
this.$().click(function (e) { |
9 |
that.aux_function(400,e);
|
10 |
}); |
11 |
this.$().find('img-wrap a').click(function(e) { |
12 |
// na kleinei ti lista....
|
13 |
}); |
14 |
}, |
15 |
|
16 |
aux_function: function (speed,e) { |
17 |
e.preventDefault(); |
18 |
e.stopPropagation(); |
19 |
this.listToggle(speed,e);
|
20 |
}, |
21 |
|
22 |
listToggle: function (speed,e) { |
23 |
var cmarg = parseInt($('.lt-bar').width()) - parseInt($('.toggle-lt-bar').outerWidth(true)); |
24 |
var ctemp = cmarg / parseInt($('.lt-bar').width()); |
25 |
var cvelocity = parseInt($('.lt-bar').width())/speed; |
26 |
var cdelay = parseInt($('.toggle-lt-bar').outerWidth(true))/cvelocity; |
27 |
var self =this; |
28 |
var marg = ''; |
29 |
|
30 |
if($(this).hasClass('fix-position')) { |
31 |
marg = parseInt($(self).css('marginLeft')) - cmarg; |
32 |
$(this).animate({ |
33 |
'margin-left': marg,
|
34 |
}, ctemp * speed, 'linear', function(){ |
35 |
$(self).removeAttr('style'); |
36 |
$(self).removeClass('fix-position'); |
37 |
}); |
38 |
$('.lt-bar').animate({ |
39 |
width: 'toggle' |
40 |
}, speed, 'linear');
|
41 |
} |
42 |
else {
|
43 |
$(this).addClass('fix-position'); |
44 |
var scrollBarWidth = 14; |
45 |
marg = parseInt($(self).css('marginLeft')) + cmarg - scrollBarWidth; |
46 |
setTimeout(function(){
|
47 |
$(self).animate({
|
48 |
'margin-left': marg,
|
49 |
}, speed, 'linear');
|
50 |
}, cdelay); |
51 |
$('.lt-bar').animate({ |
52 |
width: 'toggle' |
53 |
}, speed, 'linear', ui.setCustomScrollBar);
|
54 |
} |
55 |
} |
56 |
|
57 |
}); |