Sha256: 0a946706999295fa0ce9f21b5219a838ec7907cb4e0dc2234ce2fe7c6ebcc475

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

module Netzke
  #
  # An invisible component that provides feedback service for all Netzke widgets
  #
  class FeedbackGhost < Base
    def self.js_base_class
      "Ext.Component" # yes, invisible
    end

    def self.js_extend_properties
      {
        :show_feedback => <<-JS.l,
          function(msg){
            var createBox = function(s, l){
                return ['<div class="msg">',
                        '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
                        '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">', s, '</div></div></div>',
                        '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
                        '</div>'].join('');
            }

            var showBox = function(msg, lvl){
              if (!lvl) lvl = 'notice';
              var msgCt = Ext.DomHelper.insertFirst(document.body, {'class':'netzke-feedback'}, true);
              var m = Ext.DomHelper.append(msgCt, {html:createBox(msg,lvl)}, true);
              m.slideIn('t').pause(2).ghost("b", {remove:true});
            }

            if (typeof msg != 'string') {
              var compoundMsg = "";
              Ext.each(msg, function(m){
                compoundMsg += m.msg + '<br>';
              })
              if (compoundMsg != "") showBox(compoundMsg, null) // the second parameter will be level
            } else {
              showBox(msg)
            }
        	}
        JS
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
netzke-core-0.2.10 lib/netzke/feedback_ghost.rb
netzke-core-0.2.11 lib/netzke/feedback_ghost.rb
netzke-core-0.2.6 lib/netzke/feedback_ghost.rb
netzke-core-0.2.7 lib/netzke/feedback_ghost.rb
netzke-core-0.2.8 lib/netzke/feedback_ghost.rb
netzke-core-0.2.9 lib/netzke/feedback_ghost.rb