Sha256: 6cbfe36114abd53be24075c2b3f407fbf194c6266c16a33022ae17184038f1dc

Contents?: true

Size: 765 Bytes

Versions: 16

Compression:

Stored size: 765 Bytes

Contents

module Maglove
  module Widgets
    class Base
      include Hamloft::Helpers
      attr_accessor :options

      def identifier
        "base"
      end

      def defaults
        {}
      end

      def initialize(options)
        @options = defaults.merge(options)
      end

      def typeloft_widget_options
        attributes = {
          :class => "_typeloft_widget",
          :"data-widget-identifier" => identifier
        }
        @options.each do |k, v|
          if k == :padding or k == :margin
            [:top, :right, :bottom, :left].each do |dir|
              attributes["data-attribute-#{k}_#{dir}"] = v
            end
          end
          attributes["data-attribute-#{k}"] = v
        end
        attributes
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
maglove-widgets-1.1.9 lib/maglove/widgets/base.rb
maglove-widgets-1.1.8 lib/maglove/widgets/base.rb
maglove-widgets-1.1.7 lib/maglove/widgets/base.rb
maglove-widgets-1.1.6 lib/maglove/widgets/base.rb
maglove-widgets-1.1.5 lib/maglove/widgets/base.rb
maglove-widgets-1.1.4 lib/maglove/widgets/base.rb
maglove-widgets-1.1.3 lib/maglove/widgets/base.rb
maglove-widgets-1.0.8 lib/maglove/widgets/base.rb
maglove-widgets-1.0.7 lib/maglove/widgets/base.rb
maglove-widgets-1.0.6 lib/maglove/widgets/base.rb
maglove-widgets-1.0.5 lib/maglove/widgets/base.rb
maglove-widgets-1.0.4 lib/maglove/widgets/base.rb
maglove-widgets-1.0.3 lib/maglove/widgets/base.rb
maglove-widgets-1.0.2 lib/maglove/widgets/base.rb
maglove-widgets-1.0.1 lib/maglove/widgets/base.rb
maglove-widgets-1.0.0 lib/maglove/widgets/base.rb