Sha256: 8c2c6f6c61736dad5af6b9fde3e7dfae947f33b73425a967900bca36a6c7369c

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

{I"
class:ETI"BundledAsset;FI"logical_path;TI"cms/user.js;FI"
pathname;TI"k/usr/local/rvm/gems/ruby-2.1.2/bundler/gems/browsercms-a0b88590276e/app/assets/javascripts/cms/user.js;FI"content_type;TI"application/javascript;TI"
mtime;Tl+æTI"length;TiFI"digest;TI"%c107bb6281eb49553f8518275b4805dc;FI"source;TI"F// Determine if an element exists.
//  i.e. if($('.some-class').exists()){ // do something }
jQuery.fn.exists = function() {
  return this.length > 0;
};
// Sets up the Cms namespace for other modules.
var Cms = Cms || {};



Cms.User = function() {
};

// Find the current user and then take action based on whether the current user is authenticated or not.
// @todo - Avoid repeated AJAX calls to find the user if this is involved multiple times.
//
// @param [ObjectLiteral] options
// @option options [Function] :authenticated Call for authenticated users.
// @option options [Function] :guest (Optional) Call for guests.
//
// @example  Cms.User.current({
//    authenticated: function(user){ alert("Hello " + user.first_name);
// }); 
Cms.User.current = function(handler) {
  $.getJSON('/cms/user.json', function(user) {
//    console.log("current_user", user);
    if (user.is_logged_in) {
      handler.authenticated(user);
    } else if (handler.guest) {
      handler.guest(user);
    }
  });
};

// Default Handler for login portlet. Hide the form, show 'Hello $first_name'
jQuery(function($){
  if ($('.login-portlet').exists()) {
    Cms.User.current({
        authenticated: function(user) {
          $('.authenticated').show().find('.first-name').html(user.first_name);
          $('.guest').hide();
        }
      }
    );
  }
});

;TI"required_assets_digest;TI"%33994146a0ffabdb2d59bf451b953cd7;FI"
_version;TI"%5ef14a844324cba3e114bd0123f88a5e;F

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
bcms_spree-0.0.2 test/dummy/tmp/cache/assets/development/sprockets/22c7c609985b60f2578929e4357e8ab4
bcms_spree-0.0.2 test/dummy/tmp/cache/assets/development/sprockets/971b8b8eb6668c330e01def3aa8b93e8
bcms_spree-0.0.1 test/dummy/tmp/cache/assets/development/sprockets/22c7c609985b60f2578929e4357e8ab4
bcms_spree-0.0.1 test/dummy/tmp/cache/assets/development/sprockets/971b8b8eb6668c330e01def3aa8b93e8