: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* JavaScript Cookie v2.0.4
* https://github.com/js-cookie/js-cookie
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
if (typeof define === 'function' && define.amd) {
} else if (typeof exports === 'object') {
module.exports = factory();
/*var _OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = _OldCookies;
window.FF_Cookie = factory();
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
function init (converter) {
function api (key, value, attributes) {
if (arguments.length > 1) {
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
value = converter.write(value, key);
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
return (document.cookie = [
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
attributes.path && '; path=' + attributes.path,
attributes.domain && '; domain=' + attributes.domain,
attributes.secure ? '; secure' : ''
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var name = parts[0].replace(rdecode, decodeURIComponent);
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
cookie = JSON.parse(cookie);
api.getJSON = function () {
}, [].slice.call(arguments));
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
api.withConverter = init;
return init(function () {});
// Newsticker functionality
var template = '<div class="ffticker__table"><%= icon %><div><p class="ffticker__content"><span class="ffticker__title"><%= title %></span> <%= text %></p></div><div class="ffticker__cta_wrapper"><%= cta %></div></div><div class="ffticker__close"></div>';
var TickerModel = Backbone.Model.extend({
var TickerView = Backbone.View.extend({
template: _.template(template),
// console.log('initialize TickerView')
// console.log('render campaign view')
var $name = $('#ff_company_name');
icon: self.model.get('type') ? '<div class="ffticker__icon_wrapper"><span class="ffticker__icon"></span></div>' : '',
title: ($name.length ? 'Hi' + ($name.val() ? ' ' + $name.val() : '') + '! ' : '' ) + self.model.get('title') + ':',
text: self.model.get('text'),
cta: self.model.get('url') ? '<a target="_blank" href="' + self.model.get('url') + '" class="ffticker__cta">' + (self.model.get('cta') ? self.model.get('cta') : 'Learn more') + '</a>' : ''
self.model.get('type') && this.$el.addClass('ffticker--' + self.model.get('type'));
this.$el.html(this.template(data));
"click .ffticker__close": "destroy"
this.$el.parent().removeClass('ffticker--transition-in').css({'paddingTop' : ''});
$(document).trigger('ticker-destroyed', this.model)
var TickerController = (function () {
var cookieJSON = Cookie.getJSON('ff_news') || {seen: '', destroyed: ''};
var sessionCookie = Cookie.get('ff_news_session');
var defer = $.Deferred();
if ( /*Cookie.get( 'ff_first_time' ) &&*/ ( ! sessionCookie ) || ( sessionCookie && /*sessionCookie !== 'no_data' &&*/ sessionCookie !== 'seen' && location.href.indexOf('page=flow-flow') !== -1 ) ) {
var passthrough, s, f, curr;
//if (!sessionCookie) Cookie.set('ff_news_session', 'no_data');
if ( window.FlowFlowApp ) {
$( document ).on( 'feeds-loaded', function ( event, feeds ) {
for (var i = 0, len = FlowFlowApp.Model.StreamRow.collection.models.length; i < len; i++) {
curr = FlowFlowApp.Model.StreamRow.collection.models[ i ];
layouts[ curr.get('layout') ] += 1;
if ( curr.get('cloud') == 'yep' ) {
s = 'cloud:' + cloudStreamsLength + ';';
for (var layout in layouts) {
if ( layouts[ layout ] ) s += layout + ':' + layouts[ layout ] + ';'
s = s.replace( /\;$/, '' );
for (var feed in feeds) {
types[ feeds[ feed ].type ] += 1;
for (var type in types) {
if ( types[ type ] ) f += type + ':' + types[ type ] + ';'
f = f.replace( /\;$/, '' );
'host=' + location.host + '&' +
'ver=' + window.plugin_ver + '&' +
defer.reject('only one time in session');
function doStuff( passthrough ) {
return makeRequest( passthrough ).done( function (news) {
if ( news && $.isArray( news ) ) {
var latest = news && news[0], found;
Cookie.set('ff_news_session', latest.id);
if (isSuitableToShow(latest.id)) {
model = new TickerModel(latest);
view = new TickerView({model: model});
defer.reject('not suitable');
}).fail(function (error) {
// console.log(error.statusText);
defer.reject('request failed');
function makeRequest ( passthrough ) {
console.log('REQUESTING NOTIFICATIONS')
url: 'https://flow.looks-awesome.com/service/news',
function tryToAddNotification (id) {
seen = cookieJSON.seen.toString().split('+');
id = parseInt(id) ? id : parseInt(Cookie.get('ff_news_session'));
found = _.find( seen, function (num) {return num === id.toString()});
$item = $('#toplevel_page_flow-flow');
str = '<span class="update-plugins count-1"><span class="plugin-count">1</span></span>';
$item.find('.wp-menu-name').append(str);
$item.find('.wp-submenu li:eq(2)').prepend(str)
function isSuitableToShow (id) {
destroyed = cookieJSON.destroyed.toString().split('+');
found = _.find(destroyed, function (num) {return num === id.toString()});
cookieJSON.destroyed = id.toString() + '+' + cookieJSON.destroyed;
Cookie.set('ff_news', cookieJSON, { expires: 356 });
$(document).on('ticker-destroyed', function(event, model){
// should be in place by the moment but just in case
destroyed = cookieJSON.destroyed.toString().split('+');
found = _.find(destroyed, function (num) {return num === model.id.toString()});
cookieJSON.destroyed = model.id.toString() + '+' + cookieJSON.destroyed;
Cookie.set('ff_news', cookieJSON, { expires: 356 });
//Cookie.set('ff_news', {seen: latest.id});
// showing popup in Flow admin on resolved init() only
function injectView (view) {
var $form = $('#flow_flow_form');
height = view.$el.outerHeight() + 40;
$form.css({'paddingTop' : height+'px'});
view.$el.parent().addClass('ffticker--transition-in');
seen = cookieJSON.seen.toString().split('+');
found = _.find( seen, function (num) {return num === view.model.id.toString()}) ;
cookieJSON.seen = view.model.id.toString() + '+' + cookieJSON.seen;
Cookie.set('ff_news', cookieJSON, { expires: 356 });
Cookie.set('ff_news_session', 'seen');
tryToAddNotification: tryToAddNotification
$( document ).one('html_ready', doStuff)
if (processed) return false;
.then( TickerController.injectView )
.always( TickerController.tryToAddNotification )
})(window.jQuery, window.FF_Cookie)