mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
자동저장 관련 기능 지원
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7889 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
37d945e64f
commit
3c5c2d214a
2 changed files with 56 additions and 13 deletions
|
|
@ -4,7 +4,7 @@ if (!window.xe) xe = {};
|
|||
if (!xe.Editors) xe.Editors = [];
|
||||
|
||||
function editorStart_xe(editor_seq, primary_key, content_key, editor_height, colorset, content_style, content_font, content_font_size) {
|
||||
var $textarea, $form, $input, saved_str, xeed, as;
|
||||
var $textarea, $form, $input, saved_str, xeed, opt = {};
|
||||
|
||||
if(typeof(colorset)=='undefined') colorset = 'white';
|
||||
if(typeof(content_style)=='undefined') content_style = 'xeStyle';
|
||||
|
|
@ -17,16 +17,14 @@ function editorStart_xe(editor_seq, primary_key, content_key, editor_height, col
|
|||
|
||||
if($input[0]) $textarea.val($input.remove().val()).attr('name', content_key);
|
||||
$textarea.attr('name', content_key);
|
||||
|
||||
// Use auto save feature?
|
||||
opt.use_autosave = !!$form[0].elements['_saved_doc_title'];
|
||||
|
||||
// create an editor
|
||||
xe.Editors[editor_seq] = xeed = new xe.Xeed($textarea);
|
||||
xe.Editors[editor_seq] = xeed = new xe.Xeed($textarea, opt);
|
||||
xe.registerApp(xeed);
|
||||
|
||||
// 자동 저장 사용
|
||||
if (as=$form[0].elements['_saved_doc_title']) {
|
||||
//xeed.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
|
||||
}
|
||||
|
||||
// Set standard API
|
||||
editorRelKeys[editor_seq] = {
|
||||
primary : $form[0][primary_key],
|
||||
|
|
@ -35,6 +33,9 @@ function editorStart_xe(editor_seq, primary_key, content_key, editor_height, col
|
|||
func : function(){ return xeed.cast('GET_CONTENT'); },
|
||||
pasteHTML : function(text){ xeed.cast('PASTE_HTML', [text]); }
|
||||
};
|
||||
|
||||
// Auto save
|
||||
if (opt.use_autosave) xeed.registerPlugin(new xe.Xeed.AutoSave());
|
||||
|
||||
return xeed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ Xeed = xe.createApp('Xeed', {
|
|||
this.registerPlugin(new SChar);
|
||||
this.registerPlugin(new Table);
|
||||
this.registerPlugin(new URL);
|
||||
this.registerPlugin(new AutoSave);
|
||||
this.registerPlugin(new FileUpload);
|
||||
this.registerPlugin(new Clear);
|
||||
|
||||
|
|
@ -126,6 +125,16 @@ Xeed = xe.createApp('Xeed', {
|
|||
var v = this._options[key];
|
||||
if (is_def(v)) return v;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Set option
|
||||
* @param key String option key
|
||||
* @param key Variant option value
|
||||
* @syntax oApp.setOption('keyName', 'value')
|
||||
*/
|
||||
setOption : function(key, val) {
|
||||
try { this._options[key] = val; }catch(e){};
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Set default option
|
||||
|
|
@ -190,6 +199,20 @@ Xeed = xe.createApp('Xeed', {
|
|||
return 'xeed' + Math.ceil(Math.random() * 1000) + (''+(new Date).getTime()).substr(8);
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Fake interface for editor_common.js
|
||||
*/
|
||||
getFrame : function(seq) {
|
||||
var self = this;
|
||||
|
||||
return {
|
||||
editor_sequence : seq,
|
||||
getSelectedHTML : function(){},
|
||||
setFocus : function(){ self.cast('SET_FOCUS'); },
|
||||
replaceHTML : function(html){ self.cast('PASTE_HTML', [html]) }
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Get an HTML code of the content
|
||||
* @param Reserved slot for html code
|
||||
|
|
@ -2849,25 +2872,43 @@ Table = xe.createPlugin('Table', {
|
|||
* {{{ AutoSave
|
||||
*/
|
||||
AutoSave = xe.createPlugin('AutoSave', {
|
||||
_enable : false,
|
||||
$bar : null,
|
||||
$text : null,
|
||||
_enable : false,
|
||||
_start_time : null,
|
||||
_save_time : null,
|
||||
$bar : null,
|
||||
$text : null,
|
||||
|
||||
init : function(){ },
|
||||
activate : function() {
|
||||
var app = this.oApp;
|
||||
var self = this, app = this.oApp, $form;
|
||||
|
||||
// start time
|
||||
this._start_time = (new Date).getTime();
|
||||
|
||||
// set default option
|
||||
app.setDefault('use_autosave', false);
|
||||
this._enable = app.getOption('use_autosave');
|
||||
|
||||
this.$bar = this.oApp.$root.find('div.time').hide();
|
||||
this.$bar = this.oApp.$root.find('div.time').hide().click(function(){ $(this).slideUp(300) });
|
||||
|
||||
if (this._enable && window.editorEnableAutoSave) {
|
||||
$form = $(app.$textarea[0].form);
|
||||
editorEnableAutoSave($form[0], $form.attr('editor_sequence'), function(params){ self._save_callback(params) });
|
||||
}
|
||||
},
|
||||
deactivate : function() {
|
||||
this.$bar.unbind();
|
||||
},
|
||||
_save_callback : function(params) {
|
||||
this.$bar.slideDown(300);
|
||||
},
|
||||
API_EXEC_AUTOSAVE : function() {
|
||||
_editorAutoSave(true, this._save_callback);
|
||||
},
|
||||
API_ENABLE_AUTOSAVE : function(sender, params) {
|
||||
var b = this._enable = !!params[0];
|
||||
|
||||
app.setOption('use_autosave', b);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
|
@ -4740,6 +4781,7 @@ else xe.Xeed = Xeed;
|
|||
|
||||
xe.W3CDOMRange = W3CDOMRange;
|
||||
xe.HuskyRange = HuskyRange;
|
||||
xe.Xeed.AutoSave = AutoSave;
|
||||
|
||||
// run callback functions
|
||||
if ($.isArray(xe.Xeed.callbacks) && xe.Xeed.callbacks.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue