From 775f6a1354cd3f691a65afa754b93c19383ebeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 10 Dec 2014 15:41:38 +0100 Subject: [PATCH 1/3] make sure styles and scripts are only loaded once --- apps/files_external/templates/settings.php | 2 +- lib/private/util.php | 34 ++++++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 072f856dfb..79950f3038 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -76,7 +76,7 @@ - + diff --git a/lib/private/util.php b/lib/private/util.php index 6ccb9dba08..b97c068462 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -333,9 +333,9 @@ class OC_Util { /** * generates a path for JS/CSS files. If no application is provided it will create the path for core. * - * @param $application application to get the files from - * @param $directory directory withing this application (css, js, vendor, etc) - * @param $file the file inside of the above folder + * @param string $application application to get the files from + * @param string $directory directory withing this application (css, js, vendor, etc) + * @param string $file the file inside of the above folder * @return string the path */ private static function generatePath($application, $directory, $file) { @@ -358,7 +358,10 @@ class OC_Util { * @return void */ public static function addScript($application, $file = null) { - self::$scripts[] = OC_Util::generatePath($application, 'js', $file); + $path = OC_Util::generatePath($application, 'js', $file); + if (!in_array($path, self::$scripts)) { + self::$scripts[] = $path; + } } /** @@ -369,7 +372,10 @@ class OC_Util { * @return void */ public static function addVendorScript($application, $file = null) { - self::$scripts[] = OC_Util::generatePath($application, 'vendor', $file); + $path = OC_Util::generatePath($application, 'vendor', $file); + if (!in_array($path, self::$scripts)) { + self::$scripts[] = $path; + } } /** @@ -384,9 +390,12 @@ class OC_Util { $languageCode = $l->getLanguageCode($application); } if (!empty($application)) { - self::$scripts[] = "$application/l10n/$languageCode"; + $path = "$application/l10n/$languageCode"; } else { - self::$scripts[] = "l10n/$languageCode"; + $path = "l10n/$languageCode"; + } + if (!in_array($path, self::$scripts)) { + self::$scripts[] = $path; } } @@ -398,7 +407,10 @@ class OC_Util { * @return void */ public static function addStyle($application, $file = null) { - self::$styles[] = OC_Util::generatePath($application, 'css', $file); + $path = OC_Util::generatePath($application, 'css', $file); + if (!in_array($path, self::$styles)) { + self::$styles[] = $path; + } } /** @@ -409,7 +421,10 @@ class OC_Util { * @return void */ public static function addVendorStyle($application, $file = null) { - self::$styles[] = OC_Util::generatePath($application, 'vendor', $file); + $path = OC_Util::generatePath($application, 'vendor', $file); + if (!in_array($path, self::$styles)) { + self::$styles[] = $path; + } } /** @@ -1344,4 +1359,5 @@ class OC_Util { public static function isPhpCharSetUtf8() { return ini_get('default_charset') === 'UTF-8'; } + } From 3cc33a98a898f247499896ae0674ae680564fb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 10 Dec 2014 16:18:18 +0100 Subject: [PATCH 2/3] use script instead of \OCP\Util methods --- core/templates/login.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/templates/login.php b/core/templates/login.php index 86a1b605df..2198f063db 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -1,5 +1,11 @@ - +
@@ -65,8 +71,5 @@
- + Date: Wed, 10 Dec 2014 16:59:03 +0100 Subject: [PATCH 3/3] load showpassord.js conditionally in the template only if needed --- core/js/installation.js | 5 +++++ core/js/js.js | 29 ----------------------------- core/templates/installation.php | 6 ++++++ lib/base.php | 2 -- settings/js/personal.js | 1 + settings/templates/personal.php | 1 + 6 files changed, 13 insertions(+), 31 deletions(-) create mode 100644 core/js/installation.js diff --git a/core/js/installation.js b/core/js/installation.js new file mode 100644 index 0000000000..20ff346215 --- /dev/null +++ b/core/js/installation.js @@ -0,0 +1,5 @@ + +$(document).ready(function() { + $('#adminpass').showPassword().keyup(); + $('#dbpass').showPassword().keyup(); +}); diff --git a/core/js/js.js b/core/js/js.js index f01c0eb77c..57ce1ab695 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1081,35 +1081,6 @@ function initCore() { } }); - var setShowPassword = function(input, label) { - input.showPassword().keyup(); - }; - setShowPassword($('#adminpass'), $('label[for=show]')); - setShowPassword($('#pass2'), $('label[for=personal-show]')); - setShowPassword($('#dbpass'), $('label[for=dbpassword]')); - - var checkShowCredentials = function() { - var empty = false; - $('input#user, input#password').each(function() { - if ($(this).val() === '') { - empty = true; - } - }); - if(empty) { - $('#submit').fadeOut(); - $('#remember_login').hide(); - $('#remember_login+label').fadeOut(); - } else { - $('#submit').fadeIn(); - $('#remember_login').show(); - $('#remember_login+label').fadeIn(); - } - }; - // hide log in button etc. when form fields not filled - // commented out due to some browsers having issues with it - // checkShowCredentials(); - // $('input#user, input#password').keyup(checkShowCredentials); - // user menu $('#settings #expand').keydown(function(event) { if (event.which === 13 || event.which === 32) { diff --git a/core/templates/installation.php b/core/templates/installation.php index 9ef63dbfe8..0b3b0d46c5 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -1,3 +1,9 @@ + '> '> '> diff --git a/lib/base.php b/lib/base.php index 1dd259b091..aa536c2639 100644 --- a/lib/base.php +++ b/lib/base.php @@ -336,7 +336,6 @@ class OC { public static function initTemplateEngine() { // Add the stuff we need always - // following logic will import all vendor libraries that are // specified in core/js/core.json $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); @@ -351,7 +350,6 @@ class OC { throw new \Exception('Cannot read core/js/core.json'); } - OC_Util::addScript("jquery-showpassword"); OC_Util::addScript("placeholders"); OC_Util::addScript("jquery-tipsy"); OC_Util::addScript("compatibility"); diff --git a/settings/js/personal.js b/settings/js/personal.js index b2efa7c37f..ac29f69037 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -157,6 +157,7 @@ function avatarResponseHandler (data) { } $(document).ready(function () { + $('#pass2').showPassword().keyup(); $("#passwordbutton").click(function () { if ($('#pass1').val() !== '' && $('#pass2').val() !== '') { // Serialize the data diff --git a/settings/templates/personal.php b/settings/templates/personal.php index cc04de5ec3..913c5803f6 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -63,6 +63,7 @@

t('Password'));?>