2022-02-25 10:39:13 +08:00
|
|
|
/**
|
|
|
|
* Created with JetBrains PhpStorm.
|
|
|
|
* User: xuheng
|
|
|
|
* Date: 12-8-8
|
|
|
|
* Time: 下午2:09
|
|
|
|
* To change this template use File | Settings | File Templates.
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
var me = editor,
|
|
|
|
preview = $G( "preview" ),
|
|
|
|
preitem = $G( "preitem" ),
|
|
|
|
tmps = templates,
|
|
|
|
currentTmp;
|
|
|
|
var initPre = function () {
|
|
|
|
var str = "";
|
|
|
|
for ( var i = 0, tmp; tmp = tmps[i++]; ) {
|
|
|
|
str += '<div class="preitem" onclick="pre(' + i + ')"><img src="' + "images/" + tmp.pre + '" ' + (tmp.title ? "alt=" + tmp.title + " title=" + tmp.title + "" : "") + '></div>';
|
|
|
|
}
|
|
|
|
preitem.innerHTML = str;
|
|
|
|
};
|
|
|
|
var pre = function ( n ) {
|
|
|
|
var tmp = tmps[n - 1];
|
|
|
|
currentTmp = tmp;
|
|
|
|
clearItem();
|
|
|
|
domUtils.setStyles( preitem.childNodes[n - 1], {
|
|
|
|
"background-color":"lemonChiffon",
|
|
|
|
"border":"#ccc 1px solid"
|
|
|
|
} );
|
|
|
|
preview.innerHTML = tmp.preHtml ? tmp.preHtml : "";
|
|
|
|
};
|
|
|
|
var clearItem = function () {
|
|
|
|
var items = preitem.children;
|
|
|
|
for ( var i = 0, item; item = items[i++]; ) {
|
|
|
|
domUtils.setStyles( item, {
|
|
|
|
"background-color":"",
|
|
|
|
"border":"white 1px solid"
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
dialog.onok = function () {
|
|
|
|
if ( !$G( "issave" ).checked ){
|
|
|
|
me.execCommand( "cleardoc" );
|
|
|
|
}
|
|
|
|
var obj = {
|
|
|
|
html:currentTmp && currentTmp.html
|
|
|
|
};
|
|
|
|
me.execCommand( "template", obj );
|
|
|
|
};
|
|
|
|
initPre();
|
|
|
|
window.pre = pre;
|
|
|
|
pre(2)
|
|
|
|
|
2021-12-24 10:17:17 +08:00
|
|
|
})();
|