From 51513d82e5d4e8a452c40e1f0edee9a1cccb95c3 Mon Sep 17 00:00:00 2001 From: Jerry Jalava Date: Mon, 14 Jan 2008 11:21:54 +0200 Subject: [PATCH] Better checking for value changes --- js/widgets/tags.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/js/widgets/tags.js b/js/widgets/tags.js index b480460..0a807bd 100644 --- a/js/widgets/tags.js +++ b/js/widgets/tags.js @@ -116,7 +116,12 @@ return tag_ids; }, - has_data_changed: function(value, prev_value) { + has_data_changed: function(value, prev_objects) { + var prev_value = []; + $.each(prev_objects, function(i, n){ + prev_value.push(n.id); + }); + var data_changed = false; if ( value.length == 0 @@ -124,7 +129,9 @@ { return false; } - + + + if ( value.length > 0 && prev_value.length == 0) { @@ -137,7 +144,8 @@ } $.each(value, function(i,n){ - if ($.inArray(n, prev_value) != -1) { + var match_key = $.inArray(n, prev_value); + if (match_key == -1) { data_changed = true; } }); @@ -147,7 +155,8 @@ } $.each(prev_value, function(i,n){ - if ($.inArray(n, value) != -1) { + var match_key = $.inArray(n, value); + if (match_key == -1) { data_changed = true; } }); @@ -185,8 +194,15 @@ { tag_title += tag.value.title.widget.config.context + ':'; } + tag_title += tag.value.title.val; + if ( typeof(tag.value.title.widget.config['value']) != 'undefined' + && tag.value.title.widget.config['value'] != '') + { + tag_title += '=' + tag.value.title.widget.config.value; + } + if (type == 'plain') { tags_str += tag_title + _self.settings.separator; } else { @@ -300,11 +316,17 @@ context_key = tag_parts[0]; t = tag_parts[1]; } + var value = ''; + if (t.match(/\=/)) { + var tag_parts = t.split('='); + value = tag_parts[1]; + t = tag_parts[0]; + } var pd = { color: (typeof d.color != 'undefined') ? d.color : '', context: (typeof d.context != 'undefined') ? d.context : context_key, - value: (typeof d.value != 'undefined') ? d.value : '' + value: (typeof d.value != 'undefined') ? d.value : value } var data = { -- 2.11.4.GIT