Q2W3 Fixed Widget - Version 5.0.2

Version Description

  • Plugin javascript optimization
  • To resolve "q2w3_sidebar_options is not defined" error wp_add_inline_script function is used. WordPress 4.5 required for this fix!
  • Added option Disable MutationObserver. Use this option only as a backup to restore version 4 behavior!
Download this release

Release Info

Developer Max Bond
Plugin Icon 128x128 Q2W3 Fixed Widget
Version 5.0.2
Comparing to
See all releases

Code changes from version 5.0.1 to 5.0.2

js/q2w3-fixed-widget.js CHANGED
@@ -1,56 +1,76 @@
1
- if ( q2w3_sidebar_options && q2w3_sidebar_options.length > 0 ) {
2
  if ( window.jQuery ) {
3
- var q2w3Refresh = false;
4
- for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
5
- if ( q2w3_sidebar_options[i].window_load_hook ) {
6
- var init = 'jQuery(window).load(function(){q2w3_sidebar_init(q2w3_sidebar_options[' + i + '])});';
7
- } else {
8
- var init = 'jQuery(document).ready(function(){q2w3_sidebar_init(q2w3_sidebar_options[' + i + '])});';
9
- }
10
- eval(init);
11
  }
12
  } else {
13
  console.log('jQuery is not loaded!');
14
  }
 
 
15
  }
16
 
17
- function q2w3_sidebar_init(options) {
18
- q2w3_sidebar(options);
19
- jQuery(window).on('resize', function(){q2w3_sidebar(options)});
 
 
 
 
 
 
20
  var MutationObserver = (function(){
21
  var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
22
- for ( var i=0; i < prefixes.length; i++ ) {
23
  if ( prefixes[i] + 'MutationObserver' in window ) {
24
  return window[prefixes[i] + 'MutationObserver'];
25
  }
26
  }
27
  return false;
28
  }());
29
- if ( MutationObserver ) {
 
30
  var htmlObserver = new MutationObserver(function(mutations) {
31
- q2w3Refresh = false
32
  mutations.forEach( function(mutation) {
33
- if ( q2w3_exclude_mutations_array(options.widgets).indexOf(mutation.target.id) == -1 && mutation.target.className.indexOf('q2w3-fixed-widget-container') == -1 ) {
34
  q2w3Refresh = true;
 
35
  }
36
  });
37
  });
38
  htmlObserver.observe(document.body, {childList: true, attributes: true, attributeFilter:['style', 'class'], subtree: true});
39
  setInterval(function(){
40
- if ( q2w3Refresh ) { q2w3_sidebar(options); q2w3Refresh = false; } // console.log('Q2W3 counter:' + i++);
41
- }, 1000);
 
 
 
 
 
42
  } else {
43
- console.log('MutationObserver not supported!');
44
- if ( options.refresh_interval > 0 ) setInterval(function(){q2w3_sidebar(options)}, options.refresh_interval);
 
 
 
 
 
 
45
  }
46
  }
47
 
48
- function q2w3_exclude_mutations_array(widgets) {
49
  var out = new Array();
50
- for ( var i = 0; i < widgets.length; i++ ) {
51
- out.push(widgets[i]);
52
- out.push(widgets[i] + '_clone');
53
- }
 
 
 
 
54
  return out;
55
  }
56
 
@@ -64,6 +84,8 @@ function q2w3_sidebar(options) {
64
 
65
  if ( !options.sidebar) options.sidebar = 'q2w3-default-sidebar';
66
 
 
 
67
  function widget() {} // widget class
68
 
69
  var widgets = new Array();
@@ -72,9 +94,9 @@ function q2w3_sidebar(options) {
72
  var document_height = jQuery(document).height();
73
  var fixed_margin_top = options.margin_top;
74
 
75
- if ( jQuery('#wpadminbar').is(':visible') ) { // WordPress admin bar
76
  fixed_margin_top = options.margin_top + jQuery('#wpadminbar').height();
77
- }
78
 
79
  jQuery('.q2w3-widget-clone-' + options.sidebar).remove(); // clear fixed mode p1
80
 
@@ -119,7 +141,7 @@ function q2w3_sidebar(options) {
119
  }
120
  }
121
 
122
- jQuery(window).off('load.' + options.sidebar + ' scroll.' + options.sidebar); //+ ' resize.' + options.sidebar
123
 
124
  for ( var i = 0; i < widgets.length; i++ ) {
125
  if (widgets[i]) fixed_widget(widgets[i]);
@@ -127,9 +149,11 @@ function q2w3_sidebar(options) {
127
 
128
  function fixed_widget(widget) {
129
 
 
 
130
  var trigger_top = widget.offset_top - widget.fixed_margin_top;
131
  var trigger_bottom = document_height - options.margin_bottom;
132
-
133
  if ( options.stop_id && jQuery('#' + options.stop_id).length ) {
134
  trigger_bottom = jQuery('#' + options.stop_id).offset().top - options.margin_bottom;
135
  }
1
+ if ( typeof q2w3_sidebar_options != 'undefined' && q2w3_sidebar_options.length > 0 ) {
2
  if ( window.jQuery ) {
3
+ if ( q2w3_sidebar_options[0].window_load_hook ) {
4
+ jQuery(window).load(q2w3_sidebar_init());
5
+ } else {
6
+ jQuery(document).ready(q2w3_sidebar_init());
 
 
 
 
7
  }
8
  } else {
9
  console.log('jQuery is not loaded!');
10
  }
11
+ } else {
12
+ console.log('q2w3_sidebar_options not found!');
13
  }
14
 
15
+ function q2w3_sidebar_init() {
16
+ for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
17
+ q2w3_sidebar(q2w3_sidebar_options[i]);
18
+ }
19
+ jQuery(window).on('resize', function(){
20
+ for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
21
+ q2w3_sidebar(q2w3_sidebar_options[i]);
22
+ }
23
+ });
24
  var MutationObserver = (function(){
25
  var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
26
+ for ( var i = 0; i < prefixes.length; i++ ) {
27
  if ( prefixes[i] + 'MutationObserver' in window ) {
28
  return window[prefixes[i] + 'MutationObserver'];
29
  }
30
  }
31
  return false;
32
  }());
33
+ if ( q2w3_sidebar_options[0].disable_mo_api == false && MutationObserver ) {
34
+ q2w3Refresh = false
35
  var htmlObserver = new MutationObserver(function(mutations) {
 
36
  mutations.forEach( function(mutation) {
37
+ if ( q2w3_exclude_mutations_array(q2w3_sidebar_options).indexOf(mutation.target.id) == -1 && mutation.target.className.indexOf('q2w3-fixed-widget-container') == -1 ) {
38
  q2w3Refresh = true;
39
+ //console.log('Mutation detected!');
40
  }
41
  });
42
  });
43
  htmlObserver.observe(document.body, {childList: true, attributes: true, attributeFilter:['style', 'class'], subtree: true});
44
  setInterval(function(){
45
+ if ( q2w3Refresh ) {
46
+ for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
47
+ q2w3_sidebar(q2w3_sidebar_options[i]);
48
+ }
49
+ q2w3Refresh = false;
50
+ }
51
+ }, 300);
52
  } else {
53
+ console.log('MutationObserver not supported or disabled!');
54
+ if ( q2w3_sidebar_options[0].refresh_interval > 0 ) {
55
+ setInterval(function(){
56
+ for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
57
+ q2w3_sidebar(q2w3_sidebar_options[i]);
58
+ }
59
+ }, q2w3_sidebar_options[0].refresh_interval);
60
+ }
61
  }
62
  }
