diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index b3c65108..56d882cf 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -121,14 +121,19 @@ = 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 @@ -151,6 +156,7 @@ %a.outfit-delete-confirmation-no{:href => '#'} = t '.sidebar.outfits.outfit.delete_confirmation.cancel'
  • + %script#item-template{:type => 'text/x-jquery-tmpl'} %li{:class => 'object object-${id}'} %img{:src => '${thumbnail_url}', :title => '${description}', :alt => ''} @@ -171,6 +177,27 @@ {{/if}} {{/if}} %span.no-assets-message= t '.sidebar.closet.no_data.summary' + + %script#pagination-template{:type => 'text/x-jquery-tmpl'} + {{if current_page > 1}} + = link_to t('will_paginate.previous_label').html_safe, '#', :rel => 'prev', + 'data-page' => '${current_page - 1}' + {{/if}} + + {{each pages}} + {{if $value == 'gap'}} + %span.gap= t('will_paginate.page_gap').html_safe + {{else $value == current_page}} + %em.current ${$value} + {{else}} + = link_to '${$value}', '#', 'data-page' => '${$value}' + {{/if}} + {{/each}} + + {{if current_page < total_pages}} + = link_to t('will_paginate.next_label').html_safe, '#', :rel => 'next', + 'data-page' => '${current_page + 1}' + {{/if}} %span#userbar-session-message - if user_signed_in? diff --git a/config/locales/will_paginate.en-meep.yml b/config/locales/will_paginate.en-meep.yml new file mode 100644 index 00000000..fcf2b59d --- /dev/null +++ b/config/locales/will_paginate.en-meep.yml @@ -0,0 +1,18 @@ +en-meep: + will_paginate: + previous_label: "← Preevious" + next_label: "Neext →" + page_gap: "…!" + + page_entries_info: + single_page: + zero: "No %{model} meeped" + one: "Meeping 1 %{model}" + other: "Meeping all %{count} %{model}" + single_page_html: + zero: "No %{model} meeped" + one: "Meeping 1 %{model}" + other: "Meeping all %{count} %{model}" + + multi_page: "Meeping %{model} %{from} - %{to} of %{count} in total" + multi_page_html: "Meeping %{model} %{from} - %{to} of %{count} in total" diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index 58bde75d..39049a5c 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -1086,19 +1086,12 @@ View.Search = function (wardrobe) { PAGINATION = { INNER_WINDOW: 4, OUTER_WINDOW: 1, - GAP_TEXT: '…', - PREV_TEXT: '← Previous', - NEXT_TEXT: 'Next →', - PAGE_EL: $('', {href: '#'}), - CURRENT_EL: $('', {'class': 'current'}), EL_ID: '#preview-search-form-pagination', - PER_PAGE: 21 + PER_PAGE: 21, + TEMPLATE: $('#pagination-template') }, object_width = 112, last_request; PAGINATION.EL = $(PAGINATION.EL_ID); - PAGINATION.GAP_EL = $('', {'class': 'gap', html: PAGINATION.GAP_TEXT}) - PAGINATION.PREV_EL = $('', {href: '#', rel: 'prev', html: PAGINATION.PREV_TEXT}); - PAGINATION.NEXT_EL = $('', {href: '#', rel: 'next', html: PAGINATION.NEXT_TEXT}); $(PAGINATION.EL_ID + ' a').live('click', function (e) { e.preventDefault(); @@ -1205,33 +1198,28 @@ View.Search = function (wardrobe) { subtract_left = (left_gap[1] - left_gap[0]) > 1; subtract_right = (right_gap[1] - right_gap[0]) > 1; - - PAGINATION.EL.children().remove(); - - if(current_page > 1) { - PAGINATION.PREV_EL.clone().data('page', current_page - 1).appendTo(PAGINATION.EL); - } + + var pages = []; while(i <= total_pages) { if(subtract_left && i >= left_gap[0] && i < left_gap[1]) { - PAGINATION.GAP_EL.clone().appendTo(PAGINATION.EL); + pages.push('gap'); i = left_gap[1]; } else if(subtract_right && i >= right_gap[0] && i < right_gap[1]) { - PAGINATION.GAP_EL.clone().appendTo(PAGINATION.EL); + pages.push('gap'); i = right_gap[1]; } else { - if(i == current_page) { - PAGINATION.CURRENT_EL.clone().text(i).appendTo(PAGINATION.EL); - } else { - PAGINATION.PAGE_EL.clone().text(i).data('page', i).appendTo(PAGINATION.EL); - } + pages.push(i); i++; } } - - if(current_page < total_pages) { - PAGINATION.NEXT_EL.clone().data('page', current_page + 1).appendTo(PAGINATION.EL); - } + + PAGINATION.EL.empty(); + PAGINATION.TEMPLATE.tmpl({ + current_page: current_page, + total_pages: total_pages, + pages: pages + }).appendTo(PAGINATION.EL); }); wardrobe.search.bind('error', function (error) {