From af1e70ab32ccca15e8f22ca4919b9cf62e923724 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 13 Feb 2014 16:50:49 +0000 Subject: [PATCH] fixed javascript error, if favorite has no href AND make sure all new favorites are created with an href, like they are created server-side --- phpgwapi/js/jsapi/app_base.js | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index 465b50ba5c..6ddbfb42cc 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -301,8 +301,8 @@ var AppJS = Class.extend( // need to install a favorite handler, as we switch original one off with .off() .on('click','li[data-id]', this, function(){ var href = jQuery('a[href^="javascript:"]', this).prop('href'); - var matches = href.match(/^javascript:([^\(]+)\((.*)?\);?$/); - if (matches.length > 1 && matches[2] !== undefined) + var matches = href ? href.match(/^javascript:([^\(]+)\((.*)?\);?$/) : null; + if (matches && matches.length > 1 && matches[2] !== undefined) { return self.setState.call(self, JSON.parse(matches[2])); } @@ -486,11 +486,7 @@ var AppJS = Class.extend( else { // Normal user - just save to preferences client side - self.egw.set_preference(self.appname,favorite_pref,{ - name: name.val(), - group: false, - state:self.favorite_popup.state - }); + self.egw.set_preference(self.appname,favorite_pref,favorite); } // Add to list immediately @@ -501,20 +497,13 @@ var AppJS = Class.extend( // Create new item var html = "\n"; - $j(html).on('click.favorites',jQuery.proxy(function(event) { - // Don't apply on delete - if($j(event.target).hasClass('ui-icon-trash')) - { - return; - } - app[self.appname].setState(this); - },favorite)) - .insertBefore($j('li',self.sidebox).last()); + $j(html).insertBefore($j('li',self.sidebox).last()); self._init_sidebox(self.sidebox); }