From 43491c264180a835a3924400375bff87f4848ac7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 25 Apr 2011 21:24:55 +1200 Subject: [PATCH] MINOR Reducing number of asset downloads by combining files in LeftAndMain->init() and including full jquery.ui.css instead of multiple @import statements --- admin/code/LeftAndMain.php | 70 +++++++++++++++++--------------- css/MemberProfileForm.css | 3 -- forms/FileIFrameField.php | 2 +- forms/TabSet.php | 3 +- forms/TreeDropdownField.php | 2 +- forms/TreeMultiselectField.php | 2 +- javascript/prototypefix/README | 7 ---- javascript/prototypefix/intro.js | 1 - javascript/prototypefix/outro.js | 1 - security/Member.php | 9 ---- security/Security.php | 17 +------- 11 files changed, 43 insertions(+), 74 deletions(-) delete mode 100644 css/MemberProfileForm.css delete mode 100644 javascript/prototypefix/README delete mode 100644 javascript/prototypefix/intro.js delete mode 100644 javascript/prototypefix/outro.js diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index 32a41c0b8..2883bc301 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -194,24 +194,22 @@ class LeftAndMain extends Controller { Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/screen.css'); - Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/intro.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); - Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/outro.js'); + Requirements::javascript(THIRDPARTY_DIR . '/prototype/prototype.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); //import all of jquery ui + Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); //import all of jquery ui - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/json-js/json2.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-metadata/jquery.metadata.js'); + Requirements::javascript(THIRDPARTY_DIR . '/json-js/json2.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery-metadata/jquery.metadata.js'); // entwine - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ssui.core.js'); // @todo Load separately so the CSS files can be inlined - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css'); + Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); // Required for TreeTools panel above tree Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js'); @@ -219,20 +217,14 @@ class LeftAndMain extends Controller { Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js'); + Requirements::javascript(THIRDPARTY_DIR . '/behaviour/behaviour.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js'); Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::add_i18n_javascript(SAPPHIRE_ADMIN_DIR . '/javascript/lang'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/dragdrop.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/controls.js'); - - Requirements::javascript(THIRDPARTY_DIR . '/tree/tree.js'); - Requirements::css(THIRDPARTY_DIR . '/tree/tree.css'); Requirements::javascript(THIRDPARTY_DIR . '/jstree/jquery.jstree.js'); Requirements::css(THIRDPARTY_DIR . '/jstree/themes/apple/style.css'); @@ -257,30 +249,44 @@ class LeftAndMain extends Controller { } Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/unjquery.css'); - + // Javascript combined files Requirements::combine_files( - 'base.js', + 'lib.js', array( - 'sapphire/thirdparty/prototype/prototype.js', - 'sapphire/thirdparty/behaviour/behaviour.js', - 'sapphire/thirdparty/jquery/jquery.js', - 'sapphire/thirdparty/jquery-livequery/jquery.livequery.js', - 'sapphire/javascript/jquery-ondemand/jquery.ondemand.js', - 'sapphire/thirdparty/jquery-ui/jquery-ui.js', - 'sapphire/javascript/i18n.js', + THIRDPARTY_DIR . '/prototype/prototype.js', + THIRDPARTY_DIR . '/behaviour/behaviour.js', + THIRDPARTY_DIR . '/jquery/jquery.js', + SAPPHIRE_DIR . '/javascript/jquery_improvements.js', + THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js', + SAPPHIRE_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js', + THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', + THIRDPARTY_DIR . '/json-js/json2.js', + THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', + THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', + SAPPHIRE_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', + THIRDPARTY_DIR . '/jquery-metadata/jquery.metadata.js', + SAPPHIRE_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', + SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', + SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', + THIRDPARTY_DIR . '/jstree/jquery.jstree.js', + SAPPHIRE_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js', + SAPPHIRE_DIR . '/javascript/TreeDropdownField.js', + SAPPHIRE_DIR . '/javascript/TabSet.js', + SAPPHIRE_DIR . '/javascript/Validator.js', + SAPPHIRE_DIR . '/javascript/i18n.js', + SAPPHIRE_ADMIN_DIR . '/javascript/ssui.core.js', ) ); Requirements::combine_files( 'leftandmain.js', array( - 'sapphire/thirdparty/scriptaculous/effects.js', - 'sapphire/thirdparty/scriptaculous/dragdrop.js', - 'sapphire/thirdparty/scriptaculous/controls.js', - 'sapphire/admin/javascript/LeftAndMain.js', - 'sapphire/javascript/tree/tree.js', - 'sapphire/javascript/TreeDropdownField.js', + SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.js', + SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js', + SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js', + SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js', + SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js', ) ); diff --git a/css/MemberProfileForm.css b/css/MemberProfileForm.css deleted file mode 100644 index d81f6dbb0..000000000 --- a/css/MemberProfileForm.css +++ /dev/null @@ -1,3 +0,0 @@ -#i18nStatus { - margin-left: 0; -} \ No newline at end of file diff --git a/forms/FileIFrameField.php b/forms/FileIFrameField.php index c33194ca2..76c775be8 100755 --- a/forms/FileIFrameField.php +++ b/forms/FileIFrameField.php @@ -51,7 +51,7 @@ class FileIFrameField extends FileField { * @return string */ public function Field() { - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css'); + Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); diff --git a/forms/TabSet.php b/forms/TabSet.php index 71ee92ab0..460fda0dc 100644 --- a/forms/TabSet.php +++ b/forms/TabSet.php @@ -75,8 +75,7 @@ class TabSet extends CompositeField { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js'); - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css'); - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.tabs.css'); + Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.css'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index a1bdb76f1..d0d3e01f3 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -121,7 +121,7 @@ class TreeDropdownField extends FormField { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jstree/jquery.jstree.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeDropdownField.js'); - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css'); + Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css'); if($this->Value() && $record = $this->objectForKey($this->Value())) { diff --git a/forms/TreeMultiselectField.php b/forms/TreeMultiselectField.php index fbd06bce2..80cdeb81d 100755 --- a/forms/TreeMultiselectField.php +++ b/forms/TreeMultiselectField.php @@ -87,7 +87,7 @@ class TreeMultiselectField extends TreeDropdownField { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jstree/jquery.jstree.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeDropdownField.js'); - Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css'); + Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css'); $value = ''; diff --git a/javascript/prototypefix/README b/javascript/prototypefix/README deleted file mode 100644 index c89c713cf..000000000 --- a/javascript/prototypefix/README +++ /dev/null @@ -1,7 +0,0 @@ -Prototype replaces document.getElementsByClassName with it's own version. However many browsers -now come with their own implementation, and prototype's is much slower. - -This fixes this by restoring the original after prototype is loaded. - -@todo: Safari 3 used to come with a broken document.getElementsByClassName. We should use -the same checks jQuery does and not restore the function if it doesn't work the same as the spec. \ No newline at end of file diff --git a/javascript/prototypefix/intro.js b/javascript/prototypefix/intro.js deleted file mode 100644 index edae2e9fd..000000000 --- a/javascript/prototypefix/intro.js +++ /dev/null @@ -1 +0,0 @@ -var browserGetElementsByClassName = document.getElementsByClassName; \ No newline at end of file diff --git a/javascript/prototypefix/outro.js b/javascript/prototypefix/outro.js deleted file mode 100644 index aa3d55aab..000000000 --- a/javascript/prototypefix/outro.js +++ /dev/null @@ -1 +0,0 @@ -if (browserGetElementsByClassName) document.getElementsByClassName = browserGetElementsByClassName; diff --git a/security/Member.php b/security/Member.php index eee4d4bd3..e25edee9c 100755 --- a/security/Member.php +++ b/security/Member.php @@ -1633,17 +1633,8 @@ class Member_ProfileForm extends Form { function __construct($controller, $name, $member) { Requirements::clear(); Requirements::css(CMS_DIR . '/css/typography.css'); - Requirements::css(CMS_DIR . '/css/cms_right.css'); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js"); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); - Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js"); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/scriptaculous/scriptaculous.js"); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/scriptaculous/controls.js"); Requirements::css(SAPPHIRE_DIR . "/css/Form.css"); - Requirements::css(SAPPHIRE_DIR . "/css/MemberProfileForm.css"); - - $fields = $member->getCMSFields(); $fields->push(new HiddenField('ID','ID',$member->ID)); diff --git a/security/Security.php b/security/Security.php index d1460a08e..f22de44f2 100644 --- a/security/Security.php +++ b/security/Security.php @@ -365,10 +365,6 @@ class Security extends Controller { // only display tabs when more than one authenticator is provided // to save bandwidth and reduce the amount of custom styling needed if(count($forms) > 1) { - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js"); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); - Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js"); - Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/scriptaculous/effects.js"); Requirements::css(SAPPHIRE_DIR . "/css/Form.css"); // Needed because the in the template makes problems @@ -381,8 +377,7 @@ class Security extends Controller { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); - Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery.ui.all.css'); - Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery.ui.tabs.css'); + Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(SAPPHIRE_DIR . '/css/Security_login.css'); @@ -438,11 +433,6 @@ class Security extends Controller { * @return string Returns the "lost password" page as HTML code. */ public function lostpassword() { - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); - Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js'); - if(class_exists('SiteTree')) { $tmpPage = new Page(); $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password'); @@ -501,11 +491,6 @@ class Security extends Controller { * @return string Returns the "password sent" page as HTML code. */ public function passwordsent($request) { - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); - Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js'); - if(class_exists('SiteTree')) { $tmpPage = new Page(); $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');