1(function ($) { 2 3/** 4 * A progressbar object. Initialized with the given id. Must be inserted into 5 * the DOM afterwards through progressBar.element. 6 * 7 * method is the function which will perform the HTTP request to get the 8 * progress bar state. Either "GET" or "POST". 9 * 10 * e.g. pb = new progressBar('myProgressBar'); 11 * some_element.appendChild(pb.element); 12 */ 13Drupal.progressBar = function (id, updateCallback, method, errorCallback) { 14 var pb = this; 15 this.id = id; 16 this.method = method || 'GET'; 17 this.updateCallback = updateCallback; 18 this.errorCallback = errorCallback; 19 20 // The WAI-ARIA setting aria-live="polite" will announce changes after users 21 // have completed their current activity and not interrupt the screen reader. 22 this.element = $('<div class="progress" aria-live="polite"></div>').attr('id', id); 23 this.element.html('<div class="bar"><div class="filled"></div></div>' + 24 '<div class="percentage"></div>' + 25 '<div class="message"> </div>'); 26}; 27 28/** 29 * Set the percentage and status message for the progressbar. 30 */ 31Drupal.progressBar.prototype.setProgress = function (percentage, message) { 32 if (percentage >= 0 && percentage <= 100) { 33 $('div.filled', this.element).css('width', percentage + '%'); 34 $('div.percentage', this.element).html(percentage + '%'); 35 } 36 $('div.message', this.element).html(message); 37 if (this.updateCallback) { 38 this.updateCallback(percentage, message, this); 39 } 40}; 41 42/** 43 * Start monitoring progress via Ajax. 44 */ 45Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { 46 this.delay = delay; 47 this.uri = uri; 48 this.sendPing(); 49}; 50 51/** 52 * Stop monitoring progress via Ajax. 53 */ 54Drupal.progressBar.prototype.stopMonitoring = function () { 55 clearTimeout(this.timer); 56 // This allows monitoring to be stopped from within the callback. 57 this.uri = null; 58}; 59 60/** 61 * Request progress data from server. 62 */ 63Drupal.progressBar.prototype.sendPing = function () { 64 if (this.timer) { 65 clearTimeout(this.timer); 66 } 67 if (this.uri) { 68 var pb = this; 69 // When doing a post request, you need non-null data. Otherwise a 70 // HTTP 411 or HTTP 406 (with Apache mod_security) error may result. 71 $.ajax({ 72 type: this.method, 73 url: this.uri, 74 data: '', 75 dataType: 'json', 76 success: function (progress) { 77 // Display errors. 78 if (progress.status == 0) { 79 pb.displayError(progress.data); 80 return; 81 } 82 // Update display. 83 pb.setProgress(progress.percentage, progress.message); 84 // Schedule next timer. 85 pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay); 86 }, 87 error: function (xmlhttp) { 88 pb.displayError(Drupal.ajaxError(xmlhttp, pb.uri)); 89 } 90 }); 91 } 92}; 93 94/** 95 * Display errors on the page. 96 */ 97Drupal.progressBar.prototype.displayError = function (string) { 98 var error = $('<div class="messages error"></div>').html(string); 99 $(this.element).before(error).hide(); 100 101 if (this.errorCallback) { 102 this.errorCallback(this); 103 } 104}; 105 106})(jQuery); 107; 108(function($) { 109 110/** 111 * jQuery debugging helper. 112 * 113 * Invented for Dreditor. 114 * 115 * @usage 116 * $.debug(var [, name]); 117 * $variable.debug( [name] ); 118 */ 119jQuery.extend({ 120 debug: function () { 121 // Setup debug storage in global window. We want to look into it. 122 window.debug = window.debug || []; 123 124 args = jQuery.makeArray(arguments); 125 // Determine data source; this is an object for $variable.debug(). 126 // Also determine the identifier to store data with. 127 if (typeof this == 'object') { 128 var name = (args.length ? args[0] : window.debug.length); 129 var data = this; 130 } 131 else { 132 var name = (args.length > 1 ? args.pop() : window.debug.length); 133 var data = args[0]; 134 } 135 // Store data. 136 window.debug[name] = data; 137 // Dump data into Firebug console. 138 if (typeof console != 'undefined') { 139 console.log(name, data); 140 } 141 return this; 142 } 143}); 144// @todo Is this the right way? 145jQuery.fn.debug = jQuery.debug; 146 147})(jQuery); 148; 149(function ($) { 150 Drupal.behaviors.contextBreakpoint = { 151 width: null, 152 height: null, 153 154 breakpointsCookie: 'context_breakpoints', 155 activeBreakpoints: null, 156 157 saveResolutionCookie: false, 158 resolutionCookie: 'context_breakpoint_resolution', 159 160 reloadActive: false, 161 162 // settings 163 settings: null, 164 contexts: null, 165 166 // Whether user is on an admin page. 167 isAdminPage: null, 168 169 arrayDiff: function(a1, a2) { 170 return $(a1).not(a2).get().concat($(a2).not(a1).get()); 171 }, 172 173 preInit: function() { 174 if (!('context_breakpoint' in Drupal.settings)) { 175 return; 176 } 177 178 var config = Drupal.settings.context_breakpoint; 179 180 // Set settings that we need later on. 181 this.settings = config.settings; 182 this.contexts = config.contexts; 183 this.isAdminPage = config.is_admin; 184 185 this.breakpointsInUrl = this.settings.breakpoints_in_url; 186 this.autoReload = this.isReloadEnabled(); 187 188 var cookieFlag = this.checkForCookie(); 189 var flagUrl = this.checkForUrlDiscrepancy(); 190 191 if (flagUrl) { 192 window.location.href = flagUrl; 193 } 194 else if (cookieFlag) { 195 this.doReload(); 196 } 197 }, 198
199 checkForCookie: function() { 200 if ($.cookie(this.breakpointsCookie) === null) { 201 this.saveCookie(this.checkBreakpoints()); 202 return true; 203 } 204 205 return false; 206 }, 207 208 checkForUrlDiscrepancy: function() { 209 if (this.breakpointsInUrl && this.autoReload) { 210 var href = window.location.href; 211 212 var currentCookie = $.cookie(this.breakpointsCookie); 213 214 var pattern = new RegExp('context\-breakpoints\=([^\&\?]+)'); 215 var result = pattern.exec(href); 216 217 var newUrl = null; 218 219 if (result === null) { 220 if (currentCookie === '') { 221 // do nothing, since no context is set anyway 222 } 223 else { 224 var newUrl = href + (href.search(/\?/) === -1 ? '?' : '&') + 'context-breakpoints=' + currentCookie; 225 } 226 } 227 else { 228 if (result[1] !== currentCookie) { 229 if (currentCookie === '') { 230 // Strip out the whole parameter, since we do not need it 231 newUrl = href.replace('&context-breakpoints=' + result[1], ''); 232 newUrl = newUrl.replace('?context-breakpoints=' + result[1], ''); 233 } 234 else { 235 newUrl = href.replace(result[1], currentCookie); 236 } 237 } 238 } 239 240 return newUrl; 241 } 242 243 return false; 244 }, 245 246 attach: function (context, settings) { 247 if (!this.contexts) { 248 // Nothing to do if no contexts available. 249 return; 250 } 251 252 // Do not do anything if reload is already triggered 253 // to prevent messing with the cookie again. 254 if (this.checkForCookieReload) { 255 return; 256 } 257 258 var that = this; 259 260 // Update cookies on each resize. 261 $(window).resize(function() { 262 that.onResize(); 263 }); 264 265 // Check if cookie with resolution should also be saved. 266 this.saveResolutionCookie = this.settings.save_resolution; 267 if (!this.saveResolutionCookie) { 268 // Otherwise, delete if it exists. 269 $.cookie(this.resolutionCookie, '', {'expires': new Date(0)}); 270 } 271 272 // Retrieve active breakpoints from cookie. 273 this.activeBreakpoints = this.getCookieBreakpoints(); 274 275 // Do a first manual cookie update to catch the current state. 276 this.onResize(); 277 }, 278 279 // Set the cookie with screen and browser width + height. 280 // Then check if we need to reload. 281 onResize: function() { 282 // Compute currently active breakpoints. 283 var newActiveBreakpoints = this.checkBreakpoints(); 284 285 // If required, update resolution cookie. 286 if (this.saveResolutionCookie) { 287 $window = $(window); 288 var value = $window.width() + 'x' + $window.height() 289 + '|' + screen.width + 'x' + screen.height; 290 291 $.cookie(this.resolutionCookie, value); 292 } 293 294 // Check if any breakpoint has become active or inactive 295 var diff = this.arrayDiff(this.activeBreakpoints, newActiveBreakpoints); 296 297 if (diff.length) { 298 // Update the cookie. 299 this.saveCookie(newActiveBreakpoints); 300 this.activeBreakpoints = newActiveBreakpoints; 301 302 // If url auto-change is enabled, we have to do it now. 303 var newUrl = this.checkForUrlDiscrepancy(); 304 if (newUrl) { 305 window.location.href = newUrl; 306 } 307 else { 308 // Check if we have to reload. 309 for (var key in diff) { 310 if (this.isReloadEnabled(diff[key])) { 311 this.doReload(); 312 break; 313 } 314 } 315 } 316 } 317 }, 318 319 isReloadEnabled: function(context) { 320 // On admin pages, do not reload. 321 if (this.isAdminPage && this.settings.admin_disable_reload) { 322 return false; 323 } 324 // Check for specific context. 325 else if (context) { 326 return this.contexts[context].autoreload; 327 } 328 // Check if any context has reload enabled. 329 else { 330 var contexts = this.contexts; 331 332 for (var key in contexts) { 333 if (contexts[key].autoreload) { 334 return true; 335 } 336 } 337 338 return false;
339 } 340 }, 341 342 saveCookie: function(activeBreakpoints) { 343 var points = activeBreakpoints.length ? activeBreakpoints.join(',') : 'none'; 344 $.cookie(this.breakpointsCookie, points); 345 }, 346 347 getCookieBreakpoints: function() { 348 var value = $.cookie(this.breakpointsCookie); 349 if (value === 'none') { 350 value = null; 351 } 352 353 var breakpoints = value ? value.split(',') : []; 354 355 return breakpoints; 356 }, 357 358 checkBreakpoints: function(curWidth, curHeight) { 359 var contexts = this.contexts; 360 var $window = $(window); 361 362 var activeBreakpoints = []; 363 364 for (var contextName in contexts) { 365 var context = contexts[contextName]; 366 367 isActive = true; 368 369 for (var key in context.breakpoints) { 370 371 for (var cmd in context.breakpoints[key]) { 372 var value = context.breakpoints[key][cmd]; 373 374 // If the result changes, the condition has changed, so we need 375 // to reload. 376 var deviceCheck = cmd.search('device') !== -1; 377 378 var width = height = null; 379 if (deviceCheck) { 380 width = screen.width; 381 height = screen.height; 382 } 383 else { 384 width = $window.width(); 385 height = $window.height(); 386 } 387 388 var flag = this.checkCondition(cmd, width, height, value); 389 390 if (!flag) { 391 isActive = false; 392 break; 393 } 394 } 395 396 } 397 398 if (isActive) { 399 activeBreakpoints.push(contextName); 400 } 401 } 402 403 return activeBreakpoints; 404 }, 405 406 doReload: function() { 407 window.location.reload(true); 408 409 // FF prevents reload in onRsize event, so we need to do it 410 // in a timeout. See issue #1859058 411 if ('mozilla' in $.browser) { 412 setTimeout(function() { 413 window.location.reload(true); 414 }, 10); 415 } 416 return; 417 }, 418 419 checkCondition: function(condition, width, height, value) { 420 var flag = null; 421 422 switch (condition) { 423 case 'width': 424 case 'device-width': 425 flag = width === value; 426 break; 427 428 case 'min-width': 429 case 'min-device-width': 430 flag = width >= value; 431 break; 432 433 case 'max-width': 434 case 'max-device-width': 435 flag = width <= value; 436 break; 437 438 case 'height': 439 case 'device-height': 440 flag = height === value; 441 break; 442 443 case 'min-height': 444 case 'min-device-height': 445 flag = height >= value; 446 break; 447 448 case 'max-height': 449 case 'max-device-height': 450 flag = height <= value; 451 break; 452 453 case 'aspect-ratio': 454 case 'device-aspect-ratio': 455 flag = width / height === value; 456 break; 457 458 case 'min-aspect-ratio': 459 case 'min-device-aspect-ratio': 460 flag = width / height >= value; 461 break; 462 463 case 'max-aspect-ratio': 464 case 'max-device-aspect-ratio': 465 flag = width / height <= value; 466 break; 467 468 default: 469 break; 470 } 471 472 return flag; 473 } 474 }; 475})(jQuery); 476; 477(function ($) { 478 Drupal.behaviors.geofieldMapInit = { 479 attach: function (context, settings) { 480 481 // Init all maps in Drupal.settings. 482 if (settings.geofield_gmap) { 483 $.each(settings.geofield_gmap, function(mapid, options) { 484 geofield_gmap_initialize({ 485 lat: options.lat, 486 lng: options.lng, 487 zoom: options.zoom, 488 latid: options.latid, 489 lngid: options.lngid, 490 searchid: options.searchid, 491 mapid: options.mapid, 492 widget: options.widget, 493 map_type: options.map_type, 494 confirm_center_marker: options.confirm_center_marker, 495 click_to_place_marker: options.click_to_place_marker, 496 }); 497 }); 498 } 499 500 } 501 }; 502})(jQuery); 503 504var geofield_gmap_geocoder; 505var geofield_gmap_data = []; 506 507// Center the map to the marker location. 508function geofield_gmap_center(mapid) { 509 google.maps.event.trigger(geofield_gmap_data[mapid].map, 'resize'); 510 geofield_gmap_data[mapid].map.setCenter(geofield_gmap_data[mapid].marker.getPosition()); 511} 512 513// Place marker at the current center of the map. 514function geofield_gmap_marker(mapid) { 515 if (geofield_gmap_data[mapid].confirm_center_marker) { 516 if (!window.confirm('Change marker position ?')) return; 517 } 518 519 google.maps.event.trigger(geofield_gmap_data[mapid].map, 'resize'); 520 var position = geofield_gmap_data[mapid].map.getCenter(); 521 geofield_gmap_data[mapid].marker.setPosition(position); 522 geofield_gmap_data[mapid].lat.val(position.lat()); 523 geofield_gmap_data[mapid].lng.val(position.lng()); 524 525 if (geofield_gmap_data[mapid].search) { 526 geofield_gmap_geocoder.geocode({'latLng': position}, function (results, status) { 527 if (status == google.maps.GeocoderStatus.OK) { 528 if (results[0]) { 529 geofield_gmap_data[mapid].search.val(results[0].formatted_address); 530 } 531 } 532 }); 533 } 534} 535 536// Init google map. 537function geofield_gmap_initialize(params) { 538 geofield_gmap_data[params.mapid] = params; 539 jQuery.noConflict(); 540 541 if (!geofield_gmap_geocoder) { 542 geofield_gmap_geocoder = new google.maps.Geocoder(); 543 } 544 545 var location = new google.maps.LatLng(params.lat, params.lng); 546 var options = { 547 zoom: Number(params.zoom), 548 center: location, 549 mapTypeId: google.maps.MapTypeId.SATELLITE, 550 scaleControl: true, 551 zoomControlOptions: { 552 style: google.maps.ZoomControlStyle.LARGE 553 } 554 }; 555 556 switch (params.map_type) { 557 case "ROADMAP": 558 options.mapTypeId = google.maps.MapTypeId.ROADMAP; 559 break; 560 case "SATELLITE": 561 options.mapTypeId = google.maps.MapTypeId.SATELLITE; 562 break; 563 case "HYBRID": 564 options.mapTypeId = google.maps.MapTypeId.HYBRID; 565 break; 566 case "TERRAIN": 567 options.mapTypeId = google.maps.MapTypeId.TERRAIN; 568 break; 569 default: 570 options.mapTypeId = google.maps.MapTypeId.ROADMAP; 571 } 572 573 var map = new google.maps.Map(document.getElementById(params.mapid), options); 574 geofield_gmap_data[params.mapid].map = map; 575 576 // Fix http://code.google.com/p/gmaps-api-issues/issues/detail?id=1448. 577 google.maps.event.addListener(map, "idle", function () { 578 google.maps.event.trigger(map, 'resize'); 579 }); 580 581 // Fix map issue in fieldgroups / vertical tabs 582 // https://www.drupal.org/node/2474867. 583 google.maps.event.addListenerOnce(map, "idle", function () { 584 // Show all map tiles when a map is shown in a vertical tab. 585 jQuery('#' + params.mapid).closest('div.vertical-tabs').find('.vertical-tab-button a').click(function () { 586 google.maps.event.trigger(map, 'resize'); 587 geofield_gmap_center(params.mapid); 588 }); 589 // Show all map tiles when a map is shown in a collapsible fieldset. 590 jQuery('#' + params.mapid).closest('fieldset.collapsible').find('a.fieldset-title').click(function () { 591 google.maps.event.trigger(map, 'resize'); 592 geofield_gmap_center(params.mapid); 593 }); 594 }); 595 596 // Place map marker. 597 var marker = new google.maps.Marker({ 598 map: map, 599 draggable: params.widget 600 }); 601 geofield_gmap_data[params.mapid].marker = marker; 602 marker.setPosition(location); 603 604 if (params.widget && params.latid && params.lngid) { 605 geofield_gmap_data[params.mapid].lat = jQuery("#" + params.latid); 606 geofield_gmap_data[params.mapid].lng = jQuery("#" + params.lngid); 607 if (params.searchid) { 608 geofield_gmap_data[params.mapid].search = jQuery("#" + params.searchid); 609 geofield_gmap_data[params.mapid].search.autocomplete({ 610 // This bit uses the geocoder to fetch address values. 611 source: function (request, response) { 612 geofield_gmap_geocoder.geocode({'address': request.term }, function (results, status) { 613 response(jQuery.map(results, function (item) { 614 return { 615 label: item.formatted_address, 616 value: item.formatted_address, 617 latitude: item.geometry.location.lat(), 618 longitude: item.geometry.location.lng() 619 }; 620 })); 621 }); 622 }, 623 // This bit is executed upon selection of an address. 624 select: function (event, ui) { 625 geofield_gmap_data[params.mapid].lat.val(ui.item.latitude); 626 geofield_gmap_data[params.mapid].lng.val(ui.item.longitude); 627 var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude); 628 marker.setPosition(location); 629 map.setCenter(location); 630 } 631 }); 632 633 // Geocode user input on enter. 634 geofield_gmap_data[params.mapid].search.keydown(function (e) { 635 if (e.which == 13) { 636 var input = geofield_gmap_data[params.mapid].search.val(); 637 // Execute the geocoder 638 geofield_gmap_geocoder.geocode({'address': input }, function (results, status) { 639 if (status == google.maps.GeocoderStatus.OK) { 640 if (results[0]) { 641 // Set the location 642 var location = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); 643 marker.setPosition(location); 644 map.setCenter(location); 645 // Fill the lat/lon fields with the new info 646 geofield_gmap_data[params.mapid].lat.val(marker.getPosition().lat()); 647 geofield_gmap_data[params.mapid].lng.val(marker.getPosition().lng()); 648 } 649 } 650 }); 651 } 652 }); 653 654 // Add listener to marker for reverse geocoding. 655 google.maps.event.addListener(marker, 'drag', function () { 656 geofield_gmap_geocoder.geocode({'latLng': marker.getPosition()}, function (results, status) { 657 if (status == google.maps.GeocoderStatus.OK) { 658 if (results[0]) { 659 geofield_gmap_data[params.mapid].search.val(results[0].formatted_address); 660 geofield_gmap_data[params.mapid].lat.val(marker.getPosition().lat()); 661 geofield_gmap_data[params.mapid].lng.val(marker.getPosition().lng()); 662 } 663 } 664 }); 665 }); 666 } 667 668 if (params.click_to_place_marker) { 669 // Change marker position with mouse click. 670 google.maps.event.addListener(map, 'click', function (event) { 671 var position = new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()); 672 marker.setPosition(position); 673 geofield_gmap_data[params.mapid].lat.val(position.lat()); 674 geofield_gmap_data[params.mapid].lng.val(position.lng()); 675 //google.maps.event.trigger(geofield_gmap_data[params.mapid].map, 'resize'); 676 }); 677 } 678 679 geofield_onchange = function () { 680 var location = new google.maps.LatLng( 681 parseInt(geofield_gmap_data[params.mapid].lat.val()), 682 parseInt(geofield_gmap_data[params.mapid].lng.val())); 683 marker.setPosition(location); 684 map.setCenter(location); 685 }; 686 687 geofield_gmap_data[params.mapid].lat.change(geofield_onchange); 688 geofield_gmap_data[params.mapid].lng.change(geofield_onchange); 689 } 690} 691; 692/** 693 * @file 694 * SimpleAds JS Helper. 695 */ 696 697(function ($) { 698 Drupal.behaviors.simpleads = { 699 attach: function(context) { 700 var ad_type = $('#edit-field-ad-type select[id^=edit-field-ad-type]').val(); 701 var ad_text_format = $('#field-ad-text-add-more-wrapper select[id^=edit-field-ad-text]').val(); 702 _simpelads_switch_form(ad_type, ad_text_format); 703 $('#edit-field-ad-type select[id^=edit-field-ad-type]').change(function(){ 704 ad_type = $(this).val(); 705 _simpelads_switch_form(ad_type, ad_text_format); 706 }); 707 _simpelads_switch_form(ad_type, ad_text_format); 708 $('#field-ad-text-add-more-wrapper select[id^=edit-field-ad-text]').change(function(){ 709 ad_text_format = $(this).val(); 710 _simpelads_switch_form(ad_type, ad_text_format); 711 }); 712 var ad_block_limit = $('form#block-admin-configure #edit-ads-limit').val(); 713 var ad_block_rotation_type = $('form#block-admin-configure #edit-ads-rotation-type').val(); 714 _simpelads_switch_block_settings(ad_block_limit, false); 715 $('form#block-admin-configure #edit-ads-limit').change(function(){ 716 _simpelads_switch_block_settings($(this).val(), false); 717 }); 718 _simpelads_switch_block_settings(ad_block_rotation_type, 'delay'); 719 $('form#block-admin-configure #edit-ads-rotation-type').change(function(){ 720 _simpelads_switch_block_settings($(this).val(), 'delay'); 721 }); 722 } 723 }; 724}(jQuery)); 725 726/** 727 * Show/hide form elements. 728 */ 729function _simpelads_switch_form(ad_type, p1) { 730 (function ($) { 731 el_image = $('form#simpleads-node-form #edit-field-ad-image'); 732 el_url = $('form#simpleads-node-form #edit-field-ad-url'); 733 el_url_target = $('form#simpleads-node-form #edit-field-ad-url-taget'); 734 el_flash = $('form#simpleads-node-form #edit-field-ad-flash'); 735 el_text = $('form#simpleads-node-form #edit-field-ad-text'); 736 if (ad_type == 'graphic') { 737 el_image.show(); 738 el_url.show(); 739 el_url_target.show(); 740 el_flash.hide(); 741 el_text.hide(); 742 } 743 else if (ad_type == 'text') { 744 el_text.show(); 745 el_image.hide(); 746 el_url.hide(); 747 el_flash.hide(); 748 if (p1 == 'plain_text') { 749 el_url.show(); 750 el_url_target.show(); 751 } 752 else { 753 el_url.hide(); 754 el_url_target.hide(); 755 } 756 } 757 else if (ad_type == 'flash') { 758 el_url.show(); 759 el_url_target.show(); 760 el_flash.show(); 761 el_image.hide(); 762 el_text.hide(); 763 } 764 }(jQuery)); 765} 766 767/** 768 * Show/hide block settings. 769 */ 770function _simpelads_switch_block_settings(ad_setting_value, setting) { 771 (function ($) { 772 if (setting == false) { 773 ad_rotation = $('form#block-admin-configure #ads_rotation_settings'); 774 if (ad_setting_value != 1) 775 ad_rotation.show(); 776 else 777 ad_rotation.hide(); 778 } 779 else { 780 if (setting == 'delay') { 781 ad_rotation_delay = $('form#block-admin-configure #ads_rotation_settings .form-item-ads-rotation-delay'); 782 if (ad_setting_value == 0) 783 ad_rotation_delay.hide(); 784 else 785 ad_rotation_delay.show(); 786 } 787 } 788 }(jQuery)); 789} 790 791/** 792 * Ajax call for Ads. 793 * elem - Ad container 794 * tid - term id 795 * num - numer of ads to display 796 * img_loader - image (ad load indicator), should be HTML tag <img src="loader.gif"> 797 */ 798function _simpelads_load(elem, tid, num, img_loader) { 799 (function ($) { 800 basepath = Drupal.settings.basePath; 801 if (tid > 0 && num > 0) { 802 if (img_loader != '') 803 $(elem).html(img_loader); 804 $.get(basepath + '?q=simpleads/load/' + tid + '/' + num, function (data) { 805 $(elem).html(data); 806 }); 807 } 808 }(jQuery)); 809} 810 811/** 812 * jQuery Plugin. 813 * SimpleAds rotator. 814 */ 815(function ($) { 816 $.simpleads_globals = { 817 pos: [] 818 }; 819 $.simpleads_rotator = function(element, options) { 820 this.options = {}; 821 element.data('simpleads_rotator', this); 822 this.init = function (element, options) { 823 this.options = $.extend({}, $.simpleads_rotator.defaultOptions, options); 824 $.simpleads_globals.pos[options.delta] = 0; 825 simpleads_start(element, this.options); 826 }; 827 this.init(element, options); 828 }; 829 830 $.fn.simpleads_rotator = function(options) { 831 return this.each(function(){ 832 (new $.simpleads_rotator($(this), options)); 833 }); 834 } 835 836 function run_rotation(element, options) { 837 elem_id = element.attr('id'); 838 total_ads = $('#' + elem_id + " > div").size(); 839 if ($.simpleads_globals.pos[options.delta] == (total_ads - 1)) { 840 $.simpleads_globals.pos[options.delta] = 0; 841 } 842 else { 843 $.simpleads_globals.pos[options.delta]++; 844 } 845 846 $('#' + elem_id + " div").hide(); 847 var simpleads_elem = $('#' + elem_id + " > div:eq(" + $.simpleads_globals.pos[options.delta] + ")"); 848 849 if (options.rotation_type == 1) { 850 simpleads_elem.show(); 851 } 852 else if (options.rotation_type == 2) { 853 simpleads_elem.fadeIn('fast'); 854 } 855 else { 856 simpleads_elem.show(); 857 } 858 return false;
859 } 860 861 function simpleads_start(element, options) { 862 run_rotation(element, options); 863 setInterval(function(){run_rotation(element, options);}, options.delay); 864 } 865 866 $.simpleads_rotator.defaultOptions = { 867 rotation_type: 1, 868 delay: 5, 869 delta: 0 870 }; 871 872}(jQuery));;
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.