63
 
64
+ function q2w3_exclude_mutations_array(q2w3_sidebar_options) {
65
  var out = new Array();
66
+ for ( var i = 0; i < q2w3_sidebar_options.length; i++ ) {
67
+ if ( q2w3_sidebar_options[i].widgets.length > 0 ) {
68
+ for ( var k = 0; k < q2w3_sidebar_options[i].widgets.length; k++ ) {
69
+ out.push(q2w3_sidebar_options[i].widgets[k]);
70
+ out.push(q2w3_sidebar_options[i].widgets[k] + '_clone');
71
+ }
72
+ }
73
+ }
74
  return out;
75
  }
76
 
84
 
85
  if ( !options.sidebar) options.sidebar = 'q2w3-default-sidebar';
86
 
87
+ //console.log(options.sidebar + ' call');
88
+
89
  function widget() {} // widget class
90
 
91
  var widgets = new Array();
94
  var document_height = jQuery(document).height();
95
  var fixed_margin_top = options.margin_top;
96
 
97
+ if ( jQuery('#wpadminbar').length ) { // WordPress admin bar
98
  fixed_margin_top = options.margin_top + jQuery('#wpadminbar').height();
99
+ }
100
 
101
  jQuery('.q2w3-widget-clone-' + options.sidebar).remove(); // clear fixed mode p1
102
 
141
  }
142
  }
143
 
144
+ jQuery(window).off('scroll.' + options.sidebar);
145
 
