tb_media 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e599f4b4028bbd60d0ffd260da07f780efbf275d
4
- data.tar.gz: ed8b87939c2736898875f1b3e11c2af028f6f309
3
+ metadata.gz: 1387c1ba0eb754c7363e2c2beab5a4d94af6dc96
4
+ data.tar.gz: 0fa036c28e19bd7cbf0d53d4062c271095bc680d
5
5
  SHA512:
6
- metadata.gz: fc2b408053de8cfb801419c3ba72997440bb82da364ed7c195195fa56ffea30886448a72268d1f6fea73f6f2e3e10621bad1337ae0e6947d5dff67228d32017f
7
- data.tar.gz: e7f7e50010f62c106520846b054c2bf20e46f6026790940908456da289ebb5418d4d06c07480906276263e372e2f4c65c0af6d4809c71c9a10e73586c6a54840
6
+ metadata.gz: aee37a7b86e49d30a95b1b1c7634503096a49b51b53285a9a95c1023ae356466e8aa66c6a09ef505cd61161b692faa5cc1e99ea1c6b23beb123d13e7fb6ae849
7
+ data.tar.gz: 01cca18ee17a2d9e8764ff1ffffd8010487e01411dfb9b6e22cb4c8c18c569b83e045b406c1272528ea21f3c1b66fd95cdcd39df738520bac23007e8f2f0583a
@@ -13,6 +13,8 @@ spud.admin.mediapicker = new function(){
13
13
  var self = this;
14
14
  var supportsHtml5Upload = false;
15
15
  var selectedFile = {};
16
+ var currentPage = 1;
17
+ var pageIsLoading = false;
16
18
 
17
19
  self.init = function(){
18
20
  if(typeof(FormData) != 'undefined'){
@@ -29,6 +31,41 @@ spud.admin.mediapicker = new function(){
29
31
  $('.spud_media_picker_tab_advanced').on('spud_media_picker_tab_activated', self.activatedAdvancedTab);
30
32
  $('.spud_media_picker_option_dimensions').on('blur', 'input', self.dimensionsChanged);
31
33
  $('.spud_media_picker_option').on('keyup', 'input[type=text]', self.pickerOptionKeyDown);
34
+ $('.spud_media_picker_list').on('scroll', onListScroll);
35
+ };
36
+
37
+ var onListScroll = function(e){
38
+ var list = $(this);
39
+ var children = list.children();
40
+ var listHeight = list.height();
41
+ var scrollHeight = (children.length * children.first().outerHeight()) - listHeight;
42
+ if(list.scrollTop() >= scrollHeight){
43
+ loadNextPage();
44
+ }
45
+ };
46
+
47
+ var loadNextPage = function(){
48
+ if(pageIsLoading){
49
+ return;
50
+ }
51
+ pageIsLoading = true;
52
+ currentPage++;
53
+ $.ajax('/admin/media_picker', {
54
+ data: {
55
+ page: currentPage,
56
+ only_list: true
57
+ },
58
+ dataType: 'html',
59
+ success: function(html){
60
+ if(html.trim() === ''){
61
+ $('.spud_media_picker_list').off('scroll', onListScroll);
62
+ }
63
+ else{
64
+ $('.spud_media_picker_list').append(html);
65
+ }
66
+ pageIsLoading = false;
67
+ }
68
+ });
32
69
  };
33
70
 
34
71
  self.clickedTab = function(e){
@@ -76,7 +76,7 @@
76
76
  cursor: pointer;
77
77
  padding: 3px;
78
78
  font: normal 12px/20px sans-serif;
79
- border-top: 1px solid #ccc;
79
+ border-bottom: 1px solid #ccc;
80
80
  overflow: hidden;
81
81
  height: 20px;
82
82
  white-space: nowrap;
@@ -87,8 +87,8 @@
87
87
  -ms-user-select: none;
88
88
  user-select: none;
89
89
  }
90
- .spud_media_picker_item:first-child{
91
- border-top: none;
90
+ .spud_media_picker_item:last-child{
91
+ border-bottom: none;
92
92
  }
93
93
  .spud_media_picker_item:last-child{
94
94
  border-bottom: 1px solid #ccc;
@@ -6,8 +6,16 @@ class Admin::MediaPickerController < Admin::ApplicationController
6
6
  respond_to :html
7
7
 
8
8
  def index
9
- @media = SpudMedia.all
10
- respond_with @media
9
+ @media = SpudMedia.order('attachment_file_name asc').paginate(:page => params[:page], :per_page => 30)
10
+ respond_with @media do |format|
11
+ format.html{
12
+ if params[:only_list]
13
+ render :partial => 'media', :collection => @media
14
+ else
15
+ render 'index'
16
+ end
17
+ }
18
+ end
11
19
  end
12
20
 
13
21
  def create
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Media
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_media
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Westlake Design
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails