| author | Gautier Thibault <gthibault@universcine.com> |
| Tue, 22 Sep 2009 16:40:38 +0200 | |
| changeset 35 | 94a1dc255022 |
| permissions | -rw-r--r-- |
|
35
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
1 |
var uc = uc || {};
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
2 |
uc.common = uc.common || {};
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
3 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
4 |
//Ajaxify content |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
5 |
uc.common.ajaxify = function (timeout) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
6 |
if (timeout == null) timeout = 0; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
7 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
8 |
// Fix section header width |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
9 |
// Wait a time to make sure css is loaded |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
10 |
window.setTimeout(uc.common.fixSectionStyle, timeout); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
11 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
12 |
uc.utils.ajaxifyLink(jQuery('a.ajax-post'), 'POST', function() {uc.common.ajaxify();});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
13 |
uc.utils.ajaxifyLink(jQuery('a.ajax'), 'GET', function() {uc.common.ajaxify();});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
14 |
uc.utils.ajaxifyLink(jQuery('.ajax a'), 'GET', function() {uc.common.ajaxify();});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
15 |
uc.utils.ajaxifyForm(jQuery('form.ajax'), function() {uc.common.ajaxify();});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
16 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
17 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
18 |
uc.common.fixSectionStyle = function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
19 |
jQuery('.border-section').each(function(index) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
20 |
var jq_section = jQuery(this); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
21 |
var section_width = jq_section.outerWidth(); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
22 |
var jq_head = jQuery('.head', jq_section);
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
23 |
var head_width = jq_head.outerWidth(); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
24 |
var jq_header = jQuery('.section-header', jq_section);
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
25 |
var header_padding = parseInt(jq_header.css('padding-left')) + parseInt(jq_header.css('padding-right')) + 2;
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
26 |
jq_header.width(section_width-head_width-header_padding); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
27 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
28 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
29 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
30 |
// Process document after its loading |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
31 |
jQuery(document).ready(function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
32 |
// Cycle |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
33 |
uc.cycle.build("ul.cycle-list");
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
34 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
35 |
// Ajaxify |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
36 |
uc.common.ajaxify(200); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
37 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
38 |
// Add help feature to input text |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
39 |
jQuery('input.help[type=text]').each(function(index) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
40 |
var jq_this = jQuery(this); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
41 |
var help = jq_this.val(); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
42 |
jq_this.focus(function() {if (jq_this.val() == help) jq_this.val('');});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
43 |
jq_this.blur(function() {if (jq_this.val() == '') jq_this.val(help);});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
44 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
45 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
46 |
// Wrap select list. If user click on a list item, add a 'selected' class |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
47 |
uc.utils.buildSelectList(jQuery('ul.select-list'));
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
48 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
49 |
// Add livesearch on search input |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
50 |
uc.search.build('#search input', 2, '#page', 316, -11);
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
51 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
52 |
// Form rating |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
53 |
uc.rating.build('form select.input-rating', 10);
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
54 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
55 |
jQuery('.form-rating').bind('rated', function () {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
56 |
jQuery(this).submit(); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
57 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
58 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
59 |
// Add scrolling wrapper around image playlist |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
60 |
jQuery('.image-playlist').each(function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
61 |
jq_this = jQuery(this); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
62 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
63 |
if (jQuery('ul.media-list li', this).length > 4) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
64 |
jQuery('.scrolling', jq_this).scrollable({items: 'ul', size: 4, clickable: false, prevPage: '.rewind-page', nextPage: '.forward-page'});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
65 |
} else {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
66 |
jQuery('.rewind-page, .forward-page', jq_this).addClass('disabled');
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
67 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
68 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
69 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
70 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
71 |
// Instantiate all flow player |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
72 |
uc.player.build(".media-playlist");
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
73 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
74 |
jQuery('a.cycle-random-list').each(function () {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
75 |
var jq_this = jQuery(this); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
76 |
var json_url = jq_this.attr('href');
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
77 |
jQuery.ajax({
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
78 |
url: json_url, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
79 |
beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "application/json");},
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
80 |
complete: function (XMLHttpRequest, textStatus) {},
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
81 |
success: function (data, textStatus) {alert(data);},
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
82 |
dataType: "script" |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
83 |
}) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
84 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
85 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
86 |