initial
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
@@ -0,0 +1,347 @@
|
||||
(function () {
|
||||
window.init_wpfront_notifiction_bar_options = function (data, settings, is_pro) {
|
||||
var $ = jQuery;
|
||||
var app = Vue.createApp({
|
||||
data() {
|
||||
return data;
|
||||
},
|
||||
mounted() {
|
||||
var $div = $('div.wrap.notification-bar-add-edit');
|
||||
$(function () {
|
||||
$div.find('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
||||
postboxes.add_postbox_toggles('<?php echo $this->controller->get_menu_slug(); ?>');
|
||||
});
|
||||
|
||||
this.minutestohours();
|
||||
if (is_pro) {
|
||||
this.tinymce();
|
||||
if (data.editor == "visual") {
|
||||
this.tinymceinit();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
tinymceinit() {
|
||||
if (typeof tinymce !== 'undefined') {
|
||||
tinymce.init({
|
||||
body_id: "wpfront-notification-bar-editor",
|
||||
body_class: "wpfront-notification-bar-editor wpfront-message",
|
||||
selector: 'textarea#notification-bar-message-text',
|
||||
height: '400',
|
||||
plugins: 'code, lists, link, fullscreen, image, media, quickbars, hr',
|
||||
quickbars_selection_toolbar: 'bold italic underline | formatselect | blockquote quicklink',
|
||||
menubar: false,
|
||||
media_live_embeds: true,
|
||||
content_css: settings.content_css,
|
||||
content_style: "body{ text-align: center; padding: 0; margin: 0; } p{ margin: 0; }",
|
||||
toolbar1: 'undo redo | styleselect | fontselect fontsizeselect forecolor backcolor | numlist bullist | bold italic strikethrough blockquote underline lineheight hr | code',
|
||||
toolbar2: 'alignleft aligncenter alignright | link unlink | outdent indent | uploadmedia image media',
|
||||
fontsize_formats: settings.fontsize_formats,
|
||||
font_formats: settings.font_formats,
|
||||
setup: function (editor) {
|
||||
var frame;
|
||||
editor.ui.registry.addButton('uploadmedia', {
|
||||
icon: 'upload',
|
||||
tooltip: settings.tinymce_tooltip,
|
||||
onAction: function () {
|
||||
if (frame) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
frame = wp.media({
|
||||
title: settings.tinymce_title,
|
||||
button: {
|
||||
text: settings.tinymce_button_text,
|
||||
},
|
||||
multiple: false
|
||||
});
|
||||
|
||||
|
||||
frame.on('select', function () {
|
||||
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
var media_file;
|
||||
|
||||
if (attachment.type == 'image') {
|
||||
media_file = '<img width="' + attachment.width + '" height="' + attachment.height + '"' + 'src="' + attachment.url + '">';
|
||||
} else if (attachment.type == 'video') {
|
||||
media_file = '<video width="320" height="240" controls>' + '<source src="' + attachment.url + '" type="video/mp4">' + '</video>';
|
||||
} else {
|
||||
media_file = '<a href="' + attachment.url + '">' + attachment.name + '</a>';
|
||||
}
|
||||
editor.execCommand('mceInsertContent', false, media_file);
|
||||
});
|
||||
|
||||
frame.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
var self = this;
|
||||
setTimeout(function(){ self.tinymceinit() }, 100);
|
||||
}
|
||||
},
|
||||
tinymce(){
|
||||
},
|
||||
mediaLibrary() {
|
||||
var mediaLibrary = null;
|
||||
if (mediaLibrary === null) {
|
||||
mediaLibrary = wp.media.frames.file_frame = wp.media({
|
||||
title: settings.choose_image,
|
||||
multiple: false,
|
||||
button: {
|
||||
text: settings.select_image
|
||||
}
|
||||
}).on('select', function () {
|
||||
var obj = mediaLibrary.state().get('selection').first().toJSON();
|
||||
|
||||
$('#reopen-button-image-url').val(obj.url);
|
||||
});
|
||||
}
|
||||
|
||||
mediaLibrary.open();
|
||||
return false;
|
||||
},
|
||||
|
||||
minutestohours() {
|
||||
var duration = parseInt($('input[name="wpfront-notification-bar-options[schedule_duration]"]').val());
|
||||
if (duration > 60) {
|
||||
var hours = (duration / 60);
|
||||
var comp_hours = Math.floor(hours);
|
||||
var minutes = (hours - comp_hours) * 60;
|
||||
var comp_minutes = Math.round(minutes);
|
||||
var hours_minutes;
|
||||
if (comp_minutes > 0) {
|
||||
hours_minutes = settings.x_hours_minutes.replace("%1$d", comp_hours).replace("%2$d", comp_minutes);
|
||||
} else {
|
||||
hours_minutes = settings.x_hours.replace("%1$d", comp_hours);
|
||||
}
|
||||
$('#schedule_duration').replaceWith('<span id="schedule_duration" class="description">= ' + hours_minutes + '</span>');
|
||||
} else {
|
||||
$('#schedule_duration').replaceWith('<span id="schedule_duration" class="description"></span>');
|
||||
}
|
||||
},
|
||||
|
||||
schedules() {
|
||||
var cronminutes = [];
|
||||
var cronhours = [];
|
||||
var cronmday = [];
|
||||
var cronmon = [];
|
||||
var cronwday = [];
|
||||
var schedule_date = $('input[name="wpfront-notification-bar-options[schedule_start_date]"]').val();
|
||||
var schedule_time = $('input[name="wpfront-notification-bar-options[schedule_start_time]"]').val();
|
||||
var schedule_end_date = $('input[name="wpfront-notification-bar-options[schedule_end_date]"]').val();
|
||||
var schedule_end_time = $('input[name="wpfront-notification-bar-options[schedule_end_time]"]').val();
|
||||
var schedule_duration = $('input[name="wpfront-notification-bar-options[schedule_duration]"]').val();
|
||||
|
||||
if ('day' == $('input[name="wpfront-notification-bar-options[schedule]"]:checked').val()) {
|
||||
$("input:checkbox[name='wpfront-day-minutes[]']:checked").each(function () {
|
||||
cronminutes.push($(this).val());
|
||||
});
|
||||
$("input:checkbox[name='wpfront-day-hour[]']:checked").each(function () {
|
||||
cronhours.push($(this).val());
|
||||
});
|
||||
cronmday.push('*');
|
||||
cronmon.push('*');
|
||||
cronwday.push('*');
|
||||
}
|
||||
|
||||
if ('week' == $('input[name="wpfront-notification-bar-options[schedule]"]:checked').val()) {
|
||||
$("input:checkbox[name='wpfront-day-minutes[]']:checked").each(function () {
|
||||
cronminutes.push($(this).val());
|
||||
});
|
||||
$("input:checkbox[name='wpfront-day-hour[]']:checked").each(function () {
|
||||
cronhours.push($(this).val());
|
||||
});
|
||||
cronmday.push('*');
|
||||
cronmon.push('*');
|
||||
$("input:checkbox[name='wpfront-week-days[]']:checked").each(function () {
|
||||
cronwday.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if ('mon' == $('input[name="wpfront-notification-bar-options[schedule]"]:checked').val()) {
|
||||
$("input:checkbox[name='wpfront-day-minutes[]']:checked").each(function () {
|
||||
cronminutes.push($(this).val());
|
||||
});
|
||||
$("input:checkbox[name='wpfront-day-hour[]']:checked").each(function () {
|
||||
cronhours.push($(this).val());
|
||||
});
|
||||
$("input:checkbox[name='wpfront-month-days[]']:checked").each(function () {
|
||||
cronmday.push($(this).val());
|
||||
});
|
||||
cronmon.push('*');
|
||||
cronwday.push('*');
|
||||
}
|
||||
|
||||
var data = {
|
||||
action: 'notification_bar_cron_text',
|
||||
cronminutes: cronminutes,
|
||||
cronhours: cronhours,
|
||||
cronmday: cronmday,
|
||||
cronmon: cronmon,
|
||||
cronwday: cronwday,
|
||||
schedulestartdate: schedule_date,
|
||||
schedulestarttime: schedule_time,
|
||||
scheduleduration: schedule_duration,
|
||||
scheduleenddate: schedule_end_date,
|
||||
scheduleendtime: schedule_end_time
|
||||
};
|
||||
|
||||
var loading = $("a.thickbox.more_schedules").attr("data-action");
|
||||
|
||||
$("#div_more_schedules_inside").text(loading);
|
||||
$.post(ajaxurl, data, function (response) {
|
||||
$('#notification-bar-schedule').replaceWith(response.data[0]);
|
||||
$("#div_more_schedules_inside").replaceWith(response.data[1]);
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
app.component('HelpIcon', {
|
||||
props: ['helpText'],
|
||||
template: '<el-tooltip :content="helpText" raw-content="true" placement="right"><i class="tooltip fa fa-question-circle-o help-icon"></i></el-tooltip>'
|
||||
});
|
||||
|
||||
app.component('ColorPicker', {
|
||||
props: ['modelValue', 'name'],
|
||||
template: $('#color-picker').html(),
|
||||
});
|
||||
|
||||
app.component('PostsFilterSelection', {
|
||||
props: ['modelValue', 'name'],
|
||||
template: $('#posts-filter-selection').html(),
|
||||
computed: {
|
||||
selectedPosts: {
|
||||
get() {
|
||||
return this.modelValue.split(',');
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('update:modelValue', values.filter(e => e).join().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.component('DisplayRolesSettings', {
|
||||
props: ['modelValue', 'name'],
|
||||
template: $('#display-roles-settings').html(),
|
||||
computed: {
|
||||
selectedRoles: {
|
||||
get() {
|
||||
return this.modelValue;
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('update:modelValue', values);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.component('DatePicker', {
|
||||
props: ['modelValue', 'name'],
|
||||
data: function () {
|
||||
return { data: this.modelValue }
|
||||
},
|
||||
template: $('#date-picker').html(),
|
||||
});
|
||||
|
||||
app.component('TimePicker', {
|
||||
props: ['modelValue', 'name'],
|
||||
data: function () {
|
||||
return { data: this.modelValue }
|
||||
},
|
||||
template: $('#time-picker').html(),
|
||||
});
|
||||
|
||||
app.component('ScheduleSelectionSettings', {
|
||||
props: ['modelValue'],
|
||||
template: $('#schedule-selection-settings').html(),
|
||||
data() {
|
||||
data.scheduleType = this.scheduledata();
|
||||
return data;
|
||||
},
|
||||
methods: {
|
||||
schedules() {
|
||||
this.$parent.schedules();
|
||||
},
|
||||
scheduledata() {
|
||||
$time_units = data.schedule.split(' ');
|
||||
$minutes = $time_units[0].split(',');
|
||||
$hours = $time_units[1].split(',');
|
||||
$month_days = $time_units[2].split(',');
|
||||
$month = $time_units[3].split(',');
|
||||
$week_days = $time_units[4].split(',');
|
||||
|
||||
if (!isNaN($month_days[0]) || ($month_days[0] == "L")) {
|
||||
$schedule_type = "mon";
|
||||
}
|
||||
|
||||
if (!isNaN($week_days[0])) {
|
||||
$schedule_type = "week";
|
||||
}
|
||||
|
||||
if ($month_days[0] + $week_days[0] == '**') {
|
||||
$schedule_type = 'day';
|
||||
}
|
||||
|
||||
return $schedule_type;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectedMonthDays: {
|
||||
get() {
|
||||
$time_units = this.modelValue.split(' ');
|
||||
$month_days = $time_units[2].split(',');
|
||||
return $month_days;
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('input', values);
|
||||
}
|
||||
},
|
||||
|
||||
selectedWeekDays: {
|
||||
get() {
|
||||
$time_units = this.modelValue.split(' ');
|
||||
$week_days = $time_units[4].split(',');
|
||||
return $week_days;
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('input', values);
|
||||
}
|
||||
},
|
||||
|
||||
selectedHours: {
|
||||
get() {
|
||||
$time_units = this.modelValue.split(' ');
|
||||
$hours = $time_units[1].split(',');
|
||||
return $hours;
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('input', values);
|
||||
}
|
||||
},
|
||||
|
||||
selectedMinutes: {
|
||||
get() {
|
||||
$time_units = this.modelValue.split(' ');
|
||||
$minutes = $time_units[0].split(',');
|
||||
return $minutes;
|
||||
},
|
||||
set(values) {
|
||||
this.$emit('input', values);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.use(ElementPlus);
|
||||
app.mount('#notification-bar-add-edit');
|
||||
|
||||
};
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
WPFront Notification Bar Plugin
|
||||
Copyright (C) 2013, WPFront.com
|
||||
Website: wpfront.com
|
||||
Contact: syam@wpfront.com
|
||||
|
||||
WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
|
||||
June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
|
||||
St, Fifth Floor, Boston, MA 02110, USA
|
||||
|
||||
*/
|
||||
|
||||
(function () {
|
||||
//displays the notification bar
|
||||
window.wpfront_notification_bar = function (data, process) {
|
||||
var log = function (msg) {
|
||||
if (data.log) {
|
||||
console.log(data.log_prefix + ' ' + msg);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof jQuery === "undefined" || (data.keep_closed && typeof Cookies === "undefined") || (data.set_max_views && typeof Cookies === "undefined")) {
|
||||
log('Waiting for ' + (typeof jQuery === "undefined" ? 'jQuery.' : 'Cookies.'));
|
||||
setTimeout(function () {
|
||||
wpfront_notification_bar(data, process);
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.position == 2 && process !== true) {
|
||||
jQuery(function () {
|
||||
wpfront_notification_bar(data, true);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var get_element_id = function (id) {
|
||||
return id + data.id_suffix;
|
||||
}
|
||||
|
||||
var $ = jQuery;
|
||||
|
||||
var keep_closed_cookie = data.keep_closed_cookie;
|
||||
|
||||
var bar_views = 0;
|
||||
var max_views_cookie = data.max_views_cookie;
|
||||
|
||||
var spacer = $(get_element_id("#wpfront-notification-bar-spacer")).removeClass('hidden');
|
||||
var bar = $(get_element_id("#wpfront-notification-bar"));
|
||||
var open_button = $(get_element_id("#wpfront-notification-bar-open-button"));
|
||||
|
||||
//set the position
|
||||
if (data.position == 1) {
|
||||
log('Setting notification bar at top.');
|
||||
var top = 0;
|
||||
if (data.fixed_position && data.is_admin_bar_showing) {
|
||||
top = $("html").css("margin-top");
|
||||
if (top == "0px")
|
||||
top = $("html").css("padding-top");
|
||||
top = parseInt(top);
|
||||
}
|
||||
if (data.fixed_position) {
|
||||
top += data.position_offset;
|
||||
}
|
||||
bar.css("top", top + "px");
|
||||
open_button.css("top", top + "px");
|
||||
spacer.css("top", data.position_offset + "px");
|
||||
var $body = $("body")
|
||||
var $firstChild = $body.children().first();
|
||||
if ($firstChild.hasClass("wpfront-notification-bar-spacer")) {
|
||||
while (true) {
|
||||
var $next = $firstChild.next();
|
||||
if ($next.hasClass("wpfront-notification-bar-spacer")) {
|
||||
$firstChild = $next;
|
||||
} else {
|
||||
$firstChild.after(spacer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$body.prepend(spacer);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
if ($body.children().first().hasClass("wpfront-notification-bar-spacer")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.fixed_position && !$body.children().first().is(spacer)) {
|
||||
$body.prepend(spacer);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log('Setting notification bar at bottom.');
|
||||
var $body = $("body");
|
||||
if (!$body.children().last().is(spacer)) {
|
||||
$body.append(spacer);
|
||||
}
|
||||
$(function () {
|
||||
if (!$body.children().last().is(spacer)) {
|
||||
$body.append(spacer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var height = bar.height();
|
||||
if (data.height > 0) {
|
||||
height = data.height;
|
||||
bar.find("table, tbody, tr").css("height", "100%");
|
||||
}
|
||||
|
||||
bar.height(0).css({"position": (data.fixed_position ? "fixed" : "relative"), "visibility": "visible"});
|
||||
open_button.css({"position": (data.fixed_position ? "fixed" : "absolute")});
|
||||
|
||||
//function to set bar height based on options
|
||||
var closed = false;
|
||||
var user_closed = false;
|
||||
|
||||
function setHeight(height, callback, userclosed) {
|
||||
callback = callback || $.noop;
|
||||
|
||||
if (userclosed)
|
||||
user_closed = true;
|
||||
|
||||
if (height == 0) {
|
||||
if (closed)
|
||||
return;
|
||||
closed = true;
|
||||
} else {
|
||||
if (!closed)
|
||||
return;
|
||||
closed = false;
|
||||
}
|
||||
|
||||
if (height == 0 && data.keep_closed && userclosed) {
|
||||
if (data.keep_closed_for > 0)
|
||||
Cookies.set(keep_closed_cookie, 1, {path: "/", expires: data.keep_closed_for, sameSite: "strict"});
|
||||
else
|
||||
Cookies.set(keep_closed_cookie, 1, {path: "/", sameSite: "strict"});
|
||||
}
|
||||
|
||||
if (height !== 0 && data.set_max_views) {
|
||||
bar_views = Cookies.get(max_views_cookie);
|
||||
if (typeof bar_views === "undefined") {
|
||||
bar_views = 0;
|
||||
} else {
|
||||
bar_views = parseInt(bar_views);
|
||||
}
|
||||
if (data.max_views_for > 0) {
|
||||
Cookies.set(max_views_cookie, bar_views + 1, {path: "/", expires: data.max_views_for, sameSite: "strict"});
|
||||
} else {
|
||||
Cookies.set(max_views_cookie, bar_views + 1, {path: "/", sameSite: "strict"});
|
||||
}
|
||||
log('Setting view count to ' + (bar_views + 1) + '.');
|
||||
}
|
||||
|
||||
var fn = callback;
|
||||
callback = function () {
|
||||
fn();
|
||||
if (height > 0) {
|
||||
//set height to auto if in case content wraps on resize
|
||||
if (data.height == 0)
|
||||
bar.height("auto");
|
||||
|
||||
if (data.display_open_button) {
|
||||
log('Setting reopen button state to hidden.');
|
||||
open_button.addClass('hidden');
|
||||
}
|
||||
|
||||
closed = false;
|
||||
}
|
||||
|
||||
if (height == 0 && data.display_open_button) {
|
||||
log('Setting reopen button state to visible.');
|
||||
open_button.removeClass('hidden');
|
||||
}
|
||||
|
||||
if(height > 0){
|
||||
bar.removeClass('hidden');
|
||||
} else {
|
||||
bar.addClass('hidden');
|
||||
}
|
||||
};
|
||||
|
||||
//set animation
|
||||
if (height > 0)
|
||||
log('Setting notification bar state to visible.');
|
||||
else
|
||||
log('Setting notification bar state to hidden.');
|
||||
|
||||
if (data.animate_delay > 0) {
|
||||
bar.stop().show().animate({"height": height + "px"}, {
|
||||
"duration": data.animate_delay * 1000,
|
||||
"easing": "swing",
|
||||
"complete": function () {
|
||||
if (data.fixed_position) {
|
||||
spacer.height(height);
|
||||
}
|
||||
handle_theme_sticky(height);
|
||||
callback();
|
||||
},
|
||||
"step": function (progress) {
|
||||
if (data.fixed_position) {
|
||||
spacer.height(progress);
|
||||
}
|
||||
handle_theme_sticky(progress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bar.height(height);
|
||||
if (data.fixed_position) {
|
||||
spacer.height(height);
|
||||
}
|
||||
handle_theme_sticky(height);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
var theme_sticky_selector_position = null;
|
||||
var theme_sticky_interval_id = 0;
|
||||
var handle_theme_sticky_needed = data.fixed_position && data.theme_sticky_selector != "";
|
||||
function handle_theme_sticky(recursive) {
|
||||
if (!handle_theme_sticky_needed) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (recursive !== true) {
|
||||
clearInterval(theme_sticky_interval_id);
|
||||
var intervalCount = 0;
|
||||
theme_sticky_interval_id = setInterval(function () {
|
||||
handle_theme_sticky(true);
|
||||
|
||||
intervalCount++;
|
||||
|
||||
if (intervalCount > 100) {
|
||||
clearInterval(theme_sticky_interval_id);
|
||||
return;
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
|
||||
var $theme_sticky_selector = $(data.theme_sticky_selector);
|
||||
if ($theme_sticky_selector.length == 0 || $theme_sticky_selector.css('position') !== 'fixed') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (data.position == 1) {
|
||||
if (theme_sticky_selector_position === null) {
|
||||
theme_sticky_selector_position = $theme_sticky_selector.position().top;
|
||||
}
|
||||
if (bar.is(":visible")) {
|
||||
$theme_sticky_selector.css("top", (bar.height() + bar.position().top) + "px");
|
||||
} else {
|
||||
$theme_sticky_selector.css("top", theme_sticky_selector_position + "px");
|
||||
}
|
||||
}
|
||||
|
||||
if (data.position == 2) {
|
||||
if (theme_sticky_selector_position === null) {
|
||||
theme_sticky_selector_position = $theme_sticky_selector.height() + parseFloat($theme_sticky_selector.css("bottom"));
|
||||
}
|
||||
if (bar.is(":visible")) {
|
||||
$theme_sticky_selector.css("bottom", (bar.height() + parseFloat(bar.css("bottom"))) + "px");
|
||||
} else {
|
||||
$theme_sticky_selector.css("bottom", theme_sticky_selector_position + "px");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (handle_theme_sticky_needed) {
|
||||
$(window).on("scroll resize", function () {
|
||||
handle_theme_sticky();
|
||||
});
|
||||
}
|
||||
|
||||
if (data.close_button) {
|
||||
spacer.on('click', '.wpfront-close', function () {
|
||||
setHeight(0, null, true);
|
||||
});
|
||||
}
|
||||
|
||||
//close button action
|
||||
if (data.button_action_close_bar) {
|
||||
spacer.on('click', '.wpfront-button', function () {
|
||||
setHeight(0, null, true);
|
||||
});
|
||||
}
|
||||
|
||||
if (data.display_open_button) {
|
||||
spacer.on('click', get_element_id('#wpfront-notification-bar-open-button'), function () {
|
||||
setHeight(height);
|
||||
});
|
||||
}
|
||||
|
||||
if (data.keep_closed) {
|
||||
if (Cookies.get(keep_closed_cookie)) {
|
||||
log('Keep closed enabled and keep closed cookie exists. Hiding notification bar.');
|
||||
setHeight(0, function(){
|
||||
bar.removeClass('keep-closed');
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
bar.removeClass('keep-closed');
|
||||
|
||||
if (data.set_max_views) {
|
||||
bar_views = Cookies.get(max_views_cookie);
|
||||
if (typeof bar_views === "undefined") {
|
||||
bar_views = 0;
|
||||
}
|
||||
if (bar_views >= data.max_views) {
|
||||
log('Reached max views, hiding notification bar.');
|
||||
setHeight(0, function(){
|
||||
bar.removeClass('max-views-reached');
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
bar.removeClass('max-views-reached');
|
||||
|
||||
closed = true;
|
||||
|
||||
if (data.display_scroll) {
|
||||
log('Display on scroll enabled. Hiding notification bar.');
|
||||
setHeight(0);
|
||||
|
||||
$(window).on('scroll', function () {
|
||||
if (user_closed)
|
||||
return;
|
||||
|
||||
if ($(this).scrollTop() > data.display_scroll_offset) {
|
||||
setHeight(height);
|
||||
} else {
|
||||
setHeight(0);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//set open after seconds and auto close seconds.
|
||||
log('Setting notification bar open event after ' + data.display_after + ' second(s).');
|
||||
setTimeout(function () {
|
||||
setHeight(height, function () {
|
||||
if (data.auto_close_after > 0) {
|
||||
log('Setting notification bar auto close event after ' + data.auto_close_after + ' second(s).');
|
||||
setTimeout(function () {
|
||||
setHeight(0, null, true);
|
||||
}, data.auto_close_after * 1000);
|
||||
}
|
||||
});
|
||||
}, data.display_after * 1000);
|
||||
}
|
||||
};
|
||||
})();
|
||||
+1
@@ -0,0 +1 @@
|
||||
window.wpfront_notification_bar=function(i,t){var e=function(t){i.log&&console.log(i.log_prefix+" "+t)};if("undefined"==typeof jQuery||i.keep_closed&&"undefined"==typeof Cookies||i.set_max_views&&"undefined"==typeof Cookies)return e("Waiting for "+("undefined"==typeof jQuery?"jQuery.":"Cookies.")),void setTimeout((function(){wpfront_notification_bar(i,t)}),100);if(2!=i.position||!0===t){var o=function(t){return t+i.id_suffix},n=jQuery,s=i.keep_closed_cookie,a=0,r=i.max_views_cookie,c=n(o("#wpfront-notification-bar-spacer")).removeClass("hidden"),f=n(o("#wpfront-notification-bar")),p=n(o("#wpfront-notification-bar-open-button"));if(1==i.position){e("Setting notification bar at top.");var l=0;i.fixed_position&&i.is_admin_bar_showing&&("0px"==(l=n("html").css("margin-top"))&&(l=n("html").css("padding-top")),l=parseInt(l)),i.fixed_position&&(l+=i.position_offset),f.css("top",l+"px"),p.css("top",l+"px"),c.css("top",i.position_offset+"px");var d=(u=n("body")).children().first();if(d.hasClass("wpfront-notification-bar-spacer"))for(;;){var _=d.next();if(!_.hasClass("wpfront-notification-bar-spacer")){d.after(c);break}d=_}else u.prepend(c);n((function(){u.children().first().hasClass("wpfront-notification-bar-spacer")||i.fixed_position&&!u.children().first().is(c)&&u.prepend(c)}))}else{var u;e("Setting notification bar at bottom."),(u=n("body")).children().last().is(c)||u.append(c),n((function(){u.children().last().is(c)||u.append(c)}))}var h=f.height();i.height>0&&(h=i.height,f.find("table, tbody, tr").css("height","100%")),f.height(0).css({position:i.fixed_position?"fixed":"relative",visibility:"visible"}),p.css({position:i.fixed_position?"fixed":"absolute"});var b=!1,v=!1,g=null,m=0,x=i.fixed_position&&""!=i.theme_sticky_selector;if(x&&n(window).on("scroll resize",(function(){k()})),i.close_button&&c.on("click",".wpfront-close",(function(){w(0,null,!0)})),i.button_action_close_bar&&c.on("click",".wpfront-button",(function(){w(0,null,!0)})),i.display_open_button&&c.on("click",o("#wpfront-notification-bar-open-button"),(function(){w(h)})),i.keep_closed&&Cookies.get(s))return e("Keep closed enabled and keep closed cookie exists. Hiding notification bar."),void w(0,(function(){f.removeClass("keep-closed")}));if(f.removeClass("keep-closed"),i.set_max_views&&(void 0===(a=Cookies.get(r))&&(a=0),a>=i.max_views))return e("Reached max views, hiding notification bar."),void w(0,(function(){f.removeClass("max-views-reached")}));f.removeClass("max-views-reached"),b=!0,i.display_scroll?(e("Display on scroll enabled. Hiding notification bar."),w(0),n(window).on("scroll",(function(){v||(n(this).scrollTop()>i.display_scroll_offset?w(h):w(0))}))):(e("Setting notification bar open event after "+i.display_after+" second(s)."),setTimeout((function(){w(h,(function(){i.auto_close_after>0&&(e("Setting notification bar auto close event after "+i.auto_close_after+" second(s)."),setTimeout((function(){w(0,null,!0)}),1e3*i.auto_close_after))}))}),1e3*i.display_after))}else jQuery((function(){wpfront_notification_bar(i,!0)}));function w(t,o,l){if(o=o||n.noop,l&&(v=!0),0==t){if(b)return;b=!0}else{if(!b)return;b=!1}0==t&&i.keep_closed&&l&&(i.keep_closed_for>0?Cookies.set(s,1,{path:"/",expires:i.keep_closed_for,sameSite:"strict"}):Cookies.set(s,1,{path:"/",sameSite:"strict"})),0!==t&&i.set_max_views&&(a=void 0===(a=Cookies.get(r))?0:parseInt(a),i.max_views_for>0?Cookies.set(r,a+1,{path:"/",expires:i.max_views_for,sameSite:"strict"}):Cookies.set(r,a+1,{path:"/",sameSite:"strict"}),e("Setting view count to "+(a+1)+"."));var d=o;o=function(){d(),t>0&&(0==i.height&&f.height("auto"),i.display_open_button&&(e("Setting reopen button state to hidden."),p.addClass("hidden")),b=!1),0==t&&i.display_open_button&&(e("Setting reopen button state to visible."),p.removeClass("hidden")),t>0?f.removeClass("hidden"):f.addClass("hidden")},e(t>0?"Setting notification bar state to visible.":"Setting notification bar state to hidden."),i.animate_delay>0?f.stop().show().animate({height:t+"px"},{duration:1e3*i.animate_delay,easing:"swing",complete:function(){i.fixed_position&&c.height(t),k(t),o()},step:function(t){i.fixed_position&&c.height(t),k(t)}}):(f.height(t),i.fixed_position&&c.height(t),k(t),o())}function k(t){if(!x)return 0;if(!0!==t){clearInterval(m);var e=0;m=setInterval((function(){k(!0),++e>100&&clearInterval(m)}),10)}var o=n(i.theme_sticky_selector);if(0==o.length||"fixed"!==o.css("position"))return 0;1==i.position&&(null===g&&(g=o.position().top),f.is(":visible")?o.css("top",f.height()+f.position().top+"px"):o.css("top",g+"px")),2==i.position&&(null===g&&(g=o.height()+parseFloat(o.css("bottom"))),f.is(":visible")?o.css("bottom",f.height()+parseFloat(f.css("bottom"))+"px"):o.css("bottom",g+"px"))}};
|
||||
Reference in New Issue
Block a user