Use favorite settings from preference to avoid all the encoding problems

Avoids errors in Firefox.
(See rev. 53183, 53215, 53244)
This commit is contained in:
Nathan Gray 2015-08-20 17:18:48 +00:00
parent 52cf6344d8
commit d443f124b1
2 changed files with 15 additions and 13 deletions

View File

@ -78,10 +78,9 @@ class egw_favorites
error_log(__METHOD__.'Favorite filter is not suppose to be empty, it should be an array. filter = '. array2string($filters[$name]));
continue;
}
$href = "javascript:app.$app.setState(" . json_encode($filter,JSON_FORCE_OBJECT) . ');';
$li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n";
$li .= '<a href="'.htmlspecialchars($href).'" class="ui-corner-all" tabindex="-1">';
$li .= '<a href="#" class="ui-corner-all" tabindex="-1">';
$li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
$filter['name'];
$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" :

View File

@ -381,12 +381,16 @@ var AppJS = Class.extend(
},50);
}
var href = jQuery('a[href^="javascript:"]', this).prop('href');
var matches = href ? href.match(/^javascript:([^\(]+)\((.*)?\);?$/) : null;
if (matches && matches.length > 1 && matches[2] !== undefined)
var state = {};
var pref = egw.preference('favorite_' + this.dataset.id, self.appname);
if(pref)
{
state = pref;
}
if(this.dataset.id != 'add')
{
event.stopImmediatePropagation();
self.setState.call(self, JSON.parse(matches[2]));
self.setState.call(self, state);
return false;
}
})
@ -760,16 +764,15 @@ var AppJS = Class.extend(
var state = this.getState();
var best_match = false;
var best_count = 0;
var self = this;
$j('li[data-id]',this.sidebox).removeClass('ui-state-highlight');
$j('li[data-id] a[href^="javascript:"]',this.sidebox).each(function(i,href) {
var matches = href.href ? href.href.match(/^javascript:([^\(]+)\((.*)?\);?$/) : null;
$j('li[data-id]',this.sidebox).each(function(i,href) {
var favorite = {}
if (matches && matches.length > 1 && matches[2] !== undefined)
if(this.dataset.id && egw.preference('favorite_'+this.dataset.id,self.appname))
{
favorite = JSON.parse(matches[2]);
favorite = egw.preference('favorite_'+this.dataset.id,self.appname);
}
if(!favorite || jQuery.isEmptyObject(favorite)) return;
@ -834,7 +837,7 @@ var AppJS = Class.extend(
}
if(match_count > best_count)
{
best_match = href.parentNode.dataset.id;
best_match = this.dataset.id;
best_count = match_count;
}
});