source: trunk/www.guidonia.net/wp/wp-content/themes/fusion/js/fusion.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 7.4 KB
Line 
1
2
3// cookie functions
4jQuery.cookie = function(name, value, options) {
5 if (typeof value != 'undefined') { // name and value given, set cookie
6 options = options || {};
7 if (value === null) {
8 value = '';
9 options = jQuery.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
10 options.expires = -1;
11 }
12 var expires = '';
13 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
14 var date;
15 if (typeof options.expires == 'number') {
16 date = new Date();
17 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
18 } else {
19 date = options.expires;
20 }
21 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
22 }
23 // NOTE Needed to parenthesize options.path and options.domain
24 // in the following expressions, otherwise they evaluate to undefined
25 // in the packed version for some reason...
26 var path = options.path ? '; path=' + (options.path) : '';
27 var domain = options.domain ? '; domain=' + (options.domain) : '';
28 var secure = options.secure ? '; secure' : '';
29 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
30 } else { // only name given, get cookie
31 var cookieValue = null;
32 if (document.cookie && document.cookie != '') {
33 var cookies = document.cookie.split(';');
34 for (var i = 0; i < cookies.length; i++) {
35 var cookie = jQuery.trim(cookies[i]);
36 // Does this cookie string begin with the name we want?
37 if (cookie.substring(0, name.length + 1) == (name + '=')) {
38 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
39 break;
40 }
41 }
42 }
43 return cookieValue;
44 }
45};
46// /cookie functions
47
48// fixes for IE-7 cleartype bug on fade in/out
49jQuery.fn.fadeIn = function(speed, callback) {
50 return this.animate({opacity: 'show'}, speed, function() {
51 if (jQuery.browser.msie) this.style.removeAttribute('filter');
52 if (jQuery.isFunction(callback)) callback();
53 });
54};
55
56jQuery.fn.fadeOut = function(speed, callback) {
57 return this.animate({opacity: 'hide'}, speed, function() {
58 if (jQuery.browser.msie) this.style.removeAttribute('filter');
59 if (jQuery.isFunction(callback)) callback();
60 });
61};
62
63jQuery.fn.fadeTo = function(speed,to,callback) {
64 return this.animate({opacity: to}, speed, function() {
65 if (to == 1 && jQuery.browser.msie) this.style.removeAttribute('filter');
66 if (jQuery.isFunction(callback)) callback();
67 });
68};
69
70
71// liquid <> fixed
72function setPageWidth(){
73 var currentWidth = jQuery('#page').css('width');
74 if (currentWidth=="95%") newWidth = "960px"; else if (currentWidth=="960px") newWidth = "95%"; else newWidth = "960px";
75 jQuery("#page").animate({width: newWidth}, 333).fadeIn("slow");
76 jQuery.cookie('pageWidth', newWidth);
77}
78
79// body font size
80function setFontSize() {
81 var size = jQuery.cookie('fontSize');
82 if (size=='.8em') newSize = '.95em';
83 else if (size=='.95em') newSize = '.7em';
84 else if (size=='.7em') newSize = '.8em';
85 else newSize = '.95em';
86 jQuery("body").animate({fontSize: newSize}, 333).fadeIn("slow");
87 jQuery.cookie('fontSize',newSize)
88}
89
90// minitabs
91jQuery.fn.minitabs = function(speed,effect) {
92 id = "#" + this.attr('id')
93 jQuery(id + ">DIV:gt(0)").hide();
94 jQuery(id + ">UL>LI>A:first").addClass("current");
95 jQuery(id + ">UL>LI>A").click(
96 function(){
97 jQuery(id + ">UL>LI>A").removeClass("current");
98 jQuery(this).addClass("current");
99 jQuery(this).blur();
100 var re = /([_\-\w]+$)/i;
101 var target = jQuery('#' + re.exec(this.href)[1]);
102 var old = jQuery(id + ">DIV");
103 switch (effect) {
104 case 'fade':
105 old.fadeOut(speed).fadeOut(speed);
106 target.fadeIn(speed);
107 break;
108 case 'slide':
109 old.slideUp(speed);
110 target.fadeOut(speed).fadeIn(speed);
111 break;
112 default :
113 old.hide(speed);
114 target.show(speed)
115 }
116 return false;
117 }
118 );
119}
120
121function initTooltips(o) {
122 var showTip = function() {
123 var el = jQuery('.tip', this).css('display', 'block')[0];
124 var ttHeight = jQuery(el).height();
125 var ttOffset = el.offsetHeight;
126 var ttTop = ttOffset + ttHeight;
127 jQuery('.tip', this)
128 .stop()
129 .css({'opacity': 0, 'top': 2 - ttOffset})
130 .animate({'opacity': 1, 'top': 18 - ttOffset}, 250);
131 };
132 var hideTip = function() {
133 var self = this;
134 var el = jQuery('.tip', this).css('display', 'block')[0];
135 var ttHeight = jQuery(el).height();
136 var ttOffset = el.offsetHeight;
137 var ttTop = ttOffset + ttHeight;
138 jQuery('.tip', this)
139 .stop()
140 .animate({'opacity': 0,'top': 10 - ttOffset}, 250, function() {
141 el.hiding = false;
142 jQuery(this).css('display', 'none');
143 }
144 );
145 };
146 jQuery('.tip').hover(
147 function() { return false; },
148 function() { return true; }
149 );
150 jQuery('.tiptrigger, #sidebar .cat-item').hover(
151 function(){
152 var self = this;
153 showTip.apply(this);
154 if (o.timeout) this.tttimeout = setTimeout(function() { hideTip.apply(self) } , o.timeout);
155 },
156 function() {
157 clearTimeout(this.tttimeout);
158 hideTip.apply(this);
159 }
160 );
161}
162
163function tabmenudropdowns(){
164//jQuery(" #tabs ul ").css({display: "none"}); // Opera Fix
165jQuery(" #tabs li").hover(function(){
166 jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(333);
167 },function(){
168 jQuery(this).find('ul:first').css({visibility: "hidden"});
169 });
170}
171
172// comment.js by mg12 - http://www.neoease.com/
173(function() {
174 function $$$(id) { return document.getElementById(id); }
175 function setStyleDisplay(id, status) { $$$(id).style.display = status; }
176
177 window['MGJS'] = {};
178 window['MGJS']['$$$'] = $$$;
179 window['MGJS']['setStyleDisplay'] = setStyleDisplay;
180
181})();
182
183
184(function() {
185 function quote(authorId, commentId, commentBodyId, commentBox) {
186 var author = MGJS.$$$(authorId).innerHTML;
187 var comment = MGJS.$$$(commentBodyId).innerHTML;
188
189 var insertStr = '<blockquote cite="#' + commentBodyId + '">';
190 insertStr += '\n<strong><a href="#' + commentId + '">' + author.replace(/\t|\n|\r\n/g, "") + '</a> :</strong>';
191 insertStr += comment.replace(/\t/g, "");
192 insertStr += '</blockquote>\n';
193
194 insertQuote(insertStr, commentBox);
195 }
196
197 function insertQuote(insertStr, commentBox) {
198 if(MGJS.$$$(commentBox) && MGJS.$$$(commentBox).type == 'textarea') {
199 field = MGJS.$$$(commentBox);
200
201 } else {
202 alert("The comment box does not exist!");
203 return false;
204 }
205
206 if(document.selection) {
207 field.focus();
208 sel = document.selection.createRange();
209 sel.text = insertStr;
210 field.focus();
211
212 } else if (field.selectionStart || field.selectionStart == '0') {
213 var startPos = field.selectionStart;
214 var endPos = field.selectionEnd;
215 var cursorPos = startPos;
216 field.value = field.value.substring(0, startPos)
217 + insertStr
218 + field.value.substring(endPos, field.value.length);
219 cursorPos += insertStr.length;
220 field.focus();
221 field.selectionStart = cursorPos;
222 field.selectionEnd = cursorPos;
223
224 } else {
225 field.value += insertStr;
226 field.focus();
227 }
228 }
229
230 window['MGJS_CMT'] = {};
231 window['MGJS_CMT']['quote'] = quote;
232
233})();
Note: See TracBrowser for help on using the repository browser.