Sha256: bec58dc926ff69b734a63a60ae976c00c95c2018983f00041d9a29bc26728946

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

module MxitRails
  module Styles

    # Not sure whether a Constant is the neatest/nicest way of storing these?
    StyleList = {}

    def self.get name
      StyleList[name.to_sym]
    end

    def self.add name, content
      content.strip!
      if content[-1] != ';'
        content += ';'
      end
      StyleList[name.to_sym] = content
    end

    Emoticons =  {
      happy: [':)', ':-)'],
      sad: [':(', ':-('],
      winking: [";)", ";-)"],
      excited: [':D', ':-D'],
      shocked: [':|', ':-|'],
      surprised: [':O', ':-O'],
      tongue_out: [':P', ':-P'],
      embarrassed: [':$', ':-$'],
      cool: ['8-)'],
      heart: ['(H)'],
      flower: ['(F)'],

      # V 3.0. smileys
      male: ['(m)'],
      female: ['(f)'],
      star: ['(*)'],
      chilli: ['(c)'],
      kiss: ['(x)'],
      idea: ['(i)'],
      extremely_angry: [':e', ':-e'],
      censored: [':x', ':-x'],
      grumpy: ['(z)'],
      coffee: ['(U)'],
      mr_green: ['(G)'],

      # V 5.0 smileys
      sick: [':o('],
      wtf: [':{', ':-{'],
      in_love: [':}', ':-}'],
      rolling_eyes: ['8-o', '8o'],
      crying: [':\'('],
      thinking: [':?', ':-?'],
      drooling: [':~', ':-~'],
      sleepy: [':z', ':-z'],
      liar: [':L)'],
      nerdy: ['8-|', '8|'],
      pirate: ['P-)'],
      bored: [':[', ':-['],
      cold: [':<', ':-<'],
      confused: [':,', ':-,'],
      hungry: [':C', ':-C'],
      stressed: [':s', ':-s'],
    }

    def self.add_emoticons source
      output = source
      Emoticons.each do |name, searches|
        searches.each do |search|
          output.gsub! search, "<span class=\"emoticon #{name}\" title=\"#{name} #{search}\">#{search}</span>"
        end
      end
      output
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mxit-rails-0.4.3 lib/mxit_rails/styles.rb
mxit-rails-0.4.2 lib/mxit_rails/styles.rb
mxit-rails-0.4.1 lib/mxit_rails/styles.rb
mxit-rails-0.4.0 lib/mxit_rails/styles.rb
mxit-rails-0.3.4 lib/mxit_rails/styles.rb
mxit-rails-0.3.3 lib/mxit_rails/styles.rb
mxit-rails-0.3.2 lib/mxit_rails/styles.rb