From cb1059bbe495a5296da9f88c115c3286e55f64d8 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 26 Nov 2005 21:54:59 +0000 Subject: [PATCH] adding style template wizard --- docs/changelog/6.x.x.txt | 3 + lib/WebGUI/Asset/Template.pm | 175 ++++++++++++++++++++++ lib/WebGUI/Style.pm | 1 - lib/WebGUI/i18n/English/Asset_Template.pm | 6 + www/extras/colorPicker.js | 37 ++--- 5 files changed, 203 insertions(+), 19 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index d83eef54a..35658b7b0 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -17,6 +17,9 @@ - Added Matrix asset. - Added In/Out Board asset. - Page not found page returns a 404 error code now. + - Added more error trapping in caching system. + - Fixed some layout and control bugs in the color picker form element. + - Added a simple Style Wizard. 6.7.7 diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 35af1da89..5807eae83 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -327,6 +327,7 @@ sub www_edit { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; $self->getAdminConsole->setHelp("template add/edit","Asset_Template"); + $self->getAdminConsole->addSubmenuItem($self->getUrl('func=styleWizard'),WebGUI::International::get("style wizard","Asset_Template")) if ($self->get("namespace") eq "style"); return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get('edit template', 'Asset_Template')); } @@ -348,6 +349,180 @@ sub www_manage { +#------------------------------------------------------------------- + +sub www_styleWizard { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + my $output = ""; + if ($session{form}{step} == 2) { + my $f = WebGUI::HTMLForm->new({action=>$self->getUrl}); + $f->hidden(name=>"func", value=>"styleWizard"); + $f->hidden(name=>"proceed", value=>"manageAssets") if ($session{form}{proceed}); + $f->hidden(name=>"step", value=>3); + $f->hidden(name=>"layout", value=>$session{form}{layout}); + $f->text(name=>"heading", value=>"My Site", label=>"Site Name"); + $f->file(name=>"logo", label=>"Logo", subtext=>"
JPEG, GIF, or PNG thats less than 200 pixels wide and 100 pixels tall"); + $f->color(name=>"pageBackgroundColor", value=>"#ccccdd", label=>"Page Background Color"); + $f->color(name=>"headingBackgroundColor", value=>"#ffffff", label=>"Header Background Color"); + $f->color(name=>"headingForegroundColor", value=>"#000000", label=>"Header Text Color"); + $f->color(name=>"bodyBackgroundColor", value=>"#ffffff", label=>"Body Background Color"); + $f->color(name=>"bodyForegroundColor", value=>"#000000", label=>"Body Text Color"); + $f->color(name=>"menuBackgroundColor", value=>"#eeeeee", label=>"Menu Background Color"); + $f->color(name=>"linkColor", value=>"#0000ff", label=>"Link Color"); + $f->color(name=>"visitedLinkColor", value=>"#ff00ff", label=>"Visited Link Color"); + $f->submit; + $output = $f->print; + } elsif ($session{form}{step} == 3) { + my $storage = WebGUI::Storage::Image->get(WebGUI::FormProcessor::file("logo")); + my $logo = $self->addChild({ + className=>"WebGUI::Asset::File::Image", + title=>WebGUI::FormProcessor::text("heading")." Logo", + menuTitle=>WebGUI::FormProcessor::text("heading")." Logo", + url=>WebGUI::FormProcessor::text("heading")." Logo", + storageId=>$storage->getId, + filename=>@{$storage->getFiles}[0], + templateId=>"PBtmpl0000000000000088" + }); + $logo->generateThumbnail if ($logo->get("filename")); +my $style = ' + + + ^Page(title); - ^c; + + + +^AdminBar; +
+
+ + '.WebGUI::FormProcessor::text("heading").' +
+
+
+ +
+
+
'; +if ($session{form}{layout} == 1) { + $style .= '
'; +} +$style .= ' +
+
+
^a(^@;); ^AdminToggle;
+ +
+
+
+ +'; + return $self->addRevision({ + template=>$style + })->www_edit; + } else { + $output = WebGUI::Form::formHeader({action=>$self->getUrl}).WebGUI::Form::hidden({name=>"func", value=>"styleWizard"}); + $output .= WebGUI::Form::hidden({name=>"proceed", value=>"manageAssets"}) if ($session{form}{proceed}); + $output .= ''; + $output .= "

Choose a layout for this style:

"; + $output .= WebGUI::Form::hidden({name=>"step", value=>2}); + $output .= '
'.WebGUI::Form::radio({name=>"layout", value=>1, checked=>1}).q| + + +
LogoHeading
MenuBody content goes here.
|; + $output .= '
'.WebGUI::Form::radio({name=>"layout", value=>2}).q| + + + +
LogoHeading
Menu
Body content goes here.
|; + $output .= WebGUI::Form::submit(); + $output .= WebGUI::Form::formFooter(); + } + $self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),WebGUI::International::get("edit template","Asset_Template")) if ($self->get("url")); + return $self->getAdminConsole->render($output,WebGUI::International::get('style wizard', 'Asset_Template')); +} + #------------------------------------------------------------------- sub www_view { my $self = shift; diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index 37589349b..21403470c 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -34,7 +34,6 @@ This package contains utility methods for WebGUI's style system. =head1 SYNOPSIS use WebGUI::Style; - $template = WebGUI::Style::getTemplate(); $html = WebGUI::Style::process($content); $html = generateAdditionalHeadTags(); diff --git a/lib/WebGUI/i18n/English/Asset_Template.pm b/lib/WebGUI/i18n/English/Asset_Template.pm index 18c353e6b..f7e9f292f 100644 --- a/lib/WebGUI/i18n/English/Asset_Template.pm +++ b/lib/WebGUI/i18n/English/Asset_Template.pm @@ -1,6 +1,12 @@ package WebGUI::i18n::English::Asset_Template; our $I18N = { + 'style wizard' => { + message => q|Style Wizard|, + context => q|Label for link to engage the style wizard.|, + lastUpdated => 0, + }, + 'namespace' => { message => q|Namespace|, context => q|label for Template Add/Edit Form|, diff --git a/www/extras/colorPicker.js b/www/extras/colorPicker.js index e1a9263c1..55a13fe7f 100644 --- a/www/extras/colorPicker.js +++ b/www/extras/colorPicker.js @@ -123,14 +123,14 @@ function changePickerHue(){ else if(b == 0) bS = 0; if(gS == 0) - g = g + (bit * 2); + g = g + 1; else - g = g - (bit * 2); + g = g - 1; if(bS == 0) - b = b + (bit * 4); + b = b + 16; else - b = b - (bit * 4); + b = b - 16; } htmlStr+= ""; htmlStr+= ""; @@ -162,16 +162,16 @@ function placePickerToolbar(obj){ if(toolbarShow[obj.id] == 0){ toolbarShow[obj.id] = 1; - t = obj.offsetTop + parseInt(obj.style.height) + 3; - l = obj.offsetLeft; + t = obj.offsetTop + parseInt(obj.style.height)-5; + l = obj.offsetLeft+30; while(obj.offsetParent){ t+= obj.offsetParent.offsetTop; l+= obj.offsetParent.offsetLeft; obj = obj.offsetParent; } - document.getElementById('colorPickerTools').style.top = t; - document.getElementById('colorPickerTools').style.left = l; - document.getElementById('colorPickerTools').style.display = 'block'; + document.getElementById('colorPickerTools').style.top = t+'px'; + document.getElementById('colorPickerTools').style.left = l+'px'; + document.getElementById('colorPickerTools').style.visibility = 'visible'; if(picked[clickedPicker] == null){ changePallet(255); }else{ @@ -179,15 +179,15 @@ function placePickerToolbar(obj){ setPickedColorFromForm(document.getElementById(clickedPicker+'Value')); } }else if(toolbarShow[obj.id] == 1){ - document.getElementById('colorPickerTools').style.display = 'none'; + document.getElementById('colorPickerTools').style.visibility = 'hidden'; toolbarShow[obj.id] = 0; } } -function killColorPicker(sw){ +function killPicker(sw){ if(sw == 1 && clickedPicker){ - tmr = setTimeout('placePickerToolbar(document.getElementById(clickedPicker));',1000); + tmr = setTimeout('placePickerToolbar(document.getElementById(clickedPicker));',300); }else if(tmr){ clearTimeout(tmr); } @@ -200,16 +200,17 @@ function initColorPicker(fieldName,fieldValue){ if(!fieldValue) fieldValue = ""; - s = ""; - s+= ""; - s+= ""; - s+= "
 
"; - document.write(s); if(donePickerInits == 0){ - document.write(""); + document.write(""); document.getElementById('colorPickerTools').innerHTML = '
'+pickerScreen+''+hueScreen+'
'; } + s = ""; + s+= ""; + s+= ""; + s+= "
 
"; + document.write(s); toolbarShow["pickedColor"+donePickerInits] = 0; donePickerInits++; } +