1/** 2 * grid panel class addon to grid gallery 3 */ 4function UGStripPanel() { 5 6 var t = this, g_objThis = jQuery(this); 7 var g_gallery = new UniteGalleryMain(), g_objGallery, g_objWrapper, g_objPanel; 8 var g_functions = new UGFunctions(), g_objStrip = new UGThumbsStrip(), g_panelBase = new UGPanelsBase(); 9 var g_objButtonNext, g_objButtonPrev; 10 11 this.events = { 12 FINISH_MOVE : "gridpanel_move_finish", // called after close or open panel (slide finish). 13 OPEN_PANEL : "open_panel", // called before opening the panel. 14 CLOSE_PANEL : "close_panel" // called before closing the panel. 15 }; 16 17 var g_options = { 18 19 strippanel_vertical_type : false, // true, false - specify if the panel is vertical or horizonatal type 20 21 strippanel_padding_top : 8, // space from top of the panel 22 strippanel_padding_bottom : 8, // space from bottom of the panel 23 24 strippanel_padding_left : 0, // space from left of the panel 25 strippanel_padding_right : 0, // space from right of the panel 26 27 strippanel_enable_buttons : true, // enable buttons from the sides of the panel 28 strippanel_buttons_skin : "", // skin of the buttons, if empty inherit from gallery skin 29 30 strippanel_padding_buttons : 2, // padding between the buttons and the panel 31 32 strippanel_buttons_role : "scroll_strip", // scroll_strip, advance_item - the role of the side buttons 33 34 strippanel_enable_handle : true, // enable grid handle 35 strippanel_handle_align : "top", // top, middle, bottom , left, right, center - close handle tip align on the handle bar according panel orientation 36 strippanel_handle_offset : 0, // offset of handle bar according the valign 37 38 strippanel_handle_skin : "", // skin of the handle, if empty inherit from gallery skin 39 40 strippanel_background_color : "" // background color of the strip wrapper, if not set, it will be taken from the css 41 42 }; 43 44 var g_defaults_vertical = { 45 strip_vertical_type : true, 46 strippanel_padding_left : 8, 47 strippanel_padding_right : 8, 48 strippanel_padding_top : 0, 49 strippanel_padding_bottom : 0 50 }; 51 52 var g_defaults_no_buttons = { 53 strippanel_padding_left : 8, 54 strippanel_padding_right : 8, 55 strippanel_padding_top : 8, 56 strippanel_padding_bottom : 8 57 }; 58 59 var g_temp = { 60 panelType: "strip", 61 panelWidth : 0, 62 panelHeight : 0, 63 isEventsInited : false, 64 isClosed : false, 65 orientation : null, 66 originalPos : null, 67 isFirstRun : true 68 }; 69 70 /** 71 * init the panel 72 */ 73 function initPanel(gallery, customOptions) { 74 g_gallery = gallery; 75 76 g_objGallery = jQuery(g_gallery); 77 78 g_options = jQuery.extend(g_options, customOptions); 79 80 var repeatCustomOptions = false; 81 82 if (g_options.strippanel_vertical_type == true) { 83 g_options = jQuery.extend(g_options, g_defaults_vertical); 84 repeatCustomOptions = true; 85 } 86 87 if (g_options.strippanel_enable_buttons == false) { 88 g_options = jQuery.extend(g_options, g_defaults_no_buttons); 89 repeatCustomOptions = true; 90 } 91 92 if (repeatCustomOptions == true) 93 g_options = jQuery.extend(g_options, customOptions); // do the 94 95 96 // set arrows skin: 97 var galleryOptions = g_gallery.getOptions(); 98 var globalSkin = galleryOptions.gallery_skin; 99 if (g_options.strippanel_buttons_skin == "") 100 g_options.strippanel_buttons_skin = globalSkin; 101 102 g_objWrapper = g_gallery.getElement(); 103 104 //init the base panel object: 105 g_panelBase.init(g_gallery, g_temp, t, g_options, g_objThis); 106 107 //init thumbs strip 108 g_objStrip = new UGThumbsStrip(); 109 g_objStrip.init(g_gallery, g_options); 110 111 } 112 113 114 /** 115 * validate panel before run 116 */ 117 function validatePanelBeforeRun() { 118 119 if (g_options.strippanel_vertical_type == false) { // horizontal 120 // validate 121 if (g_temp.panelWidth == 0) { 122 throw new Error( 123 "Strip panel error: The width not set, please set width"); 124 return (false); 125 } 126 127 } else { // vertical validate 128 129 if (g_temp.panelHeight == 0) { 130 throw new Error( 131 "Strip panel error: The height not set, please set height"); 132 return (false); 133 } 134 135 } 136 137 // validate orientation 138 if (g_temp.orientation == null) { 139 throw new Error( 140 "Wrong orientation, please set panel orientation before run"); 141 return (false); 142 } 143 144 return (true); 145 } 146 147 /** 148 * run the panel 149 */ 150 function runPanel() { 151 152 // validation 153 if (g_temp.isFirstRun == true && validatePanelBeforeRun() == false) 154 return (false); 155 156 g_objStrip.run(); 157 158 setElementsSize(); 159 placeElements(); 160 161 initEvents(); 162 163 g_temp.isFirstRun = false;
164 165 checkSideButtons(); 166 } 167 168 /** 169 * set panel html 170 */ 171 function setPanelHtml(parentContainer) { 172 173 if (!parentContainer) 174 var parentContainer = g_objWrapper; 175 176 // add panel wrapper 177 parentContainer.append("<div class='ug-strip-panel'></div>"); 178 179 g_objPanel = parentContainer.children('.ug-strip-panel'); 180 181 // add arrows: 182 if (g_options.strippanel_enable_buttons == true) { 183 184 var arrowPrevClass = "ug-strip-arrow-left"; 185 var arrowNextClass = "ug-strip-arrow-right"; 186 if (g_options.strippanel_vertical_type == true) { 187 arrowPrevClass = "ug-strip-arrow-up"; 188 arrowNextClass = "ug-strip-arrow-down"; 189 } 190 191 g_objPanel.append("<div class='ug-strip-arrow " + arrowPrevClass 192 + " ug-skin-" + g_options.strippanel_buttons_skin 193 + "'><div class='ug-strip-arrow-tip'></div></div>"); 194 g_objPanel.append("<div class='ug-strip-arrow " + arrowNextClass 195 + " ug-skin-" + g_options.strippanel_buttons_skin 196 + "'><div class='ug-strip-arrow-tip'></div></div>"); 197 198 } 199 200 g_panelBase.setHtml(g_objPanel); 201 202 g_objStrip.setHtml(g_objPanel); 203 204 if (g_options.strippanel_enable_buttons == true) { 205 g_objButtonPrev = g_objPanel.children("." + arrowPrevClass); 206 g_objButtonNext = g_objPanel.children("." + arrowNextClass); 207 } 208 209 setHtmlProperties(); 210 } 211 212 /** 213 * set html properties according the options 214 */ 215 function setHtmlProperties() { 216 217 // set panel background color 218 if (g_options.strippanel_background_color != "") 219 g_objPanel.css("background-color", 220 g_options.strippanel_background_color); 221 222 } 223 224 /** 225 * set elements size horizontal type 226 */ 227 function setElementsSize_hor() { 228 229 // get strip height 230 var stripHeight = g_objStrip.getHeight(); 231 var panelWidth = g_temp.panelWidth; 232 233 // set buttons height 234 if (g_objButtonNext) { 235 g_objButtonPrev.height(stripHeight); 236 g_objButtonNext.height(stripHeight); 237 238 // arrange buttons tip 239 var prevTip = g_objButtonPrev.children(".ug-strip-arrow-tip"); 240 g_functions.placeElement(prevTip, "center", "middle"); 241 242 var nextTip = g_objButtonNext.children(".ug-strip-arrow-tip"); 243 g_functions.placeElement(nextTip, "center", "middle"); 244 } 245 246 // set panel height 247 var panelHeight = stripHeight + g_options.strippanel_padding_top 248 + g_options.strippanel_padding_bottom; 249 250 // set panel size 251 g_objPanel.width(panelWidth); 252 g_objPanel.height(panelHeight); 253 254 g_temp.panelHeight = panelHeight; 255 256 // set strip size 257 var stripWidth = panelWidth - g_options.strippanel_padding_left - g_options.strippanel_padding_right; 258 259 if (g_objButtonNext) { 260 var buttonWidth = g_objButtonNext.outerWidth(); 261 stripWidth = stripWidth - buttonWidth * 2 - g_options.strippanel_padding_buttons * 2; 262 } 263 264 g_objStrip.resize(stripWidth); 265 } 266 267 /** 268 * set elements size vertical type 269 */ 270 function setElementsSize_vert() { 271 272 // get strip width 273 var stripWidth = g_objStrip.getWidth(); 274 var panelHeight = g_temp.panelHeight; 275 276 // set buttons height 277 if (g_objButtonNext) { 278 g_objButtonPrev.width(stripWidth); 279 g_objButtonNext.width(stripWidth); 280 281 // arrange buttons tip 282 var prevTip = g_objButtonPrev.children(".ug-strip-arrow-tip"); 283 g_functions.placeElement(prevTip, "center", "middle"); 284 285 var nextTip = g_objButtonNext.children(".ug-strip-arrow-tip"); 286 g_functions.placeElement(nextTip, "center", "middle"); 287 } 288 289 // set panel width 290 var panelWidth = stripWidth + g_options.strippanel_padding_left 291 + g_options.strippanel_padding_right; 292 293 // set panel size 294 g_objPanel.width(panelWidth); 295 g_objPanel.height(panelHeight); 296 297 g_temp.panelWidth = panelWidth; 298 299 // set strip size 300 var stripHeight = panelHeight - g_options.strippanel_padding_top 301 - g_options.strippanel_padding_bottom; 302 303 if (g_objButtonNext) { 304 var buttonHeight = g_objButtonNext.outerHeight(); 305 stripHeight = stripHeight - buttonHeight * 2 306 - g_options.strippanel_padding_buttons * 2; 307 } 308 309 g_objStrip.resize(stripHeight); 310 } 311 312 /** 313 * set elements size and place the elements 314 */ 315 function setElementsSize() { 316 317 if (g_options.strippanel_vertical_type == false) 318 setElementsSize_hor(); 319 else 320 setElementsSize_vert(); 321 } 322 323 /** 324 * place elements horizontally 325 */ 326 function placeElements_hor() { 327 328 // place buttons 329 if (g_objButtonNext) { 330 g_functions.placeElement(g_objButtonPrev, "left", "top", 331 g_options.strippanel_padding_left, 332 g_options.strippanel_padding_top); 333 g_functions.placeElement(g_objButtonNext, "right", "top", 334 g_options.strippanel_padding_right, 335 g_options.strippanel_padding_top); 336 } 337 338 var stripX = g_options.strippanel_padding_left; 339 if (g_objButtonNext) 340 stripX += g_objButtonNext.outerWidth() 341 + g_options.strippanel_padding_buttons; 342 343 g_objStrip.setPosition(stripX, g_options.strippanel_padding_top); 344 345 } 346
347 /** 348 * place elements vertically 349 */ 350 function placeElements_vert() { 351 352 // place buttons 353 if (g_objButtonNext) { 354 g_functions.placeElement(g_objButtonPrev, "left", "top", 355 g_options.strippanel_padding_left, 356 g_options.strippanel_padding_top); 357 g_functions.placeElement(g_objButtonNext, "left", "bottom", 358 g_options.strippanel_padding_left, 359 g_options.strippanel_padding_bottom); 360 } 361 362 var stripY = g_options.strippanel_padding_top; 363 if (g_objButtonNext) 364 stripY += g_objButtonNext.outerHeight() 365 + g_options.strippanel_padding_buttons; 366 367 g_objStrip.setPosition(g_options.strippanel_padding_left, stripY); 368 } 369 370 /** 371 * place elements 372 */ 373 function placeElements() { 374 375 if (g_options.strippanel_vertical_type == false) 376 placeElements_hor(); 377 else 378 placeElements_vert(); 379 380 g_panelBase.placeElements(); 381 382 } 383 384 385 386 function __________EVENTS___________() { 387 } 388 ; 389 390 /** 391 * on next button click 392 */ 393 function onNextButtonClick(objButton) { 394 395 if (g_functions.isButtonDisabled(objButton)) 396 return (true); 397 398 if (g_options.strippanel_buttons_role == "advance_item") 399 g_gallery.nextItem(); 400 else 401 g_objStrip.scrollForeward(); 402 } 403 404 /** 405 * on previous button click 406 */ 407 function onPrevButtonClick(objButton) { 408 409 if (g_functions.isButtonDisabled(objButton)) 410 return (true); 411 412 if (g_options.strippanel_buttons_role == "advance_item") 413 g_gallery.prevItem(); 414 else 415 g_objStrip.scrollBack(); 416 } 417 418 /** 419 * check buttons if they need to be disabled or not 420 */ 421 function checkSideButtons() { 422 423 if (!g_objButtonNext) 424 return (true); 425 426 // if the strip not movable - disable both buttons 427 if (g_objStrip.isMoveEnabled() == false) { 428 g_functions.disableButton(g_objButtonPrev); 429 g_functions.disableButton(g_objButtonNext); 430 return (true); 431 } 432 433 // check the limits 434 var limits = g_objStrip.getInnerStripLimits(); 435 var pos = g_objStrip.getInnerStripPos(); 436 437 if (pos >= limits.maxPos) { 438 g_functions.disableButton(g_objButtonPrev); 439 } else { 440 g_functions.enableButton(g_objButtonPrev); 441 } 442 443 if (pos <= limits.minPos) 444 g_functions.disableButton(g_objButtonNext); 445 else 446 g_functions.enableButton(g_objButtonNext); 447 448 } 449 450 /** 451 * on strip move event 452 */ 453 function onStripMove() { 454 checkSideButtons(); 455 } 456 457 /** 458 * on item change event, disable or enable buttons according the images 459 * position 460 */ 461 function onItemChange() { 462 463 if (g_gallery.isLastItem()) 464 g_functions.disableButton(g_objButtonNext); 465 else 466 g_functions.enableButton(g_objButtonNext); 467 468 if (g_gallery.isFirstItem()) 469 g_functions.disableButton(g_objButtonPrev); 470 else 471 g_functions.enableButton(g_objButtonPrev); 472 473 } 474 475 476 /** 477 * init panel events 478 */ 479 function initEvents() { 480 481 if (g_temp.isEventsInited == true) 482 return (false); 483 484 g_temp.isEventsInited = true; 485 486 // buttons events 487 if (g_objButtonNext) { 488 489 // add hove class 490 g_functions.addClassOnHover(g_objButtonNext, "ug-button-hover"); 491 g_functions.addClassOnHover(g_objButtonPrev, "ug-button-hover"); 492 493 // add click events 494 g_functions.setButtonOnClick(g_objButtonPrev, onPrevButtonClick); 495 g_functions.setButtonOnClick(g_objButtonNext, onNextButtonClick); 496 497 // add disable / enable buttons on strip move event 498 if (g_options.strippanel_buttons_role != "advance_item") { 499 500 jQuery(g_objStrip).on(g_objStrip.events.STRIP_MOVE, onStripMove); 501 502 jQuery(g_objStrip).on(g_objStrip.events.INNER_SIZE_CHANGE, checkSideButtons); 503 504 g_objGallery.on(g_gallery.events.SIZE_CHANGE, checkSideButtons); 505 506 } else { 507 var galleryOptions = g_gallery.getOptions(); 508 if (galleryOptions.gallery_carousel == false) 509 jQuery(g_gallery).on(g_gallery.events.ITEM_CHANGE, onItemChange); 510 } 511 512 } 513 514 g_panelBase.initEvents(); 515 } 516 517 /** 518 * destroy the strip panel events 519 */ 520 this.destroy = function(){ 521 522 if(g_objButtonNext){ 523 g_functions.destroyButton(g_objButtonNext); 524 g_functions.destroyButton(g_objButtonPrev); 525 jQuery(g_objStrip).off(g_objStrip.events.STRIP_MOVE); 526 jQuery(g_gallery).off(g_gallery.events.ITEM_CHANGE); 527 jQuery(g_gallery).off(g_gallery.events.SIZE_CHANGE); 528 } 529 530 g_panelBase.destroy(); 531 g_objStrip.destroy(); 532 } 533 534 535 /** 536 * get panel orientation 537 */ 538 this.getOrientation = function() { 539 540 return (g_temp.orientation); 541 } 542 543 /** 544 * set panel orientation (left, right, top, bottom) 545 */ 546 this.setOrientation = function(orientation) { 547 548 g_temp.orientation = orientation; 549 } 550 551 552 /** 553 * init the panel 554 */ 555 this.init = function(gallery, customOptions) { 556 initPanel(gallery, customOptions); 557 } 558 559 /** 560 * run the panel 561 */ 562 this.run = function() { 563 runPanel(); 564 } 565 566 /** 567 * place panel html 568 */ 569 this.setHtml = function(parentContainer) { 570 setPanelHtml(parentContainer); 571 } 572 573 /** 574 * get the panel element 575 */ 576 this.getElement = function() { 577 return (g_objPanel); 578 } 579 580 /** 581 * get panel size object 582 */
583 this.getSize = function() { 584 585 var objSize = g_functions.getElementSize(g_objPanel); 586 587 return (objSize); 588 } 589 590 /** 591 * set panel width (for horizonal type) 592 */ 593 this.setWidth = function(width) { 594 595 g_temp.panelWidth = width; 596 597 } 598 599 /** 600 * set panel height (for vertical type) 601 */ 602 this.setHeight = function(height) { 603 604 g_temp.panelHeight = height; 605 606 } 607 608 /** 609 * resize the panel 610 */ 611 this.resize = function(newWidth) { 612 t.setWidth(newWidth); 613 setElementsSize(); 614 placeElements(); 615 } 616 617 this.__________Functions_From_Base_____ = function() {} 618 619 /** 620 * tells if the panel is closed 621 */ 622 this.isPanelClosed = function() { 623 return (g_panelBase.isPanelClosed()); 624 } 625 626 /** 627 * get closed panel destanation 628 */ 629 this.getClosedPanelDest = function() { 630 return g_panelBase.getClosedPanelDest(); 631 } 632 633 /** 634 * open the panel 635 */ 636 this.openPanel = function(noAnimation) { 637 g_panelBase.openPanel(noAnimation); 638 } 639 640 641 /** 642 * close the panel (slide in) 643 */ 644 this.closePanel = function(noAnimation) { 645 g_panelBase.closePanel(noAnimation); 646 } 647 648 /** 649 * set the panel opened state 650 */ 651 this.setOpenedState = function(originalPos) { 652 g_panelBase.setOpenedState(originalPos); 653 } 654 655 /** 656 * set the panel that it's in closed state, and set original pos for opening later 657 */ 658 this.setClosedState = function(originalPos) { 659 g_panelBase.setClosedState(originalPos); 660 } 661 662 /** 663 * set custom thumbs of the strip 664 */ 665 this.setCustomThumbs = function(funcSetHtml){ 666 667 g_objStrip.setCustomThumbs(funcSetHtml); 668 669 } 670 671 /** 672 * set panel disabled at start 673 */ 674 this.setDisabledAtStart = function(timeout){ 675 676 g_panelBase.setDisabledAtStart(timeout); 677 678 } 679 680} 681
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.