Commit 6316bf99 authored by Lingnan Wu's avatar Lingnan Wu

change the table editor for using the jquery sheet

parent f1163e98
...@@ -4,104 +4,75 @@ ...@@ -4,104 +4,75 @@
*/ */
SheetEditor = function() { SheetEditor = function() {
this.name = "JQuery Sheet Editor"; this.name = "JQuery Sheet Editor";
this.objectName = "SheetEditor" // name of the object reference
this.load = function() { this.load = function() {
$("#jQuerySheet0").sheet({ $('#jQuerySheet').sheet({
buildSheet: '10x15',
title: 'Spreadsheet Playground', title: 'Spreadsheet Playground',
inlineMenu: inlineMenu($.sheet.instance) inlineMenu: inlineMenu(jQuery.sheet.instance),
buildSheet: '10x20',
autoFiller: true
}); });
} }
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 this.saveEdition = function() {
saveEdition: function(content) { var sheetNumber = jQuery.sheet.instance[0].exportSheet.html().length;
this.setLastUser(getCurrentUser()); var a="";
this.setContent(content); for(var i=0;i<sheetNumber;i++){
this.setLastModification(getCurrentTime()); var objE=document.createElement("div");
this.setAsCurrentDocument(); objE.appendChild(jQuery.sheet.instance[0].exportSheet.html()[i]);
}, a=a+objE.innerHTML;
//display document information
setAsCurrentDocument: function() {
getCurrentPage().displayDocumentTitle(this);
//getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this);
} }
}); getCurrentDocument().saveEdition(a);
}
getCurrentDocument = function() { this.loadContentFromDocument = function(doc) {
var doc = new JSONSheetDocument(); if(doc.getContent()){
doc.load(JSON.parse(localStorage.getItem("currentDocument"))); jQuery.sheet.instance[0].killTab();
return doc; var o=parseDom(doc.getContent());
tryUntilSucceed(load = function() {
$('#jQuerySheet').sheet({
title: 'Spreadsheet Playground',
inlineMenu: inlineMenu(jQuery.sheet.instance),
buildSheet: o,
autoFiller:true
});
}
);
}
}
this.load();
} }
function inlineMenu(I){
I = (I ? I.length : 0);
//we want to be able to edit the html for the menu to make them multi-instance
function inlineMenu(instance) {
var I = (instance ? instance.length : 0);
var html = $('#inlineMenu').html().replace(/sheetInstance/g, "$.sheet.instance[" + I + "]"); var html = $('#inlineMenu').html().replace(/sheetInstance/g, "$.sheet.instance[" + I + "]");
var menu = $(html);
menu.find('.colorPickerCell') var menu = $(html);
.colorPicker() //The following is just so you get an idea of how to style cells
.change(function() { menu.find('.colorPickerCell').colorPicker().change(function(){
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted()); $.sheet.instance[I].cellChangeStyle('background-color', $(this).val());
$.sheet.instance[I].obj.cellHighlighted().css('background-color', $(this).val());
$.sheet.instance[I].cellUndoable.add($.sheet.instance[I].obj.cellHighlighted());
}); });
menu.find('.colorPickerFont') menu.find('.colorPickerFont').colorPicker().change(function(){
.colorPicker() $.sheet.instance[I].cellChangeStyle('color', $(this).val());
.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') menu.find('.colorPickers').children().eq(1).css('background-image', "url('jquery.sheet/images/palette.png')");
.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/images/palette_bg.png')");
menu.find('.colorPickers')
.children().eq(3).css('background-image', "url('jquery_sheet_editor/jquery_sheet_image/palette_bg.png')");
return menu; return menu;
} }
function goToObj(s) { JSONDocument.prototype.type = "table";
$('html, body').animate({ JSONDocument.prototype.saveEdition = function(content) {
scrollTop: $(s).offset().top this.setLastUser(getCurrentUser().getName());
}, 'slow'); this.setContent(content);
return false; this.setLastModification(getCurrentTime());
getCurrentPage().displayDocumentInformation(this);
} }
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