Commit 11f81591 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Adding mime object to OfficeJS

We can select files in the slickgrid document lister and the good application
will be loaded with the good file. Extensions are hidden.
parent afb2be24
...@@ -58,18 +58,6 @@ $().ready(function() { ...@@ -58,18 +58,6 @@ $().ready(function() {
<i class="icon-download-alt icon-white"></i> <i class="icon-download-alt icon-white"></i>
Save Save
</button>&nbsp; </button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load($('#input_fileName').attr('value'));">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove($('#input_fileName').attr('value'));">
<i class="icon-remove icon-white"></i>
Remove
</button>
</div> </div>
<div id="elrte_editor"> <div id="elrte_editor">
<h1>OfficeJS elRTE texteditor</h1><p>This is a new document.<br></p> <h1>OfficeJS elRTE texteditor</h1><p>This is a new document.<br></p>
......
...@@ -217,18 +217,6 @@ function goToObj(s){ ...@@ -217,18 +217,6 @@ function goToObj(s){
<i class="icon-download-alt icon-white"></i> <i class="icon-download-alt icon-white"></i>
Save Save
</button>&nbsp; </button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load($('#input_fileName').attr('value'));">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove($('#input_fileName').attr('value'));">
<i class="icon-remove icon-white"></i>
Remove
</button>
</div> </div>
<div id="jQuerySheet" class="jQuerySheet" style="height: 450px;"> <div id="jQuerySheet" class="jQuerySheet" style="height: 450px;">
</div> </div>
......
...@@ -44,15 +44,15 @@ ...@@ -44,15 +44,15 @@
New Spreadsheet New Spreadsheet
</a> </a>
</li> </li>
<li class="editpreferences left-nav-tools"> <!-- <li class="editpreferences left-nav-tools"> -->
<a href="#/editpreferences" <!-- <a href="#/editpreferences" -->
onclick="javascript: <!-- onclick="javascript: -->
OfficeJS.open({app:'editpreferences'}); <!-- OfficeJS.open({app:'editpreferences'}); -->
return false;"> <!-- return false;"> -->
<i class="icon-check"></i> <!-- <i class="icon-check"></i> -->
Edit Preferences <!-- Edit Preferences -->
</a> <!-- </a> -->
</li> <!-- </li> -->
<li id="nav_document_list_header left-nav-tools"> <li id="nav_document_list_header left-nav-tools">
<a href="#/doclist" <a href="#/doclist"
onclick="javascript: onclick="javascript:
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<!-- <!--
(function () { (function () {
var grid, onSortFunction, onClickFunction, checkboxselector, var grid, onSortFunction, onClickFunction, checkboxselector,
onRemoveSeveral, onRemoveSeveral, showIconFormatter,
documentlist = OfficeJS.cloneCurrentDocumentList(), documentlist = OfficeJS.cloneCurrentDocumentList(),
columns = [], columns = [],
options = { options = {
...@@ -54,13 +54,33 @@ ...@@ -54,13 +54,33 @@
forceFitColumns: true forceFitColumns: true
}; };
showIconFormatter = function (row,cell,value,columnDef,dataContext) {
return dataContext.icon;
};
(function (array) { (function (array) {
var i, lm, cd; var i, lm, cd, split, mime;
// FIXME : we can have 2012/1/1 12:5
// we should have 2012/01/01 12:05
for (i = 0; i < array.length; i += 1) { for (i = 0; i < array.length; i += 1) {
// TODO : create fileNameWithoutExt and fileApplication // file names
// according to the file extension. split = array[i].fileName.split('.');
array[i].fileExt = '';
if (split.length > 1) {
array[i].fileExt = split[split.length-1];
split.length -= 1;
}
array[i].fileBaseName = split.join('.');
// app & icon
mime = OfficeJS.getMimeOfExt (array[i].fileExt);
if (!mime) {
array[i].icon = '?';
array[i].app = 'textEditor';
} else {
array[i].icon = mime.icon;
array[i].app = mime.pref || mime.app;
}
// dates
// FIXME : we can have 2012/1/1 12:5
// we should have 2012/01/01 12:05
lm = (new Date(array[i].lastModified)); lm = (new Date(array[i].lastModified));
cd = (new Date(array[i].creationDate)); cd = (new Date(array[i].creationDate));
array[i].lastModified = lm.getFullYear()+'/'+ array[i].lastModified = lm.getFullYear()+'/'+
...@@ -72,7 +92,6 @@ ...@@ -72,7 +92,6 @@
} }
}(documentlist)); }(documentlist));
$(function () { $(function () {
checkboxselector = new Slick.CheckboxSelectColumn({ checkboxselector = new Slick.CheckboxSelectColumn({
...@@ -80,9 +99,10 @@ ...@@ -80,9 +99,10 @@
}); });
columns.push(checkboxselector.getColumnDefinition()); columns.push(checkboxselector.getColumnDefinition());
columns.push({id:"icon",name:"",field:"icon", columns.push({id:"icon",name:"",field:"icon",
sortable:true,resizable:false,width:24}); sortable:true,resizable:false,width:24,
formatter:showIconFormatter});
columns.push({id:"fileName",name:"Document", columns.push({id:"fileName",name:"Document",
field:"fileName",sortable:true}); field:"fileBaseName",sortable:true});
columns.push({id:"lastModified",name:"Modified", columns.push({id:"lastModified",name:"Modified",
field:"lastModified",sortable:true}); field:"lastModified",sortable:true});
columns.push({id:"creationDate",name:"Created", columns.push({id:"creationDate",name:"Created",
...@@ -119,7 +139,7 @@ ...@@ -119,7 +139,7 @@
onClickFunction = function (e) { onClickFunction = function (e) {
var cell = grid.getCellFromEvent(e); var cell = grid.getCellFromEvent(e);
if (cell.cell === grid.getColumnIndex('fileName')) { if (cell.cell === grid.getColumnIndex('fileName')) {
OfficeJS.open({app:'textEditor', OfficeJS.open({app:documentlist[cell.row].app,
fileName:documentlist[cell.row].fileName}); fileName:documentlist[cell.row].fileName});
} }
}; };
......
...@@ -10,18 +10,6 @@ ...@@ -10,18 +10,6 @@
<i class="icon-download-alt icon-white"></i> <i class="icon-download-alt icon-white"></i>
Save Save
</button>&nbsp; </button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load($('#input_fileName').attr('value'));">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove($('#input_fileName').attr('value'));">
<i class="icon-remove icon-white"></i>
Remove
</button>
</div> </div>
<iframe src="lib/svg-edit/svg-editor.html" <iframe src="lib/svg-edit/svg-editor.html"
id="svg_edit_frame" id="svg_edit_frame"
......
This diff is collapsed.
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