dex.module = function(div_id, module_index, editable) { this.div_id = div_id; this.module_index = module_index; this.div = document.getElementById(div_id); this.div.module = this; this.url = dex.page.url; this.module_id = this.div.className.match(new RegExp('module[0-9]+','gi'))[0].substr(6); if (typeof(editable) == 'undefined') { this.editable = true; } else { this.editable = editable; } this.on_render = function(o) { //var response = o.responseText.replace('/dex\.load\.subscribe/si','dex.load.onclick'); YAHOO.plugin.Dispatcher.process(this.div, o.responseText); dex.load.insert(); this.div = document.getElementById(this.div_id); this.div.module = this; this.render(); // dex.page.module_not_loading(); dex.page.assign_function_to_elements(); if (this.need_to_save_changes) { dex.page.changes_where_made(); this.need_to_save_changes = false; } }; this.render = function() { // Set form only after first render if (this.editable) { dex.load.onclick('yahoo.dex.ddmodule',this.render_dragdrop,{scope:this}); } }; this.render_dragdrop = function() { var h3 = this.div.getElementsByTagName('H3')[0]; if (h3) { if (h3.className=='headline') { // Enable DD only if headline var dd = new YAHOO.dex.DDmodule(this.div_id); dd.setHandleElId(h3); } this.editor_presenter = dex.utils.getElementsByClass('module_edit_presenter', this.div, 'div'); if (this.editor_presenter) { this.editor = dex.utils.getElementsByClass('module_edit_holder', this.editor_presenter, 'div'); if (this.editor) { var edit_btn = dex.utils.getElementsByClass('edit', h3, 'a'); var close_btn = dex.utils.getElementsByClass('close', h3, 'a'); if (edit_btn) { edit_btn.module_index = this.module_index; YAHOO.util.Event.addListener(edit_btn, "click", function(e) {dex.page.modules[module_index].edit()},0, this); } if (close_btn) { YAHOO.util.Event.addListener(close_btn, "click", function(e) {this.remove(e)},0, this); } this.form = dex.utils.getElementsByClass('module_edit', this.editor, 'form'); if (this.form) { var submit_button = dex.utils.getElementsByClass('add_submit', this.form, 'input'); submit_button.module_index = this.module_index; submit_button.setAttribute("onclick", "dex.page.load_module_from_form(this.module_index, this.form)"); submit_button.onclick = function() {dex.page.load_module_from_form(this.module_index, this.form)}; } } } } }; this.set_style = function(style) { var a = this.div.className.split(' '); var b = ""; for(var i=0; i