Skip to content

Commit

Permalink
[PATCH 14/24] Major UI refactor of the blog settings screen. All conf…
Browse files Browse the repository at this point in the history
…ig options have been moved to a single HTML page and javascript is being used to page between them. The sidebar nav had to be updated (I also changed some of the language associated with blog preferences in the process) and of course a new file has been added: cfg_blog_settings. The remaining cfg_*.tmpl files should be slated for removal as technically, they are now obsolete. They were not removed only to facilitate roll back.

Signed-off-by: Open Melody Software Group <admin@openmelody.org>
  • Loading branch information
byrnereese authored and Open Melody Software Group committed Nov 17, 2009
1 parent 40c40b9 commit 638729a
Show file tree
Hide file tree
Showing 2 changed files with 224 additions and 9 deletions.
192 changes: 192 additions & 0 deletions tmpl/cms/cfg_blog_settings.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<$mt:setvar name="page_title" value="<__trans phrase="Blog Settings">"$>
<$mt:setvar name="position_actions_bottom" value="1"$>
<$mt:setvar name="general-settings" value="1"$>
<mt:setvarblock name="system_msg">
<mt:if name="error">
<mtapp:statusmsg
id="generic-error"
class="error">
<mt:var name="error">
</mtapp:statusmsg>
</mt:if>
<mt:if name="saved">
<mtapp:statusmsg
id="saved"
class="success"
rebuild="all">
<__trans phrase="Your preferences have been saved.">
</mtapp:statusmsg>
</mt:if>
</mt:setvarblock>
<mt:setvarblock name="content_nav">
<mt:include name="include/cfg_content_nav.tmpl">
</mt:setvarblock>

