Commit 171dc6d4 authored by François Billioud's avatar François Billioud

rename editor files

parent 8b160ac6
/**
* This file provides classes needed by the text editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
var Xinha = function() {
this.name = "Xinha";
this.load = function() {
_editor_url = "xinha/";
getCurrentPage().include("xinha/XinhaCore.js","script");
getCurrentPage().include("xinha/config.js","script");
xinha_init();
}
this.saveEdition = function() {
getCurrentDocument().saveEdition(xinha_editors.input_area.getEditorContent());
}
this.loadContentFromDocument = function(doc) {
var setText = function() {xinha_editors.input_area.setEditorContent(doc.getContent());}
tryUntilSucceed(setText);
}
this.load();
}
/**
* Text documents
* editable documents must implements the following methods
* getType : returns the type of a document
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var JSONTextDocument = function() {
JSONDocument.call(this);//inherits properties from JSONDocument
this.type = "text";
}
JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONTextDocument.prototype.saveEdition = function(content) {
this.setContent(content);
this.setLastModification(currentTime());
this.setAsCurrentDocument();
}
JSONTextDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayAuthorName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this);
}
getCurrentDocument = function() {
var doc = new JSONTextDocument();
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
return doc;
}
/**
* This file provides classes needed by the illustration editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
SVGEditor = function() {
this.name = "svg-editor";
this.load = function() {$("#svgframe").attr("src", "svg-edit/svg-editor.html");}
this.saveEdition = function() {
var s = "svgframe";
getCurrentDocument().saveEdition(window.frames[s].svgCanvas.getSvgString());
}
this.loadContentFromDocument = function(doc) {
tryUntilSucceed(function() {window.frames["svgframe"].svgEditor.loadFromString(doc.getContent());});
}
this.load();
}
/**
* SVG documents
* editable documents must implements the following methods
* getType : returns the type of a document
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var JSONIllustrationDocument = function() {
JSONDocument.call(this);//inherits properties from JSONDocument
this.type = "illustration";
}
JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONIllustrationDocument.prototype.saveEdition = function(content) {
this.setContent(content);
this.setLastModification(currentTime());
this.setAsCurrentDocument();
}
JSONIllustrationDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayAuthorName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this);
}
getCurrentDocument = function() {
var doc = new JSONIllustrationDocument();
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
return doc;
}
/**
* Editors
*/
SheetEditor = function() {
this.name = "JQuery Sheet Editor";
this.load = function() {
$("#jQuerySheet0").sheet({
buildSheet: '10x15',
title: 'Spreadsheet Playground',
inlineMenu: inlineMenu($.sheet.instance)
});
}
this.saveEdition = function() {}
this.loadContentFromDocument = function(doc) {}
this.load();
}
/***
* Spreadsheet documents
*/
var JSONSheetDocument = function() {
JSONDocument.call(this);//inherits from JSONDocument
this.type = "sheet";
this.width = 10;
this.height = 15;
}
JSONSheetDocument.prototype = new JSONDocument();//inheritance
//accessors
JSONSheetDocument.prototype.load({
getWidth: function() {return this.width;},
setWidth: function(newWidth) {this.width = newWidth;},
getHeight: function() {return this.height;},
setHeight: function(newHeight) {this.height = newHeight;},
//save process
saveEdition: function(content) {
this.setContent(content);
this.setLastModification(currentTime());
this.setAsCurrentDocument();
},
//display document information
setAsCurrentDocument: function() {
getCurrentPage().displayDocumentTitle(this);
//getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayAuthorName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this);
}
});
getCurrentDocument = function() {
var doc = new JSONSheetDocument();
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
return doc;
}
function inlineMenu(instance) {
var I = (instance ? instance.length : 0);
var html = $('#inlineMenu').html().replace(/sheetInstance/g, "$.sheet.instance[" + I + "]");
var menu = $(html);
menu.find('.colorPickerCell')
.colorPicker()
.change(function() {
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted());
$.sheet.instance[I].obj.cellHighlighted().css('background-color', $(this).val());
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted());
});
menu.find('.colorPickerFont')
.colorPicker()
.change(function() {
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted());
$.sheet.instance[I].obj.cellHighlighted().css('color', $(this).val());
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted());
});
menu.find('.colorPickers')
.children().eq(1).css('background-image', "url('jquery_sheet_editor/jquery_sheet_image/palette.png')");
menu.find('.colorPickers')
.children().eq(3).css('background-image', "url('jquery_sheet_editor/jquery_sheet_image/palette_bg.png')");
return menu;
}
function goToObj(s) {
$('html, body').animate({
scrollTop: $(s).offset().top
}, 'slow');
return false;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment