1 var SlideWindowClass = Class.create({
12 widthNormal : '437px',
13 heightNormal : '325px',
21 containerSuffix : '-slide-window-container',
22 configurationWindows : 'div.configuration',
23 configurationProgress: 'div.configuration-progress',
24 contentItems : 'slide-window-element',
25 contentAlternatingItems : 'slide-window-element-alternating',
26 toolsButtonSuffix : '-slide-window-tools',
27 toolbarSuffix : '-slide-window-toolbar'
30 initialize: function(windowId, data) {
32 this.windowId = windowId;
33 this.window = $(this.windowId + this.elements.containerSuffix);
34 this.tools = $(this.windowId + this.elements.toolsButtonSuffix);
36 if(data.hasOwnProperty('showId')) {
37 this.showEl = $(data.showId);
39 alert('slide-window.js - "showId" property does not exists.');
43 if(data.hasOwnProperty('hideId')) {
44 this.hideEl = $(data.hideId);
46 alert('slide-window.js - "hideId" property does not exists.');
50 if(data.hasOwnProperty('fullSizeId')) {
51 this.fullSizeEl = $(data.fullSizeId);
53 alert('slide-window.js - "fullSizeId" property does not exists.');
57 if(data.hasOwnProperty('search')) {
58 this.search = $(data.search);
60 alert('slide-window.js - "search" property does not exists.');
67 setEvents: function() {
68 this.showEl.observe('click', function(){
72 this.hideEl.observe('click', function(){
76 this.fullSizeEl.observe('click', function(){
80 this.search.observe('keyup', function(){
84 this.tools.observe('click', function() {
89 openWindow : function() {
90 this.hideOtherWindows();
91 Effect.toggle(this.window, 'slide', { duration: 0.3, afterFinish : function() {
92 this.normalSizeWindow();
97 closeWindow : function() {
98 Effect.toggle(this.window, 'slide', { duration: 0.3, afterFinish : function() {
104 resetSize : function() {
105 if(this.isConfigurationOpen()) {
106 if(this.isFullSize()) {
107 this.halfSizeWindow();
108 } else if(this.isHalfSize()) {
109 this.normalSizeWindow();
110 } else if (this.isNormalSize()){
111 this.halfSizeWindow();
113 this.normalSizeWindow();
116 if(this.isFullSize()) {
117 this.normalSizeWindow();
118 } else if(this.isHalfSize() || this.isNormalSize()) {
119 this.fullSizeWindow();
124 isNormalSize: function() {
125 return (this.window.getWidth() + 'px' == this.size.widthNormal && this.window.getHeight() + 'px' == this.size.heightNormal);
128 isHalfSize: function() {
129 return (this.window.getWidth() + 'px' == this.size.widthHalf && this.window.getHeight() + 'px' == this.size.heightHalf);
132 isFullSize: function() {
133 return (this.window.getWidth() + 'px' == this.size.widthFull && this.window.getHeight() + 'px' == this.size.heightFull);
136 normalSizeWindow: function() {
137 new Effect.Morph(this.window, {style : 'width: ' + this.size.widthNormal + '; height: ' + this.size.heightNormal + ';', duration : 0.4});
140 halfSizeWindow: function() {
141 new Effect.Morph(this.window, {style : 'width: ' + this.size.widthHalf + '; height: ' + this.size.heightHalf + ';', duration : 0.4});
144 fullSizeWindow: function() {
145 new Effect.Morph(this.window, {style : 'width: ' + this.size.widthFull + '; height: ' + this.size.heightFull + ';', duration : 0.4});
148 hideOtherWindows: function() {
149 $$('.slide-window-container').each(function(el, index) {
152 width : this.size.widthNormal,
153 height : this.size.heightNormal
158 isConfigurationOpen: function() {
160 $$(this.elements.configurationWindows, this.elements.configurationProgress).each(function(el) {
162 if(el.getStyle('display') == 'block') {
170 setSearch: function() {
171 var search_pattern = new RegExp(this.search.value)
172 $$('div[id=' + this.windowId + this.elements.containerSuffix + '] div.' + this.elements.contentItems).each(function(value){
174 if(search_pattern.match(value.childNodes[2].textContent) == false) {
175 value.setStyle({'display' : 'none'});
177 value.setStyle({'display' : ''});
179 }.bind(search_pattern));
181 $$('div[id=' + this.windowId + this.elements.containerSuffix + '] tr.' + this.elements.contentItems + ', div[id=' + this.windowId + this.elements.containerSuffix + '] tr.' + this.elements.contentAlternatingItems).each(function(value){
182 if(search_pattern.match(value.down('div').innerHTML) == false) {
183 value.setStyle({'display' : 'none'});
185 value.setStyle({'display' : ''});
187 }.bind(search_pattern));
190 toggleToolbar: function() {
191 Effect.toggle($(this.windowId + this.elements.toolbarSuffix), 'slide', { duration: 0.2});
195 document.observe("dom:loaded", function() {
196 if(Prototype.Browser.IE || Prototype.Browser.Gecko) {
197 $$('input[type=checkbox], input[type=submit], input[type=radio], a').each(function(el) {
198 el.observe('focus', function() {