You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/lmrxedit/lmrxedit.js

48 lines
3.3 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

$(function() {
//html5支持本地存储
if(!window.localStorage){
alert('This browser does NOT support HTML5 localStorage.');
}
//加载信息内容
var info_content = $(window.opener.document).find('.lmrxedit').val();
$('#lmrxedit').html(info_content);
//禁止所有链接跳转
$(document).on('click', 'a', function() {return false;});
//初始化编辑器
$('#lmrxedit *').lmrxeditor({'debug':true});
//右侧菜单-保存。
$(document).on('click', '#lmrxedit_save', function() {
var _this = $(this);
$(this).removeClass('btn-primary').addClass('btn-success').html('保存中');
//删除高亮属性
$('#lmrxedit').find('.lmrx_hl').removeClass('lmrx_hl');
//删除class=""
var txt = $('#lmrxedit').html();
txt = txt.replace(/ class=""/g, '');
//回写并触发保存
$(window.opener.document).find('.lmrxedit').val(txt);
$(window.opener.document).find('#ignore_seo_check,#ignore_url_check').prop('checked', true);
$(window.opener.document).find('.btn-group.pull-right a.btn.btn-info').trigger('click');
setTimeout(function() {
_this.removeClass('btn-success').addClass('btn-primary').html('保存');
}, 5000);
});
//范例模板
$(document).on('click', '#lmrx_example', function() {
var y = prompt('请输入 “yes” 确认调用默认模板。', 'no');
if (y == 'yes') {
var ex1 = '\
<h2>标题</h2>\
<img alt="玉器" src="http://images.arachina.com/2014/01/the_tang_paradise8f9a20b15655_cp_318x211.jpg" class="lmrx_img_right">\
<p>模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本\
模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本\
模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本\
模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本\
模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本</p>\
<p>模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本模板文本测试</p>\
';
$('#lmrxedit').html(ex1+ex1+ex1);
$('#lmrxedit *').lmrxeditor({'debug':true});
}
});
});