'use strict';

/**
 * plugin.js
 *
 * Released under LGPL License.
 * Copyright (c) 2015 SIRAP SAS All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

/*global tinymce:true */

var Paginator = require('./classes/Paginator');
var Page = require('./classes/Page');

tinymce.PluginManager.add('paginate', function(editor) {

  var paginator = new Paginator();
  var page = new Page();

  editor.on('change',function(evt){
    var doc = editor.getDoc();
    var height = $(doc).height();
    console.log(height);
  });

});

@@ -290,16 +290,50 @@
 ator');%0A
+var ui = require('.utils/ui');%0A// 
 var Page
@@ -431,113 +431,536 @@
 var 
-paginator = new Paginator
+display;%0A  var paginator;%0A%0A  // Create and display pages navigation buttons%0A  ui.appendNavigationButtons
 ();%0A
+%0A%0A
   
-var page = new Page();%0A%0A  editor.on('change',function(evt)%7B%0A    var doc = 
+editor.on('init',function(evt)%7B%0A%0A    // console.log('editor.getWin()',editor.getWin().frameElement);%0A%0A    paginator = new Paginator('A4','portait', editor.getDoc());%0A%0A    // on first load, fill paginator with editor.getContent();%0A    // editor.once('change',function(evt)%7B%0A    // %7D);%0A    editor.on('change',function(evt)%7B%0A      // console.log(new Error().stack);%0A      // console.log('change');%0A      paginator.fill(
 edit
@@ -969,52 +969,135 @@
 .get
-Doc
+Content
 ()
+)
 ;%0A    
-var height = $(doc).height();
+  // paginator.watchPage(paginator.pages%5B0%5D);%0A    %7D);%0A  %7D);%0A%0A%0A%0A  editor.on('SetContent',function(evt,a)%7B
 %0A   
+ //
  con
@@ -1109,14 +1109,26 @@
 log(
-height
+'setcontent',evt,a
 );%0A 
@@ -1133,12 +1133,13 @@
 %0A  %7D);%0A%0A
+%0A
 %7D);%0A

use new implemented classes and instanciate on editor events