Sha256: 19d2c404733c70cb53067180f669a3bf75007bd11c033ad9e9f53efc6eee0b3e

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

/* 
  Class: Application.Poller
  The poller periodically sends requests to the server to verify that the current
  user is still editing this page. It also handles takeover actions when another
  user takes over editing.
  
  Only ONE instance of Application.Poller can be active. Only the first
  instance will be registered into Application.Poller.current.
  
  Parameters:
  url - The URL to poll.
*/
Application.Poller = new Class({
  initialize : function(url){
    if(!url || Application.Poller.current){ return; }
    
    this.url = url;
    
    Application.Poller.current = this;
    this.poller = this.poll.periodical(5000,this);
  },
  poll : function(){
    var request = new Request.JSON({url: this.url });
    request.addEvent("success",this.handlePollResponse.bind(this));
    request.get();
  },
  handlePollResponse : function(response,text){
    if(!response.current_editor){
      $clear(this.poller);
      var d  = new Skyline.Dialog();
      d.setContent(response.message);
      if(response.title){
        d.setTitle(response.title);
      }
      d.show();
    }
  },
  handleTakeOverAction : function(){
    var action = $('takeoverAction_ignore').get("checked") ? "ignore" : "new";
    var newVariantName = $('takeoverActionNewVariantName').get("value");
    
    if(action == "ignore"){
      window.location = window.location;
    } else {
      $('clone_variant').set("value","1");
      $('page_variants_attributes_1_name').set("value",newVariantName);
      $('page_form').submit();
    }
  }  
});
Application.Poller.current = null;

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
skylinecms-3.3.0 public/skyline/javascripts/src/poller.js
skylinecms-3.2.0 public/skyline/javascripts/src/poller.js
skylinecms-3.1.0 public/skyline/javascripts/src/poller.js
westarete-skylinecms-3.0.8.20100329 public/skyline/javascripts/src/poller.js
westarete-skylinecms-3.0.8.20100330 public/skyline/javascripts/src/poller.js
skylinecms-3.0.8 public/skyline/javascripts/src/poller.js
skylinecms-3.0.7 public/skyline/javascripts/src/poller.js