From c92bf4fc7a3bdcbb6510282564518d76a2c63414 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 4 Jan 2013 20:48:47 -0500 Subject: [PATCH] i18n for outfits/edit.js sharing urls --- app/views/outfits/edit.html.haml | 10 ++++++- public/javascripts/outfits/edit.js | 47 +++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index 6fd720bb..a6506dd8 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -115,12 +115,20 @@ %div %dt= search_query_with_helper '.search.examples.type' %dd= search_query_description '.search.examples.type' - #preview-search-form-loading= '.search.loading' + #preview-search-form-loading= t '.search.loading' #preview-search-form-error.possible-error #preview-search-form-no-results = t '.search.no_results_html', :query => content_tag(:span) %ul #no-assets-full-message= t '.sidebar.closet.no_data.description' + %script#sharing-html-image-template{:type => 'text/x-jquery-tmpl'} + = link_to image_tag('${image_url}'), '${permalink}' + %script#sharing-html-text-template{:type => 'text/x-jquery-tmpl'} + = link_to t('app_name'), '${permalink}' + %script#sharing-bbcode-image-template{:type => 'text/x-jquery-tmpl'} + [URL=${permalink}][IMG]${image_url}[/IMG][/URL] + %script#sharing-bbcode-text-template{:type => 'text/x-jquery-tmpl'} + [URL=${permalink}]#{t('app_name')}[/URL] %script#outfit-template{:type => 'text/x-jquery-tmpl'}
  • %header diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index 8370daa0..7e9ac917 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -715,26 +715,53 @@ View.Outfits = function (wardrobe) { }; var format_selector_els = $('#preview-sharing-url-formats li'); var thumbnail_el = $('#preview-sharing-thumbnail'); + var templates = { + html: { + image: $('#sharing-html-image-template'), + text: $('#sharing-html-text-template') + }, + bbcode: { + image: $('#sharing-bbcode-image-template'), + text: $('#sharing-bbcode-text-template') + } + } + function templateHTML(template, options) { + var contents = template.tmpl(options); + var contentsHTML = contents.clone().wrap('
    ').parent().html(); + return contentsHTML; + } + + // The HTML and BBCode formats could probably be handled more dynamic-like. var formats = { plain: { - image: function (url) { return url }, - text: function (url) { return url } + image: function (image_url) { return image_url }, + text: function (permalink) { return permalink } }, html: { - image: function (url, permalink) { - return ''; + image: function (image_url, permalink) { + return templateHTML(templates.html.image, { + image_url: image_url, + permalink: permalink + }); }, - text: function (url) { - return 'Dress to Impress'; + text: function (permalink) { + return templateHTML(templates.html.text, { + permalink: permalink + }); } }, bbcode: { - image: function (url, permalink) { - return '[URL=' + permalink + '][IMG]' + url + '[/IMG][/URL]'; + image: function (image_url, permalink) { + return templateHTML(templates.bbcode.image, { + image_url: image_url, + permalink: permalink + }); }, - text: function (url) { - return '[URL=' + url + ']Dress to Impress[/URL]'; + text: function (permalink) { + return templateHTML(templates.bbcode.text, { + permalink: permalink + }); } } };