Skip to content

Commit

Permalink
[#738 state:resolved] Improved handling of link group field type (add…
Browse files Browse the repository at this point in the history
…ing focus to the label element when the "Add Link" button is pressed) and removed dependency upon the jquery JSON plugin because it was allegedly conflicting with TypeCore's JSON library. In a future release we should replaced TypeCore's JSON library with a jquery library, reversing this implementation.
  • Loading branch information
byrnereese committed Feb 7, 2011
1 parent 076f3de commit c8a649c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm
Expand Up @@ -504,7 +504,7 @@ sub type_link_group {
my ( $ctx, $field_id, $field, $value ) = @_;
my $static = $app->static_path;
$value = '"[]"' if ( !$value || $value eq '' );
eval "\$value = $value";
eval "\$value = \"$value\"";
if ($@) { $value = '"[]"'; }
my $list;
eval { $list = JSON::from_json($value) };
Expand Down Expand Up @@ -542,7 +542,7 @@ sub type_link_group {
var l = \$(this).html();
struct.push( { 'url': u, 'label': l } );
});
var json = \$.toJSON(struct);
var json = struct.toJSON().escapeJS();
\$('#'+'$field_id').val( json );
});
\$('#'+'$field_id-link-group ul li a.remove').click( handle_delete_click );
Expand Down Expand Up @@ -1067,7 +1067,7 @@ sub _hdlr_field_link_group {
my $field = $ctx->stash('field') or return _no_field($ctx);
my $value = _get_field_value($ctx);
$value = '"[]"' if ( !$value || $value eq '' );
eval "\$value = $value";
eval "\$value = \"$value\"";
if ($@) { $value = '[]'; }
my $list = JSON::from_json($value);

Expand Down Expand Up @@ -1468,7 +1468,6 @@ END_TMPL
</mt:unless>
<script src="<mt:PluginStaticWebPath component="configassistant">js/options.js" type="text/javascript"></script>
<script src="<mt:PluginStaticWebPath component="configassistant">colorpicker/js/colorpicker.js" type="text/javascript"></script>
<script src="<mt:PluginStaticWebPath component="configassistant">js/jquery.json-2.2.min.js" type="text/javascript"></script>
</mt:setvarblock>
END_TMPL

Expand Down
12 changes: 7 additions & 5 deletions addons/ConfigAssistant.pack/static/js/options.js
@@ -1,12 +1,14 @@
// Utility Functions
function handle_edit_click() {
var link = $(this).parent().find('a.link');
var p = $(this).parent();
var link = p.find('a.link');
if (link.length > 0) {
$(this).parent().replaceWith( render_link_form( link.html(), link.attr('href') ) );
p.replaceWith( render_link_form( link.html(), link.attr('href') ) );
} else {
$(this).parent().before( render_link_form( '','' ) );
$(this).parent().hide();
p.before( render_link_form( '','' ) );
p.hide();
}
p.parent().find('input.label').focus();
return false;
};
function render_link(label,url) {
Expand Down Expand Up @@ -42,7 +44,7 @@ function render_link_form(label,url) {
e.find('button').trigger('click');
return false;
}
});
});
}).blur( function() {
$(this).unbind('keypress');
});
Expand Down
3 changes: 1 addition & 2 deletions addons/ConfigAssistant.pack/tmpl/theme_options.mtml
Expand Up @@ -43,13 +43,12 @@
<link rel="stylesheet" href="<$mt:PluginStaticWebPath component="configassistant"$>css/app.css" type="text/css" />
<link rel="stylesheet" href="<$mt:PluginStaticWebPath component="configassistant"$>colorpicker/css/colorpicker.css" type="text/css" />
<mt:unless tag="ProductName" eq="Melody">
<script src="<$mt:StaticWebPath$>jquery/jquery.js" type="text/javascript"></script>
<script src="<mt:StaticWebPath>jquery/jquery.js" type="text/javascript"></script>
</mt:unless>
<script src="<$mt:PluginStaticWebPath component="configassistant"$>js/jquery.history.js" type="text/javascript"></script>
<script src="<$mt:PluginStaticWebPath component="configassistant"$>js/app.js" type="text/javascript"></script>
<script src="<$mt:PluginStaticWebPath component="configassistant"$>js/options.js" type="text/javascript"></script>
<script src="<$mt:PluginStaticWebPath component="configassistant"$>colorpicker/js/colorpicker.js" type="text/javascript"></script>
<script src="<$mt:PluginStaticWebPath component="configassistant"$>js/jquery.json-2.2.min.js" type="text/javascript"></script>
</mt:setvarblock>

<mt:var name="screen_id" value="theme_options">
Expand Down

0 comments on commit c8a649c

Please sign in to comment.