123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- o2.widget = o2.widget || {};
- o2.require("o2.widget.ScriptArea", null, false);
- //o2.require("o2.widget.CssEditor", null, false);
- o2.widget.CssArea = new Class({
- Implements: [Options, Events],
- Extends: o2.widget.ScriptArea,
- options: {
- "title": "CssArea",
- "style": "default",
- "helpStyle" : "default",
- "maxObj": document.body,
- "isload": false,
- "key": "code"
- },
- initialize: function(node, options){
- this.setOptions(options);
- this.node = $(node);
- this.container = new Element("div");
- this.path = o2.session.path+"/widget/$CssArea/";
- this.cssPath = o2.session.path+"/widget/$CssArea/"+this.options.style+"/css.wcss";
- this._loadCss();
- },
- toJson: function(){
- return (this.editor) ? {"code": this.editor.getValue(), "html": this.editor.getValue()} : this.contentCode;
- },
- createContent: function(content){
- this.contentNode = new Element("div", {
- "styles": this.css.contentNode
- }).inject(this.container);
- this.resizeContentNodeSize();
- this.contentCode = content;
- if (!content || !content.code){
- this.referenceNode.setStyle("background", "url("+o2.session.path+"/widget/$ScriptArea/"+this.options.style+"/icon/reference_empty.png) center center no-repeat")
- }
- if (this.options.isload){
- this.loadEditor(content);
- }else{
- var inforNode = new Element("div", {"styles": this.css.inforNode, "text": o2.LP.widget.clickToEditCss }).inject(this.contentNode);
- var _self = this;
- inforNode.addEvent("click", function(){
- this.destroy();
- _self.loadEditor(content);
- });
- }
- },
- loadEditor: function(content){
- var value=(content) ? content.code : "";
- value = (value) ? value : "";
- this.jsEditor = new o2.widget.JavascriptEditor(this.contentNode,{
- "option": {
- "mode": "css",
- "value": value,
- "lineNumbers": false
- },
- "onPostLoad": function(){
- this.editor = this.jsEditor.editor;
- this.editor.id = "2";
- this.jsEditor.addEditorEvent("change", function() {
- this.fireEvent("change");
- }.bind(this));
- this.jsEditor.addEditorEvent("blur", function() {
- this.fireEvent("blur");
- }.bind(this));
- // this.editor.on("change", function() {
- // this.fireEvent("change");
- // }.bind(this));
- // this.editor.on("blur", function() {
- // this.fireEvent("blur");
- // }.bind(this));
- this.jsEditor.resize();
- this.fireEvent("postLoad");
- }.bind(this),
- "onSave": function(){
- this.fireEvent("change");
- this.fireEvent("save");
- }.bind(this)
- });
- this.jsEditor.load();
- //this.bind(content);
- this.createScriptReferenceMenu();
- this.jsEditor.addEvent("reference", function(editor, e, e1){
- if (!this.scriptReferenceMenu){
- this.createScriptReferenceMenu(this.showReferenceMenu.bind(this));
- }else{
- this.showReferenceMenu();
- }
- }.bind(this));
- this.referenceNode.setStyle("background", "url("+o2.session.path+"/widget/$ScriptArea/"+this.options.style+"/icon/reference.png) center center no-repeat")
- }
- });
|