dex.page = {
set_nodeid: function(nodeid) {
this.nodeid = nodeid;
},
set_type: function(type) {
this.type = type;
},
set_pagename : function(name) {
this.pagename = name;
},
modules_chooser : function(parameters) {
this.config = parameters;
dex.load.onclick("dex.dialog", function(){
dex.page.modules_chooser_load(this.config)
},{scope:this})
},
modules_chooser_load : function(parameters) {
this.process_answer = function(answer) {
// Remove line breaks
var response = answer.replace(new RegExp("[\n|\r|\f]", 'g'),"");
// Get edit form
var regex = new RegExp('(
]+)[\'\"]", 'i'), 'href="javascript://"');
response = '
'+module_html+'
'+form+'
';
return response;
};
this.process_content = function(content) {
var len;
var editor_presenter = dex.utils.getElementsByClass('module_edit_presenter',content);
var form = YAHOO.util.Selector.query('form', editor_presenter, true);
content.module = true;
var submit_button = dex.utils.getElementsByClass('add_submit', editor_presenter,'input');
var self = this;
// submit_button.setAttribute("onclick", "dex.page.add_module_from_form(this.form, '"+this.module_name+"')");
submit_button.onclick = function() {dex.page.add_module_from_form(this.form, self.module_name)};
var selects = YAHOO.util.Selector.query('select', form);
len = selects.length;
for(var i=0;i
';
for (i = 0;form.elements[i]; i++ ){
if (form.elements[i].name){
if (form.elements[i].name.trim() == 'moduleid'){
moduleid = form.elements[i].value.trim();
}
else {
query+= '&'+form.elements[i].name.trim() + '=' + escape(dex.utils.utf8_encode(form.elements[i].value.trim()));
}
}
}
YAHOO.util.Connect.asyncRequest('GET', this.url+'/module/'+moduleid+'/?'+query, {
cache:false,
success: dex.page.render_module_preview,
scope: this}
);
return false;
},
render_module_preview : function(o){
var module_html = o.responseText.replace(new RegExp("[\n|\r|\f]", 'gi'),"");
module_html = module_html.replace(new RegExp("href\s*=\s*[\"\']?([^\'\">]+)[\'\"]", 'gi'),'href="javascript://"');
// Remove form
module_html = module_html.replace(new RegExp("(.*)
", 'gi'),'');
var regex = new RegExp('(
c[i].offsetHeight || !longest)) {
longest = c[i].offsetHeight;
longestelm = c[i];
}
}
return longestelm;
},
get_page_colors : function(){
if (!this.css_link || !this.css_link.parentNode) {
this.css_link = document.getElementById("css_link");
this.css_link_base = this.css_link.href.split("?")[0];
this.colors = new Array();
var parts = '';
var key = '';
if ( this.css_link.href.indexOf("?") != -1){
var params = this.css_link.href.split("?")[1];
var param = params.split("&");
for (var i = 0; i < param.length; ++i){
parts = param[i].split("=");
if (parts[0]=='bg'){
this.bg = parts[1];
}
else if(parts[0]!='time') {
this.colors[parts[0]] = parts[1];
}
}
}
}
return this.colors
},
reload_css : function(){
if (!this.css_link || !this.css_link.parentNode) {
this.css_link = document.getElementById("css_link");
}
YAHOO.plugin.Dispatcher.cssLoader(this.css_link.href, {cache: false, override: true, styleElement: 'css_link'});
},
set_page_color : function (field, value){
this.colors[field] = value;
var url = this.css_link_base+'?';
url+=field+'='+value;
for(var name in this.colors){
if (name != field){
url+='&'+name;
if (this.colors[name]) {
url+='='+this.colors[name];
}
}
}
url+='&bg='+this.bg;
this.css_link.href = url;
this.reload_css();
return this.colors;
},
set_color : function(color) {
this.get_page_colors();
this.set_page_color('color', color);
this.changes_where_made();
},
set_navcolor1 : function(color) {
this.get_page_colors();
this.set_page_color('navcolor1', color);
this.changes_where_made();
},
set_navcolor2 : function(color) {
this.get_page_colors();
this.set_page_color('navcolor2', color);
this.changes_where_made();
},
set_fontcolor : function(color) {
this.get_page_colors();
this.set_page_color('fontcolor', color);
this.changes_where_made();
},
set_linkcolor : function(color) {
this.get_page_colors();
this.set_page_color('linkcolor', color);
this.changes_where_made();
},
set_linkcolor1 : function(color) {
this.get_page_colors();
this.set_page_color('linkcolor1', color);
this.changes_where_made();
},
set_linkcolor2 : function(color) {
this.get_page_colors();
this.set_page_color('linkcolor2', color);
this.changes_where_made();
},
set_bgcolor : function(color) {
this.get_page_colors();
this.set_page_color('bgcolor', color);
this.changes_where_made();
},
set_boxcolor : function(color) {
this.get_page_colors();
this.set_page_color('boxcolor', color);
this.changes_where_made();
},
set_boxbordercolor : function(color) {
this.get_page_colors();
this.set_page_color('boxbordercolor', color);
this.changes_where_made();
},
changes_where_made : function() {
this.save();
},
dont_forget_to_save : function() {
return 'You made changes to this page. If you click OK you will loose them.';
},
set_signature_hash : function(hash) {
this.signature_hash = hash;
},
save : function(){
var params = 'method=save_layout';
var i, l, j, h, k, g, col, parts, moduleid, settings, s;
g = 0;
for (i = 0; this.container[i]; i++){
if ((this.container[i].className.indexOf('editable')!=-1)){
col = 0;
l = this.container[i].getElementsByTagName('div');
for (j = 0; j module_number
this.module_refs = new Array;
if (nodeid) this.set_nodeid(nodeid);
if (type) this.set_type(type);
if (page) this.set_pagename(page);
// Get containers
for(i = 0; document.getElementById('container_'+(i+1)); i++ ) {
this.container[i] = document.getElementById('container_'+(i+1));
if (i == 0) {
YAHOO.util.Dom.addClass(this.container[i].parentNode, 'drag_enable');
}
}
},
subscribe: function(subscriber, event) {
},
unsubscribe: function(subscriber, event) {
},
notify: function(notifier, event) {
}
};
YAHOO.register("dex.page", dex.page, {version: "1", build: "1"});