FEATURE #594: Added javascript-on-demand support

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65689 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-12 04:31:53 +00:00
parent 07eb2df9dc
commit c2fe5b15ae
8 changed files with 74 additions and 66 deletions

View File

@ -19,6 +19,65 @@ Director::addRules(50, array(
CMSMenu::populate_menu();
// Javascript combined files
Requirements::combine_files(
'assets/base.js',
array(
'jsparty/prototype.js',
'jsparty/behaviour.js',
'jsparty/prototype_improvements.js',
'jsparty/jquery/jquery.js',
'jsparty/jquery/plugins/livequery/jquery.livequery.js',
'jsparty/jquery/plugins/effen/jquery.fn.js',
'sapphire/javascript/core/jquery.ondemand.js',
'jsparty/jquery/jquery_improvements.js',
'jsparty/firebug/firebugx.js',
'sapphire/javascript/i18n.js',
)
);
Requirements::combine_files(
'assets/leftandmain.js',
array(
'jsparty/loader.js',
'jsparty/hover.js',
'jsparty/layout_helpers.js',
'jsparty/scriptaculous/effects.js',
'jsparty/scriptaculous/dragdrop.js',
'jsparty/scriptaculous/controls.js',
'jsparty/greybox/AmiJS.js',
'jsparty/greybox/greybox.js',
'cms/javascript/LeftAndMain.js',
'cms/javascript/LeftAndMain_left.js',
'cms/javascript/LeftAndMain_right.js',
//'jsparty/tiny_mce2/tiny_mce_src.js',
'jsparty/tree/tree.js',
'jsparty/tabstrip/tabstrip.js',
'cms/javascript/TinyMCEImageEnhancement.js',
'jsparty/SWFUpload/SWFUpload.js',
'cms/javascript/Upload.js',
'sapphire/javascript/TreeSelectorField.js',
'cms/javascript/ThumbnailStripField.js',
)
);
Requirements::combine_files(
'assets/cmsmain.js',
array(
'cms/javascript/CMSMain.js',
'cms/javascript/CMSMain_left.js',
'cms/javascript/CMSMain_right.js',
'cms/javascript/SideTabs.js',
'cms/javascript/TaskList.js',
'cms/javascript/SideReports.js',
'cms/javascript/LangSelector.js',
'cms/javascript/TranslationTab.js',
'jsparty/calendar/calendar.js',
'jsparty/calendar/lang/calendar-en.js',
'jsparty/calendar/calendar-setup.js',
)
);
CMSMenu::add_link(
'Help',
_t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'),

View File

@ -75,8 +75,6 @@ class AssetAdmin extends LeftAndMain {
}
// needed for MemberTableField (Requirements not determined before Ajax-Call)
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
Requirements::javascript(CMS_DIR . '/javascript/AssetTableField.js');
Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");

View File

@ -37,6 +37,12 @@ class AssetTableField extends ComplexTableField {
$this->Markable = true;
}
function FieldHolder() {
Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
return parent::FieldHolder();
}
function setFolder($folder) {
$this->folder = $folder;
$this->sourceFilter .= ($this->sourceFilter) ? " AND " : "";

View File

@ -94,6 +94,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
if(!Director::is_ajax()) {
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
Requirements::javascriptTemplate(CMS_DIR . "/javascript/tinymce.template.js", array(
"ContentCSS" => (SSViewer::current_theme() ? THEMES_DIR . "/" . SSViewer::current_theme() : project()) . "/css/editor.css",
"BaseURL" => Director::absoluteBaseURL(),
@ -105,12 +106,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain_left.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain_right.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/UpdateURL.js');
Requirements::javascript(THIRDPARTY_DIR . '/tabstrip/tabstrip.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ReportField.js");
Requirements::javascript("forum/javascript/ForumAccess.js");
Requirements::javascript('gallery/javascript/GalleryPage_CMS.js');
}
public function getMenuTitle() {

View File

@ -122,6 +122,7 @@ class LeftAndMain extends Controller {
Requirements::css(CMS_DIR . '/css/layout.css');
Requirements::css(CMS_DIR . '/css/cms_left.css');
Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
if(isset($_REQUEST['debug_firebug'])) {
// Firebug is a useful console for debugging javascript
@ -137,16 +138,13 @@ class LeftAndMain extends Controller {
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/core/jquery.ondemand.js');
Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
Requirements::javascript(THIRDPARTY_DIR . '/hover.js');
Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Activator.js');
Requirements::javascript(THIRDPARTY_DIR . '/tiny_mce_improvements.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/dragdrop.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/controls.js');
@ -157,70 +155,18 @@ class LeftAndMain extends Controller {
Requirements::javascript(THIRDPARTY_DIR . '/tree/tree.js');
Requirements::css(THIRDPARTY_DIR . '/tree/tree.css');
Requirements::javascript(THIRDPARTY_DIR . '/tabstrip/tabstrip.js');
Requirements::css(THIRDPARTY_DIR . '/tabstrip/tabstrip.css');
Requirements::css(CMS_DIR . '/css/TinyMCEImageEnhancement.css');
Requirements::javascript(CMS_DIR . '/javascript/TinyMCEImageEnhancement.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_left.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_right.js');
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
Requirements::javascript(CMS_DIR . '/javascript/ForumAdmin.js');
Requirements::javascript(CMS_DIR . '/javascript/SideTabs.js');
Requirements::javascript(CMS_DIR . '/javascript/TaskList.js');
Requirements::javascript(CMS_DIR . '/javascript/CommentList.js');
Requirements::javascript(CMS_DIR . '/javascript/SideReports.js');
Requirements::javascript(CMS_DIR . '/javascript/LangSelector.js');
Requirements::javascript(CMS_DIR . '/javascript/TranslationTab.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/Validator.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/UniqueFields.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/RedirectorPage.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ToggleCompositeField.js');
Requirements::css(SAPPHIRE_DIR . '/css/SubmittedFormReportField.css');
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField.css');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ComplexTableField.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/RelationComplexTableField.js');
Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css');
Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css');
Requirements::javascript(THIRDPARTY_DIR . '/calendar/calendar.js');
Requirements::javascript(THIRDPARTY_DIR . '/calendar/lang/calendar-en.js');
Requirements::javascript(THIRDPARTY_DIR . '/calendar/calendar-setup.js');
Requirements::css(SAPPHIRE_DIR . '/css/CalendarDateField.css');
Requirements::css(THIRDPARTY_DIR . '/calendar/calendar-win2k-1.css');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/DropdownTimeField.js');
Requirements::css(SAPPHIRE_DIR . '/css/DropdownTimeField.css');
Requirements::css(SAPPHIRE_DIR . '/css/PopupDateTimeField.css');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
Requirements::javascript(THIRDPARTY_DIR . '/SWFUpload/SWFUpload.js');
Requirements::javascript(CMS_DIR . '/javascript/Upload.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/HasManyFileField.js');
Requirements::css(SAPPHIRE_DIR . '/css/HasManyFileField.css');
Requirements::themedCSS('typography');
// For Widgets
Requirements::css(CMS_DIR . '/css/WidgetAreaEditor.css');
Requirements::javascript(CMS_DIR . '/javascript/WidgetAreaEditor.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/Security_login.js");
foreach (self::$extra_requirements['javascript'] as $file) {
Requirements::javascript($file[0]);
}

View File

@ -32,6 +32,7 @@ class ReportAdmin extends LeftAndMain {
// We don't want this showing up in every ajax-response, it should
// always be present in a CMS environment
if(!Director::is_ajax()) {
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
Requirements::javascriptTemplate(CMS_DIR . '/javascript/tinymce.template.js', array(
'ContentCSS' => project() . '/css/editor.css',
'BaseURL' => Director::absoluteBaseURL(),

View File

@ -6,6 +6,9 @@
*/
class WidgetAreaEditor extends FormField {
function FieldHolder() {
Requirements::css(CMS_DIR . '/css/WidgetAreaEditor.css');
Requirements::javascript(CMS_DIR . '/javascript/WidgetAreaEditor.js');
return $this->renderWith("WidgetAreaEditor");
}

View File

@ -12,7 +12,7 @@ if((typeof tinyMCE != 'undefined')) {
mode : "none",
language: "$Lang",
width: "100%",
auto_resize : true,
auto_resize : false,
theme : "advanced",
content_css : "$ContentCSS",
document_base_url: "$BaseURL",