1/******************************************************************** 2 BPCStretchSlider - stretched "resin" slider 3 4 data - initial data 5 active - active element in array 6 count - count of items in slider (0 if unknown) 7 position - position of first element in slider (1 by default) 8 9********************************************************************/ 10function BPCStretchSlider(data, position, count, active) 11{ 12 if (count <= 0 && data) 13 count = data.length; 14 else if (count <= 0 ) 15 return false; 16 this.oSource = new BPCSourse(data, position, count); 17 if (!this.oSource) 18 return false; 19 this.oSource.iForceElementCount = 10; 20 this.active = this.oSource.iFirstNumber; 21 this.params = {'height' : 250, 'width' : 250, 'first_created' : 0, 'last_created' : 0, 'step_size' : 100}; 22 this.events = {}; 23 for (var ii = this.oSource.iFirstNumber; ii < this.oSource.Data.length; ii++) 24 { 25 if (active == this.oSource.Data[ii]['id']) 26 this.active = ii; 27 } 28 this.oSource.OnAfterItemAdd = function() 29 { 30 try 31 { 32 var element_id = arguments[0][1]; 33 var item_data = this.Data[element_id]; 34 var item_id = item_data["id"]; 35 var item = BX('item_' + item_id); 36 if (!item) 37 { 38 var div = BX.create("DIV", {"props" : {"id" : "item_" + item_id}, "attrs" : {"class" : "photo-slider-item"}, 39 "html" : ( 40 '<table class="photo-slider-thumb" cellpadding="0">' + 41 '<tr>' + 42 '<td>' + 43 '<a href="' + item_data['url'] + '">' + 44 this.parentObject.CreateItem(element_id) + 45 '</a>' + 46 '</td>' + 47 '</tr>' + 48 '</table>')}); 49 50 if (element_id < this.iFirstNumber) 51 { 52 var pointer = BX('item_' + this.Data[this.iFirstNumber]["id"]); 53 if (pointer) 54 pointer.parentNode.insertBefore(div, pointer); 55 } 56 else 57 this.parentObject.tape.appendChild(div); 58 59 pos = BX.pos(div); 60 this.parentObject.tape.__int_width += parseInt(pos['width']); 61 if (element_id < this.iFirstNumber) 62 { 63 this.parentObject.tape.style.left = (parseInt(this.parentObject.tape.style.left) - parseInt(pos['width'])) + 'px'; 64 this.parentObject.prev.className = this.parentObject.prev.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 65 } 66 else 67 { 68 this.parentObject.next.className = this.parentObject.next.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 69 } 70 } 71 } 72 catch (e) { } 73 } 74 this.oSource.OnBeforeSendData = function() 75 { 76 arguments[0][1]['package_id'] = this.parentObject.pack_id; 77 return arguments[0][1]; 78 } 79 80 return true; 81} 82 83BPCStretchSlider.prototype = { 84 /** 85 CreateSlider - create slider and set carret to the active item 86 */ 87 CreateSlider: function() 88 { 89 this.checkEvent('OnBeforeSliderCreate'); 90 this.params['first_created'] = this.params['last_created'] = this.oSource.iFirstNumber; 91 for (var item_id = this.oSource.iFirstNumber; item_id < this.oSource.Data.length; item_id++) 92 { 93 this.params['last_created'] = item_id; 94 var res = this.oSource.checkItem(item_id); 95 if (!res || res == 'wait') 96 return res; 97 this.MakeItem(item_id, (this.active == item_id)); 98 } 99 this.checkEvent('OnAfterSliderCreate'); 100 return true; 101 }, 102 103 /** 104 MakeItem create the item 105 item_id - item id 106 number - serial number in slider 107 */ 108 MakeItem: function(item_id, active_id) 109 { 110 this.checkEvent('OnBeforeItemMake', item_id, active_id); 111 this.ShowItem(item_id, active_id); 112 this.checkEvent('OnAfterItemMake', item_id, active_id); 113 }, 114 115 /** 116 ShowItem - show the element, this method have to be redefined in template.php 117 */ 118 ShowItem: function(item_id, active_id) 119 { 120 }, 121 122 /** 123 CreateItem - create dom item 124 Returns: object 125 */ 126 CreateItem: function(item_id) 127 { 128 var koeff = Math.min(this.params['width']/this.oSource.Data[item_id]['width'], this.params['he
128ight']/this.oSource.Data[item_id]['height']); 129 var res = {'width' : this.oSource.Data[item_id]['width'], 'height' : this.oSource.Data[item_id]['height']}; 130 if (koeff < 1) 131 { 132 res['width'] = parseInt(this.oSource.Data[item_id]['width']*koeff); 133 res['height'] = parseInt(this.oSource.Data[item_id]['height']*koeff); 134 } 135 136 var image = new Image(); 137 image.src = this.oSource.Data[item_id]['src']; 138 return '<img id="image_' + item_id + '" border="0" ' + 139 'onload="window[\'_slider_' + this.pack_id + '\'].oSource.Data[this.id.replace(\'image_\', \'\')][\'loaded\'] = true; window[\'_slider_' + this.pack_id + '\'].checkEvent(\'OnAfterItemLoad\', this);" ' + 140 'style="width:' + res['width'] + 'px;height:' + res['height'] + 'px;" ' + 141 'title="' + this.oSource.Data[item_id]['title'] + '" alt="' + this.oSource.Data[item_id]['title'] + '" ' + 142 'src="' + this.oSource.Data[item_id]['src'] + '" />'; 143 }, 144 145 /** 146 GoToNext - go to the next photo 147 Returns: true || false || 'wait' 148 */ 149 GoToNext: function() 150 { 151 var pos_window = BX.pos(this.window); 152 var tape_right_width = parseInt(this.tape.__int_width) + parseInt(this.tape.style.left) - pos_window['width']; 153 154 var leftward = (tape_right_width > this.params['step_size'] ? this.params['step_size'] : tape_right_width); 155 if (leftward > 0) 156 { 157 this.tape.style.left = parseInt(parseInt(this.tape.style.left) - leftward - 5) + 'px'; 158 this.prev.className = this.prev.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 159 } 160 161 if (this.oSource.Data.length <= this.oSource.iCountData && tape_right_width <= this.params['step_size'] * 10) 162 this.oSource.getData(this.oSource.Data.length, true); 163 164 if (tape_right_width > this.params['step_size']) 165 this.next.className = this.next.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 166 else if (this.oSource.busy === true || this.oSource.Data.length < this.oSource.iCountData) 167 this.next.className = this.next.className.replace("-enabled", "-wait").replace("-disabled", "-wait"); 168 else 169 this.next.className = this.next.className.replace("-enabled", "-disabled").replace("-wait", "-disabled"); 170 171 return true; 172 }, 173 174 /** 175 GoToPrev - go to the previous photo 176 Returns: true || false || 'wait' 177 */ 178 GoToPrev: function() 179 { 180 var tape_left_width = parseInt(this.tape.style.left) * (-1); 181 var rightward = (tape_left_width > this.params['step_size'] ? this.params['step_size'] : tape_left_width); 182 183 if (rightward > 0) 184 { 185 this.tape.style.left = parseInt(parseInt(this.tape.style.left) + rightward) + 'px'; 186 var pos_window = BX.pos(this.window); 187 var tape_right_width = parseInt(this.tape.__int_width) + parseInt(this.tape.style.left) - pos_window['width']; 188 if (tape_right_width > 0) 189 this.next.className = this.next.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 190 } 191 192 if (this.oSource.iFirstNumber > 1 && rightward <= this.params['step_size'] * 10) 193 this.oSource.getData(this.oSource.iFirstNumber, false); 194 195 if (tape_left_width > this.params['step_size']) 196 this.prev.className = this.prev.className.replace("-disabled", "-enabled").replace("-wait", "-enabled"); 197 else if (this.oSource.busy === true || this.oSource.iFirstNumber > 1) 198 this.prev.className = this.prev.className.replace("-enabled", "-wait").replace("-disabled", "-wait"); 199 else 200 this.prev.className = this.prev.className.replace("-enabled", "-disabled").replace("-wait", "-disabled"); 201 202 return true; 203 }, 204 205 checkEvent: function() 206 { 207 eventName = arguments[0]; 208 if (this.events[eventName]) { return this.events[eventName](arguments); } 209 if (this[eventName]) {return this[eventName](arguments); } 210 return true; 211 }, 212 213 OnBeforeSliderCreate: function(image) 214 { 215 window['_slider_' + this.pack_id] = this; 216 217 this.prev = BX('prev_' + this.pack_id); 218 this.next = BX('next_' + this.pack_id); 219 this.window = BX('slider_window_' + this.pack_id); 220 this.tape = this.window.firstChild; 221 this.oSource.parentObject = this; 222 this.__leftward = 0; 223 this.__width = 0; 224 this.__active_element_founded = false; 225 226 if (this.window.addEventListener) 227 this.window.addEventListener('DOMMouseScroll', BX.proxy(this.OnMouseWheel, this), false); 228 229 BX.bind(this.window, 'mousewheel', BX.proxy(this.OnMouseWheel, this)); 230 }, 231 232 OnMouseWheel: function(event) 233 { 234 if (!event) 235 event = window.event; 236 237 var wheelDelta = 0; 238 239 if (event.wheelDelta) 240 wheelDelta = event.wheelDelta / 120; 241 else if (event.detail) 242 wheelDelta = -event.detail / 3; 243 BX.PreventDefault(event); 244 var steps = (wheelDelta > 0 ? wheelDelta : wheelDelta * (-1)); 245 for (var ii = 1; ii <= steps; ii++) 246 { 247 if (wheelDelta < 0) 248 this.GoToNext(); 249 else 250 this.GoToPrev(); 251 } 252 }, 253 254 OnAfterSliderCreate: function() 255 { 256 this.tape.style.left = (this.__leftward > 0 ? ('-' + this.__leftward + 'px') : '0px'); 257 this.tape.__int_width = this.__width; 258 259 delete this.__leftward; 260 delete this.__width; 261 delete this.__active_element_founded; 262 263 BX.bind(this.next, 'click', BX.proxy(this.GoToNext, this)); 264 BX.bind(this.prev, 'click', BX.proxy(this.GoToPrev, this)); 265 }, 266 267 OnAfterItemMake: function() 268 { 269 arguments = arguments[0]; 270 var item_id = arguments[1]; 271 var is_active = (arguments[2] === false || arguments[2] === true ? arguments[2] : (arguments[2] === 'false' ? false : (arguments[2] === 'true' ? true : null))); 272 273 var item = BX('item_' + this.oSource.Data[item_id]['id']); 274 var pos = BX.pos(item); 275 276 this.__width += parseInt(pos['width']); 277 if (!this.__active_element_founded && (is_active === false || is_active === true)) 278 { 279 if (is_active === false) 280 { 281 this.__leftward += parseInt(pos['width']); 282 } 283 else 284 {
285 this.__active_element_founded = true; 286 } 287 } 288 } 289}; 290window.bPhotoSliderStretchLoad = true;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.