Permalink
Browse files

Updated _b plugin

  • Loading branch information...
1 parent 41f37ed commit 20997a364b697267f5c1b106a4184ef059ae70e4 @boriscy committed Feb 27, 2013
Showing with 19 additions and 16 deletions.
  1. +1 −1 lib/assets/version.rb
  2. +18 −15 vendor/assets/javascripts/plugins/_b.coffee
View
@@ -1,3 +1,3 @@
module Assets
- VERSION = "1.0.5"
+ VERSION = "1.0.6"
end
@@ -13,8 +13,8 @@
""
# Returns the value with decimals
roundVal: (val, dec) ->
- dec ||= 0
- if dec == 0
+ dec or= 0
+ if dec is 0
Math.round(val)
else
Math.round(val * Math.pow(10, dec)) / Math.pow(10, dec)
@@ -24,7 +24,7 @@
ntc: (val, precision) ->
precision = if precision >= 0 then precision else @numPresicion
- val = if typeof val == 'string' then (1 * val) else val
+ val = if typeof val is 'string' then (1 * val) else val
if val < 0 then sign = "-" else sign = ""
@@ -37,17 +37,17 @@
c = 0
for i in [l..0]
tmp = ar[i] + tmp
- if (l - i + 1)%3 == 0 and i < l
+ if (l - i + 1)%3 is 0 and i < l
arr.push(tmp)
tmp = ''
c++
t = arr.reverse().join(@numDelimiter)
- if tmp != ""
+ if tmp isnt ""
sep = if t.length > 0 then @numDelimiter else ""
t = tmp + sep + t
- if precision == 0
+ if precision is 0
sign + t
else
sign + t + @numSeparator + vals[1]
@@ -67,7 +67,7 @@
roundVal( bytes/ Math.pow(1024, 6)) + " EB"
notEnter: (event) ->
- ( event.type == "keyup" or event.type == "keypress" ) and event.keyCode != 13
+ ( event.type is "keyup" or event.type is "keypress" ) and event.keyCode isnt 13
# creates Image tag
createImagetag: (path, image, options = {}) ->
@@ -86,14 +86,17 @@
$('<div/>').append( img ).html()
# Returns an image with the correct file extension
- getExtnameImage: (ext) ->
- if ext == ".pdf" then return "/assets/pdf.png"
- if ext == ".xls" or ext == ".xlsx" then return "/assets/excel.png"
- if ext == ".doc" or ext == ".docx" then return "/assets/word.png"
- if ext == ".html" or ext == ".htm" then return "/assets/html.png"
- if ext == ".pps" or ext == ".ppt" or ext == ".pptx" then return "/assets/powerpoint.png"
- if ext == ".psd" then return "/assets/photoshop.png"
- else "/assets/file.png"
+ getExtnameImage: (file) ->
+ file = file.split('.')
+ ext = file[file.length - 1]
+ switch ext.toLowerCase()
+ when "pdf" then return "/assets/pdf.png"
+ when "xls", "xlsx", "xlsm" then return "/assets/excel.png"
+ when "doc", "docx" then return "/assets/word.png"
+ when "html", "htm" then return "/assets/html.png"
+ when "pps", "ppt", "pptx" then return "/assets/powerpoint.png"
+ when "psd" then return "/assets/photoshop.png"
+ else "/assets/file.png"
# Function to determine background colors
idealTextColor: (bgColor) ->

0 comments on commit 20997a3

Please sign in to comment.