diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-05-17 06:48:29 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-05-17 06:48:29 +0400 |
commit | 1f87f85c1a20557f34b08cdde6ea9bc137a43822 (patch) | |
tree | 72567661449d045189b7add0366df7315712f8e9 | |
parent | 229a3f213f1102c197549e282d6324416d9412cf (diff) |
Refs #2135
* Fixes "The input field for the segment's name disappers on focus loss"
-rw-r--r-- | plugins/SegmentEditor/templates/Segmentation.js | 13 | ||||
-rw-r--r-- | plugins/SegmentEditor/templates/selector.tpl | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/plugins/SegmentEditor/templates/Segmentation.js b/plugins/SegmentEditor/templates/Segmentation.js index 8e2050ea25..6b8bfc7ee7 100644 --- a/plugins/SegmentEditor/templates/Segmentation.js +++ b/plugins/SegmentEditor/templates/Segmentation.js @@ -509,8 +509,6 @@ Segmentation = (function($) { function openEditFormGivenSegment(option) { var segment = {}; segment.idsegment = option.attr("data-idsegment"); - segment.name = option.attr("title"); - segment.definition = option.data("definition"); var segmentExtra = getSegmentFromId(segment.idsegment); @@ -518,6 +516,8 @@ Segmentation = (function($) { { segment[item] = segmentExtra[item]; } + segment.name = option.attr("title"); + segment.definition = option.data("definition"); openEditForm(segment); } @@ -548,9 +548,11 @@ Segmentation = (function($) { $(self.form).off("blur", "input#edit_segment_name").on("blur", "input#edit_segment_name", function(e){ var newName = $(this).val(); - $(e.currentTarget).parents("h3").find("span").text(newName).show(); - $(self.form).find("a.editSegmentName").show(); - $(this).remove(); + if(newName.trim() != '') { + $(e.currentTarget).parents("h3").find("span").text(newName).show(); + $(self.form).find("a.editSegmentName").show(); + $(this).remove(); + } }); $(self.form).on("click", '.segment-element', function(event) { @@ -844,7 +846,6 @@ Segmentation = (function($) { if(typeof mode !== "undefined" && mode == "new") { $(self.form).find(".editSegmentName").trigger('click'); - $(self.form).find("#edit_segment_name").val(""); } $("#segmentList").hide(); diff --git a/plugins/SegmentEditor/templates/selector.tpl b/plugins/SegmentEditor/templates/selector.tpl index ff4b583f18..f4802d8db3 100644 --- a/plugins/SegmentEditor/templates/selector.tpl +++ b/plugins/SegmentEditor/templates/selector.tpl @@ -125,7 +125,7 @@ </div> {/if} - <h3>{'General_Name'|translate}: <span class="segmentName">{'SegmentEditor_NewSegment'|translate}</span> <a class="editSegmentName" href="#">{'General_Edit'|translate|strtolower}</a></h3> + <h3>{'General_Name'|translate}: <span class="segmentName"></span> <a class="editSegmentName" href="#">{'General_Edit'|translate|strtolower}</a></h3> </div> <div class="segment-footer"> <span class="segmentFooterNote">The Segment Editor was <a href='http://crowdfunding.piwik.org/custom-segments-editor/' target='_blank'>crowdfunded</a> with the awesome support of 80 companies and Piwik users worldwide!</span> |