Sha256: ea3869afff19283e2bb106c8f69f6f5db824908e6ac778832d73c7358903386d

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

module Slippery
  module Processors
    module ImpressJs
     class AddImpressJs
       include ProcessorHelpers

       def self.call(doc)
         self.new.call(doc)
       end

       attr_reader :attributes

       DEFAULT_ATTRS = {
        'transition-duration' => 1000
      }.freeze

       def initialize(path_composer, attributes = {})
         @path_composer = path_composer
         @attributes = DEFAULT_ATTRS.merge(attributes).freeze
       end

       def call(doc)
         doc.replace('body') do |body|
           include_local_javascript(body, @path_composer.call('impress.js/js/impress.js'))
             .set_attrs({id: 'impress'}.merge(data_attributes(attributes)))
             .add H[:script, 'impress().init();']
         end
       end
     end
   end
 end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slippery-0.1.0 lib/slippery/processors/impress_js/add_impress_js.rb