1 | window.addEvent('domready', function() { |
---|
2 | galleryThumbs = $$('.thumbnailCategories li'); |
---|
3 | galleryThumbs.each(function(el){ |
---|
4 | el.linkUrl = el.getElement('a').href; |
---|
5 | el.addEvents({ |
---|
6 | 'mouseenter' : function(){addOver(el)}, |
---|
7 | 'mouseleave' : function(){removeOver(el)}, |
---|
8 | 'click' : function(){goToUrl(el)} |
---|
9 | }); |
---|
10 | }); |
---|
11 | |
---|
12 | catThumbs = $$('.thumbnails li'); |
---|
13 | catThumbs.each(function(el){ |
---|
14 | el.addEvents({ |
---|
15 | 'mouseenter' : function(){addOver(el)}, |
---|
16 | 'mouseleave' : function(){removeOver(el)} |
---|
17 | }); |
---|
18 | }); |
---|
19 | |
---|
20 | var mySelect = new elSelect( {container : 'order', onClicked: function(){new URI(this.hiddenInput.value).go();}} ); |
---|
21 | var themeSelect = new elSelect( {container : 'themeSelect'} ); |
---|
22 | var languageSelect = new elSelect( {container : 'languageSelect'} ); |
---|
23 | |
---|
24 | var photoPrev = $('linkPrev'); |
---|
25 | |
---|
26 | if(photoPrev) |
---|
27 | { |
---|
28 | photoPrev.image = photoPrev.getElement('img'); |
---|
29 | photoPrev.image.setStyle('opacity', 0); |
---|
30 | photoPrev.setStyle('display', 'block'); |
---|
31 | photoPrev.addEvents({ |
---|
32 | 'mouseenter': function(){ showElement(photoPrev.image) }, |
---|
33 | 'mouseleave': function(){ hideElement(photoPrev.image)} |
---|
34 | }); |
---|
35 | } |
---|
36 | |
---|
37 | var photoNext = $('linkNext'); |
---|
38 | if(photoNext) |
---|
39 | { |
---|
40 | photoNext.image = photoNext.getElement('img'); |
---|
41 | photoNext.image.setStyle('opacity', 0); |
---|
42 | photoNext.setStyle('display', 'block'); |
---|
43 | photoNext.addEvents({ |
---|
44 | 'mouseenter': function(){ showElement(photoNext.image) }, |
---|
45 | 'mouseleave': function(){ hideElement(photoNext.image)} |
---|
46 | }); |
---|
47 | } |
---|
48 | }); |
---|
49 | |
---|
50 | function addOver(el){ |
---|
51 | if(!el.hasClass('hover')) el.addClass('hover'); |
---|
52 | } |
---|
53 | |
---|
54 | function removeOver(el){ |
---|
55 | if(el.hasClass('hover')) el.removeClass('hover'); |
---|
56 | } |
---|
57 | |
---|
58 | function goToUrl(el){ |
---|
59 | new URI(el.linkUrl).go(); |
---|
60 | } |
---|
61 | |
---|
62 | function showElement(el) |
---|
63 | { |
---|
64 | el.morph({'opacity': 1}); |
---|
65 | } |
---|
66 | |
---|
67 | function hideElement(el) |
---|
68 | { |
---|
69 | el.morph({'opacity': 0}); |
---|
70 | } |
---|
71 | |
---|
72 | function toggleElement(el) |
---|
73 | { |
---|
74 | if(el.getStyle('opacity') == 0) showElement(el); else hideElement(el); |
---|
75 | } |
---|
76 | |
---|
77 | var gRatingOptions, gRatingButtons, gUserRating; |
---|
78 | |
---|
79 | function makeNiceRatingForm(options) |
---|
80 | { |
---|
81 | gRatingOptions = options || {}; |
---|
82 | var form = $('rateForm'); |
---|
83 | if (!form) return; |
---|
84 | |
---|
85 | gRatingButtons = form.getElements('input'); |
---|
86 | gUserRating = ""; |
---|
87 | |
---|
88 | gRatingButtons.each(function(el){ if ( el.type=="button" ) { gUserRating = el.value; } }); |
---|
89 | |
---|
90 | gRatingButtons.each(function(el, i){ |
---|
91 | |
---|
92 | el.initialRateValue = el.value; // save it as a property |
---|
93 | |
---|
94 | try { el.type = "button"; } catch (e){}// avoid normal submit (use ajax); not working in IE6 |
---|
95 | |
---|
96 | //hide the text IE/Opera - breaks safari |
---|
97 | if (navigator.userAgent.indexOf('AppleWebKit/') == -1 ) el.value = ""; |
---|
98 | |
---|
99 | el.setStyles({ |
---|
100 | 'textIndent' : "-50px", |
---|
101 | 'marginLeft' : 0, |
---|
102 | 'marginRight' : 0 |
---|
103 | }); |
---|
104 | |
---|
105 | if (i!=gRatingButtons.length-1 && el.nextSibling.nodeType == 3 /*TEXT_NODE*/) |
---|
106 | el.parentNode.removeChild(el.nextSibling); |
---|
107 | |
---|
108 | if (i>0 && el.previousSibling.nodeType == 3 /*TEXT_NODE*/) |
---|
109 | el.parentNode.removeChild(el.previousSibling); |
---|
110 | |
---|
111 | el.addEvents({ |
---|
112 | 'mouseenter' : function(){updateRating(el)}, |
---|
113 | 'mouseleave' : function(){resetRating(el)}, |
---|
114 | 'click' : function(e){submitRating(e)} |
---|
115 | }); |
---|
116 | |
---|
117 | }); |
---|
118 | } |
---|
119 | |
---|
120 | function resetRating(el) |
---|
121 | { |
---|
122 | for (i = 1; i<gRatingButtons.length; i++){ |
---|
123 | gRatingButtons[i].removeClass('rateButtonUserFull2'); |
---|
124 | gRatingButtons[i].removeClass('rateButtonUserHalf2'); |
---|
125 | gRatingButtons[i].removeClass('rateButtonUserEmpty2'); |
---|
126 | gRatingButtons[i].removeClass('rateButtonFull2'); |
---|
127 | gRatingButtons[i].removeClass('rateButtonHalf2'); |
---|
128 | gRatingButtons[i].removeClass('rateButtonEmpty2'); |
---|
129 | if(gRatingButtons[i].value > el.value) break; |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | function updateRating(el) |
---|
134 | { |
---|
135 | for (i = 1; i<gRatingButtons.length; i++){ |
---|
136 | var newClass = 'rateButton'; |
---|
137 | if(gRatingButtons[i].title <= el.title) newClass = newClass+'User'; |
---|
138 | if(gRatingButtons[i].hasClass('rateButtonFull') || gRatingButtons[i].hasClass('rateButtonUserFull')) newClass = newClass+'Full2'; |
---|
139 | else if(gRatingButtons[i].hasClass('rateButtonHalf') || gRatingButtons[i].hasClass('rateButtonUserHalf')) newClass = newClass+'Half2'; |
---|
140 | else newClass = newClass+'Empty2'; |
---|
141 | gRatingButtons[i].addClass(newClass); |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | function setNewRate(average, count, stdev, newRating) |
---|
146 | { |
---|
147 | ratingSplitted = average.split('.'); |
---|
148 | starFull = ratingSplitted[0]; |
---|
149 | starHalf = (ratingSplitted[1] > 49) ? true : false; |
---|
150 | |
---|
151 | for (i = 1; i<gRatingButtons.length; i++){ |
---|
152 | gRatingButtons[i].removeClass('rateButtonFull'); |
---|
153 | gRatingButtons[i].removeClass('rateButtonHalf'); |
---|
154 | gRatingButtons[i].removeClass('rateButtonEmpty'); |
---|
155 | gRatingButtons[i].removeClass('rateButtonUserFull'); |
---|
156 | gRatingButtons[i].removeClass('rateButtonUserHalf'); |
---|
157 | gRatingButtons[i].removeClass('rateButtonUserEmpty'); |
---|
158 | gRatingButtons[i].removeClass('rateButtonFull2'); |
---|
159 | gRatingButtons[i].removeClass('rateButtonHalf2'); |
---|
160 | gRatingButtons[i].removeClass('rateButtonEmpty2'); |
---|
161 | gRatingButtons[i].removeClass('rateButtonUserFull2'); |
---|
162 | gRatingButtons[i].removeClass('rateButtonUserHalf2'); |
---|
163 | gRatingButtons[i].removeClass('rateButtonUserEmpty2'); |
---|
164 | |
---|
165 | |
---|
166 | if(gRatingButtons[i].title <= starFull) gRatingButtons[i].addClass((gRatingButtons[i].title <= newRating) ? 'rateButtonUserFull': 'rateButtonFull'); |
---|
167 | else if(gRatingButtons[i].title == starFull.toInt()+1) |
---|
168 | if(gRatingButtons[i].title <= newRating) gRatingButtons[i].addClass((starHalf) ? 'rateButtonUserHalf': 'rateButtonUserEmpty'); |
---|
169 | else gRatingButtons[i].addClass((starHalf) ? 'rateButtonHalf': 'rateButtonEmpty'); |
---|
170 | else gRatingButtons[i].addClass((gRatingButtons[i].title <= newRating) ? 'rateButtonUserEmpty': 'rateButtonEmpty'); |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | function submitRating(e) |
---|
175 | { |
---|
176 | var rateButton = e.target; |
---|
177 | if (rateButton.initialRateValue == gUserRating) |
---|
178 | return false; //nothing to do |
---|
179 | |
---|
180 | for (var i=0; i<gRatingButtons.length; i++) gRatingButtons[i].disabled=true; |
---|
181 | var y = new PwgWS(gRatingOptions.rootUrl); |
---|
182 | y.callService( |
---|
183 | "pwg.images.rate", {image_id: gRatingOptions.image_id, rate: rateButton.initialRateValue } , |
---|
184 | { |
---|
185 | onFailure: function(num, text) { |
---|
186 | alert(num + " " + text); |
---|
187 | document.location = rateButton.form.action + "&rate="+rateButton.initialRateValue; |
---|
188 | }, |
---|
189 | onSuccess: function(result) { |
---|
190 | gUserRating = rateButton.initialRateValue; |
---|
191 | for (var i=0; i<gRatingButtons.length; i++) gRatingButtons[i].disabled=false; |
---|
192 | setNewRate(result.average, result.count, result.stdev, rateButton.initialRateValue); |
---|
193 | if (gRatingOptions.ratingSummaryElement) |
---|
194 | { |
---|
195 | var t = gRatingOptions.ratingSummaryText; |
---|
196 | var args =[result.average, result.count, result.stdev], idx = 0, rexp = new RegExp( /%\.?\d*[sdf]/ ); |
---|
197 | _xxx = t.match( rexp ); |
---|
198 | while (idx<args.length) t=t.replace(rexp, args[idx++]); |
---|
199 | gRatingOptions.ratingSummaryElement.innerHTML = t; |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | ); |
---|
204 | return false; |
---|
205 | } |
---|
206 | |
---|
207 | |
---|
208 | /** |
---|
209 | * @file elSelect.js |
---|
210 | * @downloaded from http://www.cult-f.net/2007/12/14/elselect/ |
---|
211 | * @hacked by Luciano Amodio www.lucianoamodio.it |
---|
212 | * @author Sergey Korzhov aka elPas0 |
---|
213 | * @site http://www.cult-f.net |
---|
214 | * @date December 14, 2007 |
---|
215 | * |
---|
216 | */ |
---|
217 | var elSelect = new Class({ |
---|
218 | options: { |
---|
219 | container: false, |
---|
220 | baseClass : 'elSelect', |
---|
221 | onClicked: $lambda(false) |
---|
222 | }, |
---|
223 | source : false, |
---|
224 | selected : false, |
---|
225 | _select : false, |
---|
226 | current : false, |
---|
227 | selectedOption : false, |
---|
228 | dropDown : false, |
---|
229 | optionsContainer : false, |
---|
230 | hiddenInput : false, |
---|
231 | /* |
---|
232 | pass the options, |
---|
233 | create html and inject into container |
---|
234 | */ |
---|
235 | initialize: function(options){ |
---|
236 | this.setOptions(options) |
---|
237 | |
---|
238 | if ( !$(this.options.container) ) return |
---|
239 | |
---|
240 | this.selected = false |
---|
241 | this.source = $(this.options.container).getElement('select') |
---|
242 | this.buildFrameWork() |
---|
243 | |
---|
244 | $(this.source).getElements('option').each( this.addOption, this ) |
---|
245 | $(this.options.container).set('html', '') |
---|
246 | this._select.injectInside($(this.options.container)) |
---|
247 | |
---|
248 | this.bindEvents() |
---|
249 | |
---|
250 | }, |
---|
251 | |
---|
252 | buildFrameWork : function() { |
---|
253 | this._select = new Element('div').addClass( this.options.baseClass ) |
---|
254 | this.current = new Element('div').addClass('selected').injectInside($(this._select)) |
---|
255 | this.selectedOption = new Element('div').addClass('selectedOption').injectInside($(this.current)) |
---|
256 | this.dropDown = new Element('div').addClass('dropDown').injectInside($(this.current)) |
---|
257 | new Element('div').addClass('clear').injectInside($(this._select)) |
---|
258 | this.optionsContainer = new Element('div').addClass('optionsContainer').injectInside($(this._select)) |
---|
259 | var t = new Element('div').addClass('optionsContainerTop').injectInside($(this.optionsContainer)) |
---|
260 | var o = new Element('div').injectInside($(t)) |
---|
261 | var p = new Element('div').injectInside($(o)) |
---|
262 | var t = new Element('div').addClass('optionsContainerBottom').injectInside($(this.optionsContainer)) |
---|
263 | var o = new Element('div').injectInside($(t)) |
---|
264 | var p = new Element('div').injectInside($(o)) |
---|
265 | |
---|
266 | this.hiddenInput = new Element('input', { |
---|
267 | 'type' : 'hidden', |
---|
268 | 'name' : this.source.get('name') |
---|
269 | }).inject($(this.options.container), 'before'); |
---|
270 | |
---|
271 | }, |
---|
272 | |
---|
273 | bindEvents : function() { |
---|
274 | document.addEvent('click', function() { |
---|
275 | if ( this.optionsContainer.getStyle('display') == 'block') |
---|
276 | this.onDropDown() |
---|
277 | }.bind(this)); |
---|
278 | |
---|
279 | $(this.options.container).addEvent( 'click', function(e) { new Event(e).stop(); } ) |
---|
280 | this.current.addEvent('click', this.onDropDown.bindWithEvent(this) ) |
---|
281 | |
---|
282 | }, |
---|
283 | |
---|
284 | //add single option to select |
---|
285 | addOption: function( option ){ |
---|
286 | var o = new Element('div').addClass('option').setProperty('value',option.value) |
---|
287 | if ( option.disabled ) { o.addClass('disabled') } else { |
---|
288 | o.addEvents( { |
---|
289 | 'click': this.onOptionClick.bindWithEvent(this), |
---|
290 | 'mouseout': this.onOptionMouseout.bindWithEvent(this), |
---|
291 | 'mouseover': this.onOptionMouseover.bindWithEvent(this) |
---|
292 | }) |
---|
293 | } |
---|
294 | |
---|
295 | if ( $defined(option.getProperty('class')) && $chk(option.getProperty('class')) ) |
---|
296 | o.addClass(option.getProperty('class')) |
---|
297 | |
---|
298 | |
---|
299 | if ( option.selected ) { |
---|
300 | if ( this.selected) this.selected.removeClass('selected'); |
---|
301 | this.selected = o |
---|
302 | o.addClass('selected') |
---|
303 | this.selectedOption.set('text', option.text); |
---|
304 | this.hiddenInput.setProperty('value',option.value); |
---|
305 | } |
---|
306 | o.set('text', option.text); |
---|
307 | o.injectBefore($(this.optionsContainer).getLast()); |
---|
308 | }, |
---|
309 | |
---|
310 | onDropDown : function( e ) { |
---|
311 | |
---|
312 | if ( this.optionsContainer.getStyle('display') == 'block') { |
---|
313 | this.optionsContainer.setStyle('display','none') |
---|
314 | } else { |
---|
315 | this.optionsContainer.setStyle('display','block') |
---|
316 | this.selected.addClass('selected') |
---|
317 | //needed to fix min-width in ie6 |
---|
318 | var width = this.optionsContainer.getStyle('width').toInt() > this._select.getStyle('width').toInt() ? |
---|
319 | this.optionsContainer.getStyle('width') |
---|
320 | : |
---|
321 | this._select.getStyle('width') |
---|
322 | |
---|
323 | this.optionsContainer.setStyle('width', width) |
---|
324 | this.optionsContainer.getFirst().setStyle('width', width) |
---|
325 | this.optionsContainer.getLast().setStyle('width', width) |
---|
326 | } |
---|
327 | }, |
---|
328 | onOptionClick : function(e) { |
---|
329 | var event = new Event(e) |
---|
330 | if ( this.selected != event.target ) { |
---|
331 | this.selected.removeClass('selected') |
---|
332 | event.target.addClass('selected') |
---|
333 | this.selected = event.target |
---|
334 | this.selectedOption.set('text', this.selected.get('text')); |
---|
335 | this.hiddenInput.setProperty('value',this.selected.getProperty('value')); |
---|
336 | this.fireEvent('clicked'); |
---|
337 | } |
---|
338 | this.onDropDown() |
---|
339 | }, |
---|
340 | onOptionMouseover : function(e){ |
---|
341 | var event = new Event(e) |
---|
342 | this.selected.removeClass('selected') |
---|
343 | event.target.addClass('selected') |
---|
344 | }, |
---|
345 | onOptionMouseout : function(e){ |
---|
346 | var event = new Event(e) |
---|
347 | event.target.removeClass('selected') |
---|
348 | } |
---|
349 | |
---|
350 | }); |
---|
351 | elSelect.implement(new Events); |
---|
352 | elSelect.implement(new Options); |
---|