From 141b708392003db51da620a086f8a88cf4e95047 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Sat, 14 Sep 2013 18:18:59 +0800 Subject: [PATCH] widget code rewritten for gallery master branch --- .../app/assets/images/gallery/nodata.jpg | Bin 0 -> 12657 bytes .../panel/gallery/widget/albums_controller.rb | 31 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100755 vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg diff --git a/vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg b/vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg new file mode 100755 index 0000000000000000000000000000000000000000..d3c857b6b60e374db099ebc86b9e48307644be79 GIT binary patch literal 12657 zcmeG?c|6qXyWcT(vbQfLYvUwl>`sy`M%EcZr_`7kObx@#SaMoXsZKcu2^EDOp8q|;8N(&;1`qGj&${mzW&bnovjpZmxC+}`@W%kw_(v%SyrF5?y56?G{1yCt&2 z5yaaYF+mVS5mCh<2p(!UBpWiEq@D<>TZfa2bGWN$M~VH&#*yEZihS4x@u0 z#kk4C^$OgK5o1XRP(TRqRpZE5T?gu|8`+2~lt2-A2?YV z{35vmErNZoMJUvDC#8W~Ei+78u1P}A14>js ztQ6f9y+KqleU`X*BQm1D5jCuZFxR4ZqWefHqN=Eq@=2;qO77hR$Wz9ee48n z?XlY06Esz^Bq_v=Z*$xj6_qh+V>Hy%G<4L|)O65HO-DRL^FKpCbPmx}L=ur~JWdah z(Zu03aiWKyq_U_U=Lk~D;jjb(qX`clBP%Dbps1v*g8Q};hsfZiof-&E7KfLSm621B zSCqr6T0o~JUUs?`NzTciuB{iljx4Y9$KE5(`UYdE=ff;4dC9k26bv(HJss~De5-MV zRVhZUnE_0<3q=C!@wWpzS-nS7FSf)z?VD$uRlL4>dwuJ(_xp}rYI`nR5FWoFyX1Jo zovwZx_n?S`jXO$f8rxqCXd*H)AgwGWlY+dQ6(+)Tl9nt;5UZyxM_%`b4l2QU>a89N zgRl->a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v7g^B&DAuVlKAqXvt74v?oJbfV-p@32Bx*J9?0j_ z7AY5%9nwCT9sH=vwy1QQd(`Hu!M`K2%XzSFm#8M-%FiuZx?x3OMajWUv8py&d%_b< zmd2Y*RXI>|k6LUltKkH(Lv2X9I$MFryqaUKI_FgRIM2cI1F`mei<29U6)sLtK?*^a z6IZhLTn`9VGu;sxcEN;Xl6PkE_&t5BK@WrCQqP961v!^rPu!H7qZL(s-x+}=`cfv5 zxo}xG=ax&_($_)q+M9!1bCQ+W#vumjNmk~+S0o!LUo8#o2j6^}{%qL{3+veAEt882 zn{wk1Eo7I!7<{oXOh~>ohA5BMzaDwLf5T#>2fxBhdN5ANo|sI3+xL5?U_!O-wU{%W zDc5?t(mZ>n8o9DqiGPN8+)QV|Hd_KaAG!rHV5+7U939Agu{3eY<04p+(!w-9eDqgG z18!aPu=hxuNK$xy+LU&S9#XjBw8kzP)opAT#X_DiaYo4|fuB#sIq-;8uWqm|^n7y8 zRJhig)7y84#t0A|*mp1aRGu3vckW4(?$ZYN69jZ-%jZm|rG}p|J$(6H-pZde&L5fW zS)0}w?(yn1k))(KFmqk-%rr);)uG~F{6QM8iO1{IEOVEe(YL4Qq?oqM_oZ#FKlI0S ze;QRtR!m*@OOtnp6Jb$uR2cZe&))Lmw>|gT?Qt?MMWy2W?NgKPE%IwC$6GD;OkH8_ zsc6D|3@g>4v74AfZWnmf$9g&g1f?36o;Q?tlr3_2w{UY{a*id-wM6mL5#D7bgNN~3 zSA|yG?rgOjq)oi=x^J2;ZS$nREG8wV$m|OyemcOg_b6+vemC!Sfu)vOwr=Fkb=^YG z`jV!=oI{EA=4ZId1rr-$ts4&KeTrAe*hLqToAn#YgYbGcRE*wS7JM`sfXU8jPRyRV ziJogmB%O#&sxZnfRj#jHIFZ=tBkn)b68-sabCvertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6 @class = "c" + @settings["horizontal"].to_s @total = @settings["vertical"] * @settings["horizontal"] @rnd = Random.new @images = [] - for i in 0..@total-1 - image = @album_images[@rnd.rand(0...@album_images.count)] - values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} - @images << values + + if @album_images.count > @total + @randoms = [] + until @randoms.count == @total do + r = @rnd.rand(0...@album_images.count) + if !@randoms.include?r + @randoms << r + image = @album_images[r] + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + end + elsif @album_images.count == @total + @album_images.each do |image| + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + else + @album_images.each do |image| + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + until @images.count == @total do + values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} + @images << values + end end end