From 2524de6c74fd59a04bc3eaca770009ff629ca6a0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 21 Oct 2013 16:32:07 +0000 Subject: [PATCH] Add link now remembers you last selected app --- etemplate/js/et2_widget_link.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 64d967aca8..60a7e1a98f 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -443,12 +443,24 @@ var et2_link_apps = et2_selectbox.extend( select_options = this.getArrayMgr('content') .getEntry("options-" + this.id); } - + // Default to an empty object if (select_options == null) { select_options = {}; } + else + { + // Preset to last application + if(!this.options.value) + { + this.set_value(egw.preference('link_app','common')); + } + // Register to update preference + this.input.on("click", jQuery.proxy(function() { + egw.set_preference('common','link_app',this.getValue()); + }),this); + } } this.set_select_options(select_options); } @@ -542,10 +554,14 @@ var et2_link_entry = et2_inputWidget.extend( this.div = $j(document.createElement("div")).addClass("et2_link_entry"); // Application selection - this.app_select = $j(document.createElement("select")).appendTo(this.div) .change(function(e) { - self.cache = {}; // Clear cache when app changes + // Clear cache when app changes + self.cache = {}; + + // Update preference with new value + egw.set_preference('common','link_app',self.app_select.val()); + if(typeof self.options.value != 'object') self.options.value = {}; self.options.value.app = self.app_select.val(); }); @@ -561,6 +577,10 @@ var et2_link_entry = et2_inputWidget.extend( { this.app_select.val(self.options.value.app); } + else if (egw.preference('link_app','common')) + { + this.app_select.val(egw.preference('link_app','common')); + } else { this.app_select.val(this.options.application_list[0]);