<mt:setvarblock name="html_head" append="1">
<script type="text/javascript" src="<mt:var name="static_uri">js/tc/client.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
function validate (f) {
if (!f.site_path.value) {
alert('<__trans phrase="You must set your Local Site Path." escape="singlequotes">');
return false;
} else if (!is_valid_url(f.site_url.value)){
alert('<__trans phrase="You must set a valid Site URL." escape="singlequotes">');
return false;
} else if (!is_valid_path(f.site_path.value)){
alert('<__trans phrase="You must set a valid Local Site Path." escape="singlequotes">');
return false;
}
if (f.enable_archive_paths.checked) {
if (!f.archive_path.value) {
alert('<__trans phrase="You must set Local Archive Path." escape="singlequotes">');
return false;
} else if (!is_valid_url(f.archive_url.value)){
alert('<__trans phrase="You must set a valid Archive URL." escape="singlequotes">');
return false;
} else if (!is_valid_path(f.archive_path.value)){
alert('<__trans phrase="You must set a valid Local Archive Path." escape="singlequotes">');
return false;
}
}
if (!f.name.value) {
alert('<__trans phrase="You must set your Blog Name." escape="singlequotes">');
return false;
} else if (f.server_offset.value == '') {
alert('<__trans phrase="You did not select a timezone." escape="singlequotes">');
return false;
}
f.site_url.disabled = false;
f.site_path.disabled = false;
f.archive_path.disabled = false;
f.archive_url.disabled = false;
return true;
}
function is_valid_url(url_){
return url_.match( /^https?:\/\/[A-Za-z0-9!$%()=_.:,;@~-]+/ );
}
function is_valid_path(path_){
var str = path_.replace(/[ "%<>\[\\\]\^`{\|}~]/g, "");
str = encodeURI(str);
if (str.indexOf('%') != -1) {
return false;
}
if (str.match(/\.\./)) {
return false;
}
return true;
}
function doRemoveLicense () {
document.cfg_form.cc_license.value = '';
var e = getByID('has-license');
if (e) e.style.display = 'none';
e = getByID('no-license');
if (e) e.style.display = 'block';
}

function setLicense() {
var w = window.open('http://creativecommons.org/license/?partner=SixApart&amp;jurisdiction_choose=1&amp;exit_url=<mt:var name="script_full_url">?__mode=cc_return%26license_code=[license_code]%26license_url=[license_url]%26license_button=[license_button]', 'cc', 'width=600,height=650,scrollbars=yes,resizable=no');
if ( w ) w.focus();
return false;
}

function disableFields(path1,path2) {
var url_is = "<mt:var name="site_url" encode_js="1">";
var path_is = "<mt:var name="site_path" encode_js="1">";
if (url_is.match(/BLOG-NAME/)) {
var daURL = getByID(path1);
var lock = path1 +"-lock";
var lock_img = getByID(lock);
daURL.disabled = false;
lock_img.style.display = 'none';
}
if (path_is.match(/BLOG-NAME/)) {
var daPath = getByID(path2);
var lock = path2 +"-lock";
var lock_img = getByID(lock);
daPath.disabled = false;
lock_img.style.display = 'none';
}
return;
}

function toggleFile(path) {
var fld = getByID(path);
if (fld) {
fld.disabled = false;
fld.focus();
var which_warning = path + "-warning";
var urlwarn = getByID(which_warning);
if (urlwarn) urlwarn.style.display = "block";
}
var which_lock = path + "-lock";
var img = getByID(which_lock);
if (img)
img.style.display = 'none';
return false;
}

function init() {
// conditionally disables
disableFields('site_url','site_path');
}

TC.attachLoadEvent( init );
/* ]]> */
</script>
</mt:setvarblock>

<mt:include name="include/header.tmpl">

<form name="cfg_form" method="post" action="<mt:var name="script_url">" onsubmit="return validate(this)">
<input type="hidden" name="id" value="<mt:var name="id" escape="html">" />
<input type="hidden" name="__mode" value="save" />
<input type="hidden" name="_type" value="blog" />
<input type="hidden" name="cfg_screen" value="cfg_prefs" />
<input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
<input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />

<div id="general" class="blog-preferences">
<$mt:include name="prefs/general.tmpl"$>
</div>
<div id="publishing" class="blog-preferences">
<$mt:include name="prefs/publishing.tmpl"$>
</div>
<div id="entry" class="blog-preferences">
<$mt:include name="prefs/entry.tmpl"$>
</div>
<div id="comments" class="blog-preferences">
<$mt:include name="prefs/comments.tmpl"$>
</div>
<div id="trackbacks" class="blog-preferences">
<$mt:include name="prefs/trackbacks.tmpl"$>
</div>
<div id="registration" class="blog-preferences">
<$mt:include name="prefs/registration.tmpl"$>
</div>
<div id="spam" class="blog-preferences">
<$mt:include name="prefs/spam.tmpl"$>
</div>
<div id="web-services" class="blog-preferences">
<$mt:include name="prefs/web_services.tmpl"$>
</div>
<mt:if name="show_ip_info">
<div id="ip-banning" class="blog-preferences">
<$mt:include name="prefs/ip-banning.tmpl"$>
</div>
</mt:if>

<mt:setvarblock name="action_buttons">
<button
type="submit"
accesskey="s"
title="<__trans phrase="Save changes to these settings (s)">"
class="primary-button"
><__trans phrase="Save Changes"></button>
</mt:setvarblock>
<mt:include name="include/actions_bar.tmpl" bar_position="bottom" hide_pager="1" settings_bar="1">

</form>

<mt:include name="include/footer.tmpl">
41 changes: 32 additions & 9 deletions tmpl/cms/include/cfg_content_nav.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
<script type="text/javascript">
$(document).ready( function() {
var active = $('#content-nav ul li.active a').attr('title');
$('#'+active).show();
$('fieldset input, fieldset select, fieldset textarea').change( function () {
var sel = '#content-nav ul li a[title="'+active+'"]';
var e = $(sel).parent();
if (!e.hasClass('changed')) {
e.find('b').html( e.find('b').html() + " *" );
}
e.addClass('changed');
});
$('#content-nav ul li a').click( function() {
var current = $(this).parent().parent().find('.active');
var newactive = $(this).attr('title');
current.removeClass('active');
$('#' + active).hide();
$(this).parent().addClass('active');
$('#' + newactive).show();
active = newactive;
});
});
</script>
<mt:if name="BLOG_ID">
<mt:setvarblock id="more_items" name="more_items"></mt:setvarblock>
<ul>
<li<mt:if name="general-settings"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_prefs&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="General"></b></a></li>
<li<mt:if name="publishing"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_archives&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Publishing"></b></a></li>
<li<mt:if name="entries"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_entry&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Entry"></b></a></li>
<li<mt:if name="comments"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_comments&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Comment"></b></a></li>
<li<mt:if name="trackbacks"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_trackbacks&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="TrackBack"></b></a></li>
<li<mt:if name="registration-settings"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_registration&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Registration"></b></a></li>
<li<mt:if name="spam"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_spam&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Spam"></b></a></li>
<li<mt:if name="web_services"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=cfg_web_services&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Web Services"></b></a></li>
<li class="active"><a href="javascript:void(0)" title="general"><b><__trans phrase="General"></b></a></li>
<li><a href="javascript:void(0)" title="publishing"><b><__trans phrase="Publishing"></b></a></li>
<li><a href="javascript:void(0)" title="entry"><b><__trans phrase="Compose"></b></a></li>
<li><a href="javascript:void(0)" title="comments"><b><__trans phrase="Comments"></b></a></li>
<li><a href="javascript:void(0)" title="trackbacks"><b><__trans phrase="TrackBacks"></b></a></li>
<li><a href="javascript:void(0)" title="registration"><b><__trans phrase="Login & Sign-up"></b></a></li>
<li><a href="javascript:void(0)" title="spam"><b><__trans phrase="Spam"></b></a></li>
<li><a href="javascript:void(0)" title="web-services"><b><__trans phrase="Web Services"></b></a></li>
<mt:if name="show_ip_info">
<li<mt:if name="ip_info"> class="active"</mt:if>><a href="<mt:var name="SCRIPT_URL">?__mode=list&amp;_type=banlist&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="IP Banning"></b></a></li>
<li><a href="javascript:void(0)" title="ip-banning"><b><__trans phrase="IP Banning"></b></a></li>
</mt:if>
<mt:var name="more_items">
</ul>
Expand Down

0 comments on commit 638729a

Please sign in to comment.