PageSourceSearch

https://el7ekaya.com/sites/all/modules/simpleads/simpleads.js?t9tzj9

js el7ekaya.com collected 2026-10-02 21:20:43 UTC 5,299 bytes, 181 lines download raw bytes

1/**
2 * @file
3 * SimpleAds JS Helper.
4 */
5
6(function ($) {
7  Drupal.behaviors.simpleads = {
8    attach: function(context) {
9      var ad_type = $('#edit-field-ad-type select[id^=edit-field-ad-type]').val();
10      var ad_text_format = $('#field-ad-text-add-more-wrapper select[id^=edit-field-ad-text]').val();
11      _simpelads_switch_form(ad_type, ad_text_format);
12      $('#edit-field-ad-type select[id^=edit-field-ad-type]').change(function(){
13        ad_type = $(this).val();
14        _simpelads_switch_form(ad_type, ad_text_format);
15      });
16      _simpelads_switch_form(ad_type, ad_text_format);
17      $('#field-ad-text-add-more-wrapper select[id^=edit-field-ad-text]').change(function(){
18        ad_text_format = $(this).val();
19        _simpelads_switch_form(ad_type, ad_text_format);
20      });
21      var ad_block_limit = $('form#block-admin-configure #edit-ads-limit').val();
22      var ad_block_rotation_type = $('form#block-admin-configure #edit-ads-rotation-type').val();
23      _simpelads_switch_block_settings(ad_block_limit, false);
24      $('form#block-admin-configure #edit-ads-limit').change(function(){
25        _simpelads_switch_block_settings($(this).val(), false);
26      });
27      _simpelads_switch_block_settings(ad_block_rotation_type, 'delay');
28      $('form#block-admin-configure #edit-ads-rotation-type').change(function(){
29        _simpelads_switch_block_settings($(this).val(), 'delay');
30      });
31    }
32  };
33}(jQuery));
34
35/**
36 * Show/hide form elements.
37 */
38function _simpelads_switch_form(ad_type, p1) {
39  (function ($) {
40    el_image = $('form#simpleads-node-form #edit-field-ad-image');
41    el_url = $('form#simpleads-node-form #edit-field-ad-url');
42    el_url_target = $('form#simpleads-node-form #edit-field-ad-url-taget');
43    el_flash = $('form#simpleads-node-form #edit-field-ad-flash');
44    el_text = $('form#simpleads-node-form #edit-field-ad-text');
45    if (ad_type == 'graphic') {
46      el_image.show();
47      el_url.show();
48      el_url_target.show();
49      el_flash.hide();
50      el_text.hide();
51    }
52    else if (ad_type == 'text') {
53      el_text.show();
54      el_image.hide();
55      el_url.hide();
56      el_flash.hide();
57      if (p1 == 'plain_text') {
58        el_url.show();
59        el_url_target.show();
60      }
61      else {
62        el_url.hide();
63        el_url_target.hide();
64      }
65    }
66    else if (ad_type == 'flash') {
67      el_url.show();
68      el_url_target.show();
69      el_flash.show();
70      el_image.hide();
71      el_text.hide();
72    }
73  }(jQuery));
74}
75
76/**
77 * Show/hide block settings.
78 */
79function _simpelads_switch_block_settings(ad_setting_value, setting) {
80  (function ($) {
81    if (setting == false) {
82      ad_rotation = $('form#block-admin-configure #ads_rotation_settings');
83      if (ad_setting_value != 1)
84        ad_rotation.show();
85      else
86        ad_rotation.hide();
87    }
88    else {
89      if (setting == 'delay') {
90        ad_rotation_delay = $('form#block-admin-configure #ads_rotation_settings .form-item-ads-rotation-delay');
91        if (ad_setting_value == 0)
92          ad_rotation_delay.hide();
93        else
94          ad_rotation_delay.show();
95      }
96    }
97  }(jQuery));
98}
99
100/**
101 * Ajax call for Ads.
102 * elem - Ad container
103 * tid  - term id
104 * num - numer of ads to display
105 * img_loader - image (ad load indicator), should be HTML tag <img src="loader.gif">
106 */
107function _simpelads_load(elem, tid, num, img_loader) {
108  (function ($) {
109    basepath = Drupal.settings.basePath;
110    if (tid > 0 && num > 0) {
111      if (img_loader != '')
112        $(elem).html(img_loader);
113      $.get(basepath + '?q=simpleads/load/' + tid + '/' + num, function (data) {
114        $(elem).html(data);
115      });
116    }
117  }(jQuery));
118}
119
120/**
121 * jQuery Plugin.
122 * SimpleAds rotator.
123 */
124(function ($) {
125  $.simpleads_globals = {
126    pos: []
127  };
128  $.simpleads_rotator = function(element, options) {
129    this.options = {};
130    element.data('simpleads_rotator', this);
131    this.init = function (element, options) {
132      this.options = $.extend({}, $.simpleads_rotator.defaultOptions, options);
133      $.simpleads_globals.pos[options.delta] = 0;
134      simpleads_start(element, this.options);
135    };
136    this.init(element, options);
137  };
138
139  $.fn.simpleads_rotator = function(options) {
140    return this.each(function(){
141      (new $.simpleads_rotator($(this), options));
142    });
143  }
144
145  function run_rotation(element, options) {
146    elem_id = element.attr('id');
147    total_ads = $('#' + elem_id + " > div").size();
148    if ($.simpleads_globals.pos[options.delta] == (total_ads - 1)) {
149      $.simpleads_globals.pos[options.delta] = 0;
150    }
151    else {
152      $.simpleads_globals.pos[options.delta]++;
153    }
154
155    $('#' + elem_id + " div").hide();
156    var simpleads_elem = $('#' + elem_id + " > div:eq(" + $.simpleads_globals.pos[options.delta] + ")");
157    
158    if (options.rotation_type == 1) {
159      simpleads_elem.show();
160    }
161    else if (options.rotation_type == 2) {
162      simpleads_elem.fadeIn('fast');
163    }
164    else {
165      simpleads_elem.show();
166    }
167    return false;
168  }
169
170  function simpleads_start(element, options) {
171    run_rotation(element, options); 
172    setInterval(function(){run_rotation(element, options);}, options.delay);
173  }
174
175  $.simpleads_rotator.defaultOptions = {
176    rotation_type: 1,
177    delay: 5,
178    delta: 0
179  };
180
181}(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.