146
  for ( var i = 0; i < widgets.length; i++ ) {
147
  if (widgets[i]) fixed_widget(widgets[i]);
149
 
150
  function fixed_widget(widget) {
151
 
152
+ //console.log('fixed_widget call: ' + widget.obj.attr('id'));
153
+
154
  var trigger_top = widget.offset_top - widget.fixed_margin_top;
155
  var trigger_bottom = document_height - options.margin_bottom;
156
+
157
  if ( options.stop_id && jQuery('#' + options.stop_id).length ) {
158
  trigger_bottom = jQuery('#' + options.stop_id).offset().top - options.margin_bottom;
159
  }
js/q2w3-fixed-widget.min.js CHANGED
@@ -1 +1 @@
1
- function q2w3_sidebar_init(a){q2w3_sidebar(a),jQuery(window).on("resize",function(){q2w3_sidebar(a)});var b=function(){for(var a=["WebKit","Moz","O","Ms",""],b=0;b<a.length;b++)if(a[b]+"MutationObserver"in window)return window[a[b]+"MutationObserver"];return!1}();if(b){var c=new b(function(b){q2w3Refresh=!1,b.forEach(function(b){q2w3_exclude_mutations_array(a.widgets).indexOf(b.target.id)==-1&&b.target.className.indexOf("q2w3-fixed-widget-container")==-1&&(q2w3Refresh=!0)})});c.observe(document.body,{childList:!0,attributes:!0,attributeFilter:["style","class"],subtree:!0}),setInterval(function(){q2w3Refresh&&(q2w3_sidebar(a),q2w3Refresh=!1)},1e3)}else console.log("MutationObserver not supported!"),a.refresh_interval>0&&setInterval(function(){q2w3_sidebar(a)},a.refresh_interval)}function q2w3_exclude_mutations_array(a){for(var b=new Array,c=0;c<a.length;c++)b.push(a[c]),b.push(a[c]+"_clone");return b}function q2w3_sidebar(a){function b(){}function j(b){var c=b.offset_top-b.fixed_margin_top,f=e-a.margin_bottom;a.stop_id&&jQuery("#"+a.stop_id).length&&(f=jQuery("#"+a.stop_id).offset().top-a.margin_bottom);var g;g=a.width_inherit?"inherit":b.obj.css("width");var h=!1,i=!1,j=!1;jQuery(window).on("scroll."+a.sidebar,function(e){if(jQuery(window).width()<=a.screen_max_width||jQuery(window).height()<=a.screen_max_height)j||(b.obj.css("position",""),b.obj.css("top",""),b.obj.css("bottom",""),b.obj.css("width",""),b.obj.css("margin",""),b.obj.css("padding",""),widget_obj.parent().css("height",""),jQuery("#"+b.clone_id).length>0&&jQuery("#"+b.clone_id).remove(),j=!0,h=!1,i=!1);else{var k=jQuery(this).scrollTop();k+b.fixed_margin_bottom>=f?(i||(b.obj.css("position","fixed"),b.obj.css("top",""),b.obj.css("width",g),jQuery("#"+b.clone_id).length<=0&&b.obj.before(b.clone),i=!0,h=!1,j=!1),b.obj.css("bottom",k+d+b.next_widgets_height-f)):k>=c?h||(b.obj.css("position","fixed"),b.obj.css("top",b.fixed_margin_top),b.obj.css("bottom",""),b.obj.css("width",g),jQuery("#"+b.clone_id).length<=0&&b.obj.before(b.clone),h=!0,i=!1,j=!1):j||(b.obj.css("position",""),b.obj.css("top",""),b.obj.css("bottom",""),b.obj.css("width",""),jQuery("#"+b.clone_id).length>0&&jQuery("#"+b.clone_id).remove(),j=!0,h=!1,i=!1)}}).trigger("scroll."+a.sidebar)}if(!a)return!1;if(!a.widgets)return!1;if(a.widgets.length<1)return!1;a.sidebar||(a.sidebar="q2w3-default-sidebar");var c=new Array,d=jQuery(window).height(),e=jQuery(document).height(),f=a.margin_top;jQuery("#wpadminbar").is(":visible")&&(f=a.margin_top+jQuery("#wpadminbar").height()),jQuery(".q2w3-widget-clone-"+a.sidebar).remove();for(var g=0;g<a.widgets.length;g++)widget_obj=jQuery("#"+a.widgets[g]),widget_obj.css("position",""),widget_obj.attr("id")?(c[g]=new b,c[g].obj=widget_obj,c[g].clone=widget_obj.clone(),c[g].clone.children().remove(),c[g].clone_id=widget_obj.attr("id")+"_clone",c[g].clone.addClass("q2w3-widget-clone-"+a.sidebar),c[g].clone.attr("id",c[g].clone_id),c[g].clone.css("height",widget_obj.height()),c[g].clone.css("visibility","hidden"),c[g].offset_top=widget_obj.offset().top,c[g].fixed_margin_top=f,c[g].height=widget_obj.outerHeight(!0),c[g].fixed_margin_bottom=f+c[g].height,f+=c[g].height):c[g]=!1;for(var i,h=0,g=c.length-1;g>=0;g--)c[g]&&(c[g].next_widgets_height=h,c[g].fixed_margin_bottom+=h,h+=c[g].height,i||(i=widget_obj.parent(),i.addClass("q2w3-fixed-widget-container"),i.css("height",""),i.height(i.height())));jQuery(window).off("load."+a.sidebar+" scroll."+a.sidebar);for(var g=0;g<c.length;g++)c[g]&&j(c[g])}if(q2w3_sidebar_options&&q2w3_sidebar_options.length>0)if(window.jQuery)for(var q2w3Refresh=!1,i=0;i<q2w3_sidebar_options.length;i++){if(q2w3_sidebar_options[i].window_load_hook)var init="jQuery(window).load(function(){q2w3_sidebar_init(q2w3_sidebar_options["+i+"])});";else var init="jQuery(document).ready(function(){q2w3_sidebar_init(q2w3_sidebar_options["+i+"])});";eval(init)}else console.log("jQuery is not loaded!");
1
+ function q2w3_sidebar_init(){for(var a=0;a<q2w3_sidebar_options.length;a++)q2w3_sidebar(q2w3_sidebar_options[a]);jQuery(window).on("resize",function(){for(var a=0;a<q2w3_sidebar_options.length;a++)q2w3_sidebar(q2w3_sidebar_options[a])});var b=function(){for(var a=["WebKit","Moz","O","Ms",""],b=0;b<a.length;b++)if(a[b]+"MutationObserver"in window)return window[a[b]+"MutationObserver"];return!1}();if(0==q2w3_sidebar_options[0].disable_mo_api&&b){q2w3Refresh=!1;var c=new b(function(a){a.forEach(function(a){q2w3_exclude_mutations_array(q2w3_sidebar_options).indexOf(a.target.id)==-1&&a.target.className.indexOf("q2w3-fixed-widget-container")==-1&&(q2w3Refresh=!0)})});c.observe(document.body,{childList:!0,attributes:!0,attributeFilter:["style","class"],subtree:!0}),setInterval(function(){if(q2w3Refresh){for(var a=0;a<q2w3_sidebar_options.length;a++)q2w3_sidebar(q2w3_sidebar_options[a]);q2w3Refresh=!1}},300)}else console.log("MutationObserver not supported or disabled!"),q2w3_sidebar_options[0].refresh_interval>0&&setInterval(function(){for(var a=0;a<q2w3_sidebar_options.length;a++)q2w3_sidebar(q2w3_sidebar_options[a])},q2w3_sidebar_options[0].refresh_interval)}function q2w3_exclude_mutations_array(a){for(var b=new Array,c=0;c<a.length;c++)if(a[c].widgets.length>0)for(var d=0;d<a[c].widgets.length;d++)b.push(a[c].widgets[d]),b.push(a[c].widgets[d]+"_clone");return b}function q2w3_sidebar(a){function b(){}function j(b){var c=b.offset_top-b.fixed_margin_top,f=e-a.margin_bottom;a.stop_id&&jQuery("#"+a.stop_id).length&&(f=jQuery("#"+a.stop_id).offset().top-a.margin_bottom);var g;g=a.width_inherit?"inherit":b.obj.css("width");var h=!1,i=!1,j=!1;jQuery(window).on("scroll."+a.sidebar,function(e){if(jQuery(window).width()<=a.screen_max_width||jQuery(window).height()<=a.screen_max_height)j||(b.obj.css("position",""),b.obj.css("top",""),b.obj.css("bottom",""),b.obj.css("width",""),b.obj.css("margin",""),b.obj.css("padding",""),widget_obj.parent().css("height",""),jQuery("#"+b.clone_id).length>0&&jQuery("#"+b.clone_id).remove(),j=!0,h=!1,i=!1);else{var k=jQuery(this).scrollTop();k+b.fixed_margin_bottom>=f?(i||(b.obj.css("position","fixed"),b.obj.css("top",""),b.obj.css("width",g),jQuery("#"+b.clone_id).length<=0&&b.obj.before(b.clone),i=!0,h=!1,j=!1),b.obj.css("bottom",k+d+b.next_widgets_height-f)):k>=c?h||(b.obj.css("position","fixed"),b.obj.css("top",b.fixed_margin_top),b.obj.css("bottom",""),b.obj.css("width",g),jQuery("#"+b.clone_id).length<=0&&b.obj.before(b.clone),h=!0,i=!1,j=!1):j||(b.obj.css("position",""),b.obj.css("top",""),b.obj.css("bottom",""),b.obj.css("width",""),jQuery("#"+b.clone_id).length>0&&jQuery("#"+b.clone_id).remove(),j=!0,h=!1,i=!1)}}).trigger("scroll."+a.sidebar)}if(!a)return!1;if(!a.widgets)return!1;if(a.widgets.length<1)return!1;a.sidebar||(a.sidebar="q2w3-default-sidebar");var c=new Array,d=jQuery(window).height(),e=jQuery(document).height(),f=a.margin_top;jQuery("#wpadminbar").length&&(f=a.margin_top+jQuery("#wpadminbar").height()),jQuery(".q2w3-widget-clone-"+a.sidebar).remove();for(var g=0;g<a.widgets.length;g++)widget_obj=jQuery("#"+a.widgets[g]),widget_obj.css("position",""),widget_obj.attr("id")?(c[g]=new b,c[g].obj=widget_obj,c[g].clone=widget_obj.clone(),c[g].clone.children().remove(),c[g].clone_id=widget_obj.attr("id")+"_clone",c[g].clone.addClass("q2w3-widget-clone-"+a.sidebar),c[g].clone.attr("id",c[g].clone_id),c[g].clone.css("height",widget_obj.height()),c[g].clone.css("visibility","hidden"),c[g].offset_top=widget_obj.offset().top,c[g].fixed_margin_top=f,c[g].height=widget_obj.outerHeight(!0),c[g].fixed_margin_bottom=f+c[g].height,f+=c[g].height):c[g]=!1;for(var i,h=0,g=c.length-1;g>=0;g--)c[g]&&(c[g].next_widgets_height=h,c[g].fixed_margin_bottom+=h,h+=c[g].height,i||(i=widget_obj.parent(),i.addClass("q2w3-fixed-widget-container"),i.css("height",""),i.height(i.height())));jQuery(window).off("scroll."+a.sidebar);for(var g=0;g<c.length;g++)c[g]&&j(c[g])}"undefined"!=typeof q2w3_sidebar_options&&q2w3_sidebar_options.length>0?window.jQuery?q2w3_sidebar_options[0].window_load_hook?jQuery(window).load(q2w3_sidebar_init()):jQuery(document).ready(q2w3_sidebar_init()):console.log("jQuery is not loaded!"):console.log("q2w3_sidebar_options not found!");
lang/q2w3-fixed-widget-ru_RU.mo CHANGED
Binary file
lang/q2w3-fixed-widget-ru_RU.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Q2W3 Fixed Widget\n"
4
- "POT-Creation-Date: 2016-09-07 14:49+0300\n"
5
- "PO-Revision-Date: 2016-09-07 14:55+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: ru_RU\n"
@@ -14,60 +14,68 @@ msgstr ""
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
- #: q2w3-fixed-widget.php:173
18
  msgid "Fixed widget"
19
  msgstr "Зафиксировать виджет"
20
 
21
- #: q2w3-fixed-widget.php:207 q2w3-fixed-widget.php:307
22
  msgid "Fixed Widget Options"
23
  msgstr "Фикс. Виджеты"
24
 
25
- #: q2w3-fixed-widget.php:295
26
  msgid "General Options"
27
  msgstr "Основные настройки"
28
 
29
- #: q2w3-fixed-widget.php:297
30
  msgid "Compatibility"
31
  msgstr "Совместимость"
32
 
33
- #: q2w3-fixed-widget.php:299
34
  msgid "Custom IDs"
35
  msgstr "Произвольные идентификаторы"
36
 
37
- #: q2w3-fixed-widget.php:301
38
  msgid "Help for users"
39
  msgstr "Помощь пользователям"
40
 
41
- #: q2w3-fixed-widget.php:303
42
  msgid "Help for developer"
43
  msgstr "Помощь разработчику"
44
 
45
- #: q2w3-fixed-widget.php:311
46
  msgid "Settings saved."
47
  msgstr "Настройки сохранены."
48
 
49
- #: q2w3-fixed-widget.php:337
 
 
 
 
 
 
 
 
50
  msgid "Save Changes"
51
  msgstr "Сохранить"
52
 
53
- #: q2w3-fixed-widget.php:351
54
  msgid "Margin Top:"
55
  msgstr "Верхний отступ:"
56
 
57
- #: q2w3-fixed-widget.php:351 q2w3-fixed-widget.php:353
58
  #: q2w3-fixed-widget.php:359 q2w3-fixed-widget.php:361
 
59
  msgid "px"
60
  msgstr "пикс."
61
 
62
- #: q2w3-fixed-widget.php:353
63
  msgid "Margin Bottom:"
64
  msgstr "Нижний отступ:"
65
 
66
- #: q2w3-fixed-widget.php:355
67
  msgid "Stop ID:"
68
  msgstr "Стоп ID:"
69
 
70
- #: q2w3-fixed-widget.php:355
71
  msgid ""
72
  "Here you need to provide html tag id. The position of that html element will "
73
  "determine margin bottom value."
@@ -75,15 +83,15 @@ msgstr ""
75
  "Здесь необходимо ввести id html-элемента. Позиция этого html-элемента будет "
76
  "динамически определять значение нижнего отступа."
77
 
78
- #: q2w3-fixed-widget.php:357
79
  msgid "Refresh interval:"
80
  msgstr "Интервал обновления:"
81
 
82
- #: q2w3-fixed-widget.php:357
83
  msgid "milliseconds"
84
  msgstr "миллисекунды"
85
 
86
- #: q2w3-fixed-widget.php:357
87
  msgid ""
88
  "Used only for compatibility with browsers without MutationObserver API "
89
  "support! Set 0 to completely disable."
@@ -91,11 +99,11 @@ msgstr ""
91
  "Используется только для совместимости с браузерами не поддерживающими "
92
  "MutationObserver API"
93
 
94
- #: q2w3-fixed-widget.php:359
95
  msgid "Disable Width:"
96
  msgstr "Ширина отключения:"
97
 
98
- #: q2w3-fixed-widget.php:359
99
  msgid ""
100
  "Use this option to disable plugin on portable devices. When the browser "
101
  "screen width is less then specified value, the plugin is disabled!"
@@ -104,68 +112,80 @@ msgstr ""
104
  "ширина окна браузера меньше или равна указанной величине, плагин будет "
105
  "отключен!"
106
 
107
- #: q2w3-fixed-widget.php:361
108
  msgid "Disable Height:"
109
  msgstr "Высота отключения:"
110
 
111
- #: q2w3-fixed-widget.php:361
112
  msgid "Works the same way as Disable Width option."
113
  msgstr "Работает аналогично опции \"Ширина отключения\""
114
 
115
- #: q2w3-fixed-widget.php:367
116
  msgid "Custom HTML IDs (each one on a new line):"
117
  msgstr ""
118
  "HTML-идентификаторы статических виджетов и прочих нестандартных элементов "
119
  "(каждый на новой строке):"
120
 
121
- #: q2w3-fixed-widget.php:373
122
  msgid "Auto fix widget id:"
123
  msgstr "Автоматически исправлять id виджетов:"
124
 
125
- #: q2w3-fixed-widget.php:375
 
 
 
 
 
 
 
 
 
 
 
 
126
  msgid "Enable plugin for logged in users only:"
127
  msgstr "Только зарегистрированные пользователи:"
128
 
129
- #: q2w3-fixed-widget.php:375
130
  msgid "Enable this option for debug purposes (frontend problems and etc.)"
131
  msgstr "Используйте для отладки стилей, скриптов"
132
 
133
- #: q2w3-fixed-widget.php:377
134
  msgid "Inherit widget width from the parent container:"
135
  msgstr "Наследовать ширину родительского контейнера:"
136
 
137
- #: q2w3-fixed-widget.php:377
138
  msgid "Enable this option for themes with responsive sidebar"
139
  msgstr ""
140
  "Задействуйте эту опцию, если ширина сайдбара вашей темы меняется динамически"
141
 
142
- #: q2w3-fixed-widget.php:379
143
  msgid "Use jQuery(window).load() hook:"
144
  msgstr "Вкл. jQuery(window).load():"
145
 
146
- #: q2w3-fixed-widget.php:379
147
  msgid ""
148
  "Enable this option only if you have problems with other scroll oriented "
149
  "javascript code"
150
  msgstr "Задействуйте эту опцию в случае проблем с другими скриптами"
151
 
152
- #: q2w3-fixed-widget.php:381
153
  msgid "widget_display_callback hook priority:"
154
  msgstr "Приоритет хука widget_display_callback:"
155
 
156
- #: q2w3-fixed-widget.php:387
157
  msgid "Support forums:"
158
  msgstr "Форумы поддержки:"
159
 
160
- #: q2w3-fixed-widget.php:389
161
  msgid "English (wordpress.org)"
162
  msgstr "Английский (wordpress.org)"
163
 
164
- #: q2w3-fixed-widget.php:391
165
  msgid "Russian (www.q2w3.ru)"
166
  msgstr "Русский (www.q2w3.ru)"
167
 
168
- #: q2w3-fixed-widget.php:397
169
  msgid "RATE THE PLUGIN"
170
  msgstr "Оцените плагин!"
171
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Q2W3 Fixed Widget\n"
4
+ "POT-Creation-Date: 2016-09-08 13:02+0300\n"
5
+ "PO-Revision-Date: 2016-09-08 13:05+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: ru_RU\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
+ #: q2w3-fixed-widget.php:175
18
  msgid "Fixed widget"
19
  msgstr "Зафиксировать виджет"
20
 
21
+ #: q2w3-fixed-widget.php:209 q2w3-fixed-widget.php:313
22
  msgid "Fixed Widget Options"
23
  msgstr "Фикс. Виджеты"
24
 
25
+ #: q2w3-fixed-widget.php:301
26
  msgid "General Options"
27
  msgstr "Основные настройки"
28
 
29
+ #: q2w3-fixed-widget.php:303
30
  msgid "Compatibility"
31
  msgstr "Совместимость"
32
 
33
+ #: q2w3-fixed-widget.php:305
34
  msgid "Custom IDs"
35
  msgstr "Произвольные идентификаторы"
36
 
37
+ #: q2w3-fixed-widget.php:307
38
  msgid "Help for users"
39
  msgstr "Помощь пользователям"
40
 
41
+ #: q2w3-fixed-widget.php:309
42
  msgid "Help for developer"
43
  msgstr "Помощь разработчику"
44
 
45
+ #: q2w3-fixed-widget.php:317
46
  msgid "Settings saved."
47
  msgstr "Настройки сохранены."
48
 
49
+ #: q2w3-fixed-widget.php:343
50
+ msgid ""
51
+ "Note for cache plugin users. Don't forget to clear the cache after options "
52
+ "change!"
53
+ msgstr ""
54
+ "Используете кэширующие плагины? После изменения настроек не забудьте "
55
+ "очистить кэш!"
56
+
57
+ #: q2w3-fixed-widget.php:345
58
  msgid "Save Changes"
59
  msgstr "Сохранить"
60
 
61
+ #: q2w3-fixed-widget.php:359
62
  msgid "Margin Top:"
63
  msgstr "Верхний отступ:"
64
 
 
65
  #: q2w3-fixed-widget.php:359 q2w3-fixed-widget.php:361
66
+ #: q2w3-fixed-widget.php:367 q2w3-fixed-widget.php:369
67
  msgid "px"
68
  msgstr "пикс."
69
 
70
+ #: q2w3-fixed-widget.php:361
71
  msgid "Margin Bottom:"
72
  msgstr "Нижний отступ:"
73
 
74
+ #: q2w3-fixed-widget.php:363
75
  msgid "Stop ID:"
76
  msgstr "Стоп ID:"
77
 
78
+ #: q2w3-fixed-widget.php:363
79
  msgid ""
80
  "Here you need to provide html tag id. The position of that html element will "
81
  "determine margin bottom value."
83
  "Здесь необходимо ввести id html-элемента. Позиция этого html-элемента будет "
84
  "динамически определять значение нижнего отступа."
85
 
86
+ #: q2w3-fixed-widget.php:365
87
  msgid "Refresh interval:"
88
  msgstr "Интервал обновления:"
89
 
90
+ #: q2w3-fixed-widget.php:365
91
  msgid "milliseconds"
92
  msgstr "миллисекунды"
93
 
94
+ #: q2w3-fixed-widget.php:365
95
  msgid ""
96
  "Used only for compatibility with browsers without MutationObserver API "
97
  "support! Set 0 to completely disable."
99
  "Используется только для совместимости с браузерами не поддерживающими "
100
  "MutationObserver API"
101
 
102
+ #: q2w3-fixed-widget.php:367
103
  msgid "Disable Width:"
104
  msgstr "Ширина отключения:"
105
 
106
+ #: q2w3-fixed-widget.php:367
107
  msgid ""
108
  "Use this option to disable plugin on portable devices. When the browser "
109
  "screen width is less then specified value, the plugin is disabled!"
112
  "ширина окна браузера меньше или равна указанной величине, плагин будет "
113
  "отключен!"
114
 
115
+ #: q2w3-fixed-widget.php:369
116
  msgid "Disable Height:"
117
  msgstr "Высота отключения:"
118
 
119
+ #: q2w3-fixed-widget.php:369
120
  msgid "Works the same way as Disable Width option."
121
  msgstr "Работает аналогично опции \"Ширина отключения\""
122
 
123
+ #: q2w3-fixed-widget.php:375
124
  msgid "Custom HTML IDs (each one on a new line):"
125
  msgstr ""
126
  "HTML-идентификаторы статических виджетов и прочих нестандартных элементов "
127
  "(каждый на новой строке):"
128
 
129
+ #: q2w3-fixed-widget.php:381
130
  msgid "Auto fix widget id:"
131
  msgstr "Автоматически исправлять id виджетов:"
132
 
133
+ #: q2w3-fixed-widget.php:383
134
+ msgid "Disable MutationObserver:"
135
+ msgstr "Отключить MutationObserver:"
136
+
137
+ #: q2w3-fixed-widget.php:383
138
+ msgid ""
139
+ "If MutationObserver disabled, plugin will use Refresh Interval to reflect "
140
+ "page changes (version 4 behavior)"
141
+ msgstr ""
142
+ "Отключение восстанавливает функционал версии 4 - для обнаружения изменений "
143
+ "на странице используется интервал обновления."
144
+
145
+ #: q2w3-fixed-widget.php:385
146
  msgid "Enable plugin for logged in users only:"
147
  msgstr "Только зарегистрированные пользователи:"
148
 
149
+ #: q2w3-fixed-widget.php:385
150
  msgid "Enable this option for debug purposes (frontend problems and etc.)"
151
  msgstr "Используйте для отладки стилей, скриптов"
152
 
153
+ #: q2w3-fixed-widget.php:387
154
  msgid "Inherit widget width from the parent container:"
155
  msgstr "Наследовать ширину родительского контейнера:"
156
 
157
+ #: q2w3-fixed-widget.php:387
158
  msgid "Enable this option for themes with responsive sidebar"
159
  msgstr ""
160
  "Задействуйте эту опцию, если ширина сайдбара вашей темы меняется динамически"
161
 
162
+ #: q2w3-fixed-widget.php:389
163
  msgid "Use jQuery(window).load() hook:"
164
  msgstr "Вкл. jQuery(window).load():"
165
 
166
+ #: q2w3-fixed-widget.php:389
167
  msgid ""
168
  "Enable this option only if you have problems with other scroll oriented "
169
  "javascript code"
170
  msgstr "Задействуйте эту опцию в случае проблем с другими скриптами"
171
 
172
+ #: q2w3-fixed-widget.php:391
173
  msgid "widget_display_callback hook priority:"
174
  msgstr "Приоритет хука widget_display_callback:"
175
 
176
+ #: q2w3-fixed-widget.php:397
177
  msgid "Support forums:"
178
  msgstr "Форумы поддержки:"
179
 
180
+ #: q2w3-fixed-widget.php:399
181
  msgid "English (wordpress.org)"
182
  msgstr "Английский (wordpress.org)"
183
 
184
+ #: q2w3-fixed-widget.php:401
185
  msgid "Russian (www.q2w3.ru)"
186
  msgstr "Русский (www.q2w3.ru)"
187
 
188
+ #: q2w3-fixed-widget.php:407
189
  msgid "RATE THE PLUGIN"
190
  msgstr "Оцените плагин!"
191
 
q2w3-fixed-widget.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Text Domain: q2w3-fixed-widget
7
  Author: Max Bond
8
- Version: 5.0.1
9
  Author URI: http://www.q2w3.ru/
10
  */
11
 
@@ -17,7 +17,7 @@ class q2w3_fixed_widget { // Plugin class
17
 
18
  const ID = 'q2w3_fixed_widget';
19
 
20
- const VERSION = '5.0.1';
21
 
22
  protected static $sidebars_widgets;
23
 
@@ -54,7 +54,9 @@ class q2w3_fixed_widget { // Plugin class
54
 
55
  add_action('wp_loaded', array( __CLASS__, 'custom_ids' ));
56
 
57
- add_action('wp_footer', array( __CLASS__, 'js_settings' ), 1);
 
 
58
 
59
  add_action('wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ));
60
 
@@ -131,17 +133,19 @@ class q2w3_fixed_widget { // Plugin class
131
  public static function js_settings() {
132
 
133
  $options = self::load_options();
 
 
134
 
135
  if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
136
-
137
- echo '<script type="text/javascript">';
138
-
139
- echo 'var q2w3_sidebar_options = new Array();'.PHP_EOL;
140
 
141
  if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = 'true'; else $window_load_hook = 'false';
142
 
143
  if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = 'true'; else $width_inherit = 'false';
144
 
 
 
145
  if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
146
 
147
  $i = 0;
@@ -150,15 +154,23 @@ class q2w3_fixed_widget { // Plugin class
150
 
151
  $widgets_array = implode(',', $widgets);
152
 
153
- echo 'q2w3_sidebar_options['. $i .'] = { "sidebar" : "'. $sidebar .'", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "stop_id" : "' . $options['stop-id'] .'", "screen_max_width" : '. $options['screen-max-width'] .', "screen_max_height" : '. $options['screen-max-height'] .', "width_inherit" : '. $width_inherit .', "refresh_interval" : '. $refresh_interval .', "window_load_hook" : '. $window_load_hook .', "widgets" : ['. $widgets_array .'] };'.PHP_EOL;
154
 
155
  $i++;
156
 
157
  }
158
-
159
- echo '</script>'.PHP_EOL;
160
 
161
  }
 
 
 
 
 
 
 
 
 
 
162
 
163
  }
164
 
@@ -232,6 +244,8 @@ class q2w3_fixed_widget { // Plugin class
232
 
233
  $d['widget_display_callback_priority'] = 30;
234
 
 
 
235
  return $d;
236
 
237
  }
@@ -276,6 +290,8 @@ class q2w3_fixed_widget { // Plugin class
276
 
277
  if ( !isset($input['width-inherit']) ) $input['width-inherit'] = false;
278
 
 
 
279
  return $input;
280
 
281
  }
@@ -333,7 +349,9 @@ class q2w3_fixed_widget { // Plugin class
333
  do_meta_boxes( $screen, 'normal', $options );
334
 
335
  echo '</div>'.PHP_EOL;
336
-
 
 
337
  echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
338
 
339
  echo '</div><!-- #poststuff -->'.PHP_EOL;
@@ -369,8 +387,10 @@ class q2w3_fixed_widget { // Plugin class
369
  }
370
 
371
  public static function settings_page_compatibility_box($options) {
372
-
373
  echo '<p><span style="display: inline-block; width: 280px;">'. __('Auto fix widget id:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[fix-widget-id]" value="yes" '. checked('yes', $options['fix-widget-id'], false) .' /> </p>'.PHP_EOL;
 
 
374
 
375
  echo '<p><span style="display: inline-block; width: 280px;">'. __('Enable plugin for logged in users only:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[logged_in_req]" value="yes" '. checked('yes', $options['logged_in_req'], false) .' /> '. __('Enable this option for debug purposes (frontend problems and etc.)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
376
 
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Text Domain: q2w3-fixed-widget
7
  Author: Max Bond
8
+ Version: 5.0.2
9
  Author URI: http://www.q2w3.ru/
10
  */
11
 
17
 
18
  const ID = 'q2w3_fixed_widget';
19
 
20
+ const VERSION = '5.0.2';
21
 
22
  protected static $sidebars_widgets;
23
 
54
 
55
  add_action('wp_loaded', array( __CLASS__, 'custom_ids' ));
56
 
57
+ //add_action('wp_footer', array( __CLASS__, 'js_settings' ), 1);
58
+
59
+ add_action('wp_print_footer_scripts', array( __CLASS__, 'js_settings' ), 1);
60
 
61
  add_action('wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ));
62
 
133
  public static function js_settings() {
134
 
135
  $options = self::load_options();
136
+
137
+ $js = '';
138
 
139
  if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
140
+
141
+ $js .= 'var q2w3_sidebar_options = new Array();'.PHP_EOL;
 
 
142
 
143
  if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = 'true'; else $window_load_hook = 'false';
144
 
145
  if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = 'true'; else $width_inherit = 'false';
146
 
147
+ if ( isset($options['disable-mo-api']) && $options['disable-mo-api'] ) $disable_mo_api = 'true'; else $disable_mo_api = 'false';
148
+
149
  if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
150
 
151
  $i = 0;
154
 
155
  $widgets_array = implode(',', $widgets);
156
 
157
+ $js .= 'q2w3_sidebar_options['. $i .'] = { "sidebar" : "'. $sidebar .'", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "stop_id" : "' . $options['stop-id'] .'", "screen_max_width" : '. $options['screen-max-width'] .', "screen_max_height" : '. $options['screen-max-height'] .', "width_inherit" : '. $width_inherit .', "refresh_interval" : '. $refresh_interval .', "window_load_hook" : '. $window_load_hook .', "disable_mo_api" : '. $disable_mo_api .', "widgets" : ['. $widgets_array .'] };'.PHP_EOL;
158
 
159
  $i++;
160
 
161
  }
 
 
162
 
163
  }
164
+
165
+ if ( $js && function_exists('wp_add_inline_script') ) {
166
+
167
+ wp_add_inline_script(self::ID, $js, 'before');
168
+
169
+ } elseif ( $js ) {
170
+
171
+ echo '<script type="text/javascript">'. $js .'</script>';
172
+
173
+ }
174
 
175
  }
176
 
244
 
245
  $d['widget_display_callback_priority'] = 30;
246
 
247
+ $d['disable-mo-api'] = false;
248
+
249
  return $d;
250
 
251
  }
290
 
291
  if ( !isset($input['width-inherit']) ) $input['width-inherit'] = false;
292
 
293
+ if ( !isset($input['disable-mo-api']) ) $input['disable-mo-api'] = false;
294
+
295
  return $input;
296
 
297
  }
349
  do_meta_boxes( $screen, 'normal', $options );
350
 
351
  echo '</div>'.PHP_EOL;
352
+
353
+ echo '<p><em>'. __("Note for cache plugin users. Don't forget to clear the cache after options change!", 'q2w3-fixed-widget') .'</em></p>'.PHP_EOL;
354
+
355
  echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
356
 
357
  echo '</div><!-- #poststuff -->'.PHP_EOL;
387
  }
388
 
389
  public static function settings_page_compatibility_box($options) {
390
+
391
  echo '<p><span style="display: inline-block; width: 280px;">'. __('Auto fix widget id:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[fix-widget-id]" value="yes" '. checked('yes', $options['fix-widget-id'], false) .' /> </p>'.PHP_EOL;
392
+
393
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Disable MutationObserver:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-mo-api]" value="yes" '. checked('yes', $options['disable-mo-api'], false) .' /> '. __('If MutationObserver disabled, plugin will use Refresh Interval to reflect page changes (version 4 behavior)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
394
 
395
  echo '<p><span style="display: inline-block; width: 280px;">'. __('Enable plugin for logged in users only:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[logged_in_req]" value="yes" '. checked('yes', $options['logged_in_req'], false) .' /> '. __('Enable this option for debug purposes (frontend problems and etc.)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
396
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Max Bond
3
  Tags: sidebar, widget, scroll, scrolling, fixed, fixed widget, floating, floating widget, sticky, sticky widget, russian, q2w3
4
  Requires at least: 4.0
5
  Tested up to: 4.6
6
- Stable tag: 5.0.1
7
 
8
  Fixes positioning of the selected widgets, when the page is scrolled down.
9
 
@@ -82,6 +82,11 @@ Other Q2W3 plugins:
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
85
  = 5.0.1 =
86
  * Fixed problem in multiple sidebars layout
87
 
3
  Tags: sidebar, widget, scroll, scrolling, fixed, fixed widget, floating, floating widget, sticky, sticky widget, russian, q2w3
4
  Requires at least: 4.0
5
  Tested up to: 4.6
6
+ Stable tag: 5.0.2
7
 
8
  Fixes positioning of the selected widgets, when the page is scrolled down.
9
 
82
 
83
  == Changelog ==
84
 
85
+ = 5.0.2 =
86
+ * Plugin javascript optimization
87
+ * To resolve "q2w3_sidebar_options is not defined" error `wp_add_inline_script` function is used. WordPress 4.5 required for this fix!
88
+ * Added option `Disable MutationObserver`. Use this option only as a backup to restore version 4 behavior!
89
+
90
  = 5.0.1 =
91
  * Fixed problem in multiple sidebars layout
92