From 4f779e90831e9746083564ac82d4105dfc994262 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 18 Feb 2013 18:09:29 +0100 Subject: Password strength indicator fixed for new jQuery. Also cleaned up formatting. --- modules/user/js/password_strength.js | 71 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'modules/user') diff --git a/modules/user/js/password_strength.js b/modules/user/js/password_strength.js index 2442b8de..5764e332 100644 --- a/modules/user/js/password_strength.js +++ b/modules/user/js/password_strength.js @@ -1,39 +1,38 @@ (function($) { - // Based on the Password Strength Indictor By Benjamin Sterling - // http://benjaminsterling.com/password-strength-indicator-and-generator/ - $.widget("ui.user_password_strength", { - _init: function() { - var self = this; - $(this.element).keyup(function() { - var strength = self.calculateStrength (this.value); - var index = Math.min(Math.floor( strength / 10 ), 10); - $("#g-password-gauge") - .removeAttr('class') - .addClass( "g-password-strength0" ) - .addClass( self.options.classes[ index ] ); - }).after("
"); - }, + // Based on the Password Strength Indictor By Benjamin Sterling + // http://benjaminsterling.com/password-strength-indicator-and-generator/ + $.widget("ui.user_password_strength", { + options: { + classes: ['g-password-strength10', 'g-password-strength20', 'g-password-strength30', + 'g-password-strength40', 'g-password-strength50', 'g-password-strength60', + 'g-password-strength70', 'g-password-strength80', 'g-password-strength90', + 'g-password-strength100'] + }, - calculateStrength: function(value) { - // Factor in the length of the password - var strength = Math.min(5, value.length) * 10 - 20; - // Factor in the number of numbers - strength += Math.min(3, value.length - value.replace(/[0-9]/g,"").length) * 10; - // Factor in the number of non word characters - strength += Math.min(3, value.length - value.replace(/\W/g,"").length) * 15; - // Factor in the number of Upper case letters - strength += Math.min(3, value.length - value.replace(/[A-Z]/g,"").length) * 10; + _init: function() { + var self = this; + $(this.element).keyup(function() { + var strength = self.calculateStrength(this.value); + var index = Math.min(Math.floor(strength / 10), 10); + $("#g-password-gauge") + .removeAttr("class") + .addClass("g-password-strength0") + .addClass(self.options.classes[index]); + }).after("
"); + }, - // Normalizxe between 0 and 100 - return Math.max(0, Math.min(100, strength)); - } - }); - $.extend($.ui.user_password_strength, { - defaults: { - classes : ['g-password-strength10', 'g-password-strength20', 'g-password-strength30', - 'g-password-strength40', 'g-password-strength50', 'g-password-strength60', - 'g-password-strength70',' g-password-strength80',' g-password-strength90', - 'g-password-strength100'] - } - }); - })(jQuery); + calculateStrength: function(value) { + // Factor in the length of the password + var strength = Math.min(5, value.length) * 10 - 20; + // Factor in the number of numbers + strength += Math.min(3, value.length - value.replace(/[0-9]/g,"").length) * 10; + // Factor in the number of non word characters + strength += Math.min(3, value.length - value.replace(/\W/g,"").length) * 15; + // Factor in the number of Upper case letters + strength += Math.min(3, value.length - value.replace(/[A-Z]/g,"").length) * 10; + + // Normalize between 0 and 100 + return Math.max(0, Math.min(100, strength)); + } + }); +})(jQuery); -- cgit v1.2.3 From fd012276cbf03cc1dc7b8da10aac5cc6f26326c6 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 23 Feb 2013 21:29:09 +0100 Subject: #2013 - Clean up gallery.panel.js. - prepend "data-" in front of non-standard attr to be more standards compliant. --- lib/gallery.panel.js | 18 +++++++++--------- modules/user/views/admin_users.html.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'modules/user') diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index e5028f2a..15c09920 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -10,19 +10,19 @@ var parentClass = $(parent).attr("class"); var ePanel = ""; - // We keep track of the open vs. closed state by looking to see if there' - // an orig_text attr. If that attr is missing, then the panel is closed + // We keep track of the open vs. closed state by looking to see if there's + // a data-orig-text attr. If that attr is missing, then the panel is closed // and we want to open it - var should_open = !$(element).attr("orig_text"); + var should_open = !$(element).attr("data-orig-text"); // Close any open panels and reset their button text if ($("#g-panel").length) { $("#g-panel").slideUp("slow").remove(); $.each($(".g-panel-link"), function() { - if ($(this).attr("orig_text")) { - $(this).children(".g-button-text").text($(this).attr("orig_text")); - $(this).attr("orig_text", ""); + if ($(this).attr("data-orig-text")) { + $(this).children(".g-button-text").text($(this).attr("data-orig-text")); + $(this).attr("data-orig-text", ""); } } ); @@ -45,9 +45,9 @@ $("#g-panel td").html(content); self._ajaxify_panel(); - if ($(element).attr("open_text")) { - $(element).attr("orig_text", $(element).children(".g-button-text").text()); - $(element).children(".g-button-text").text($(element).attr("open_text")); + if ($(element).attr("data-open-text")) { + $(element).attr("data-orig-text", $(element).children(".g-button-text").text()); + $(element).children(".g-button-text").text($(element).attr("data-open-text")); } $("#g-panel").addClass(parentClass).show().slideDown("slow"); } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 033c9dae..e7abbef9 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -92,7 +92,7 @@ id") ?>" - open_text="" + data-open-text="" class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left"> id != $user->id && !$user->guest): ?> -- cgit v1.2.3 From f9806089876a3ad912bd6e7f931025dad8c10bef Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 25 Feb 2013 15:09:42 +0100 Subject: Follow-on from autocomplete and gallery.panel.js revisions. (9345dde83e1f092a9309c45282dc21e3fd408875, d632ef3e50252d388c272cacd29e8cc6e4949cec, fd012276cbf03cc1dc7b8da10aac5cc6f26326c6) - revised xss_data.txt golden file (no new cases). - escaped translated string in admin_users.html.php (would have otherwise been a new case in xss_data.txt). --- modules/gallery/tests/xss_data.txt | 12 ++++++------ modules/user/views/admin_users.html.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/user') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 0028ac87..daba878d 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -42,7 +42,7 @@ modules/comment/views/user_profile_comments.html.php 11 DIRTY $comme modules/exif/views/exif_dialog.html.php 14 DIRTY $details[$i]["caption"] modules/exif/views/exif_dialog.html.php 21 DIRTY $details[$i]["caption"] modules/g2_import/views/admin_g2_import.html.php 7 DIRTY_JS url::site("__ARGS__") -modules/g2_import/views/admin_g2_import.html.php 52 DIRTY $form +modules/g2_import/views/admin_g2_import.html.php 49 DIRTY $form modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity) modules/gallery/views/admin_block_log_entries.html.php 8 DIRTY_JS user_profile::url($entry->user->id) @@ -216,7 +216,7 @@ modules/gallery/views/menu.html.php 18 DIRTY $eleme modules/gallery/views/menu_ajax_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":"" modules/gallery/views/menu_ajax_link.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_ajax_link.html.php 5 DIRTY_JS $menu->url -modules/gallery/views/menu_ajax_link.html.php 7 DIRTY $menu->ajax_handler +modules/gallery/views/menu_ajax_link.html.php 7 DIRTY_ATTR $menu->ajax_handler modules/gallery/views/menu_dialog.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":"" modules/gallery/views/menu_dialog.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu->url @@ -351,8 +351,8 @@ modules/search/views/search.html.php 47 DIRTY_ATTR $ite modules/search/views/search.html.php 57 DIRTY $theme->paginator() modules/search/views/search_link.html.php 15 DIRTY_ATTR $album_id modules/server_add/views/admin_server_add.html.php 8 DIRTY_JS url::site("__ARGS__") -modules/server_add/views/admin_server_add.html.php 19 DIRTY $form -modules/server_add/views/admin_server_add.html.php 30 DIRTY_ATTR $id +modules/server_add/views/admin_server_add.html.php 16 DIRTY $form +modules/server_add/views/admin_server_add.html.php 27 DIRTY_ATTR $id modules/server_add/views/server_add_tree.html.php 20 DIRTY_ATTR is_dir($file)?"ui-icon-folder-collapsed":"ui-icon-document" modules/server_add/views/server_add_tree.html.php 21 DIRTY_ATTR is_dir($file)?"g-directory":"g-file" modules/server_add/views/server_add_tree_dialog.html.php 3 DIRTY_JS url::site("server_add/children?path=__PATH__") @@ -360,8 +360,8 @@ modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY_JS url::s modules/server_add/views/server_add_tree_dialog.html.php 21 DIRTY $tree modules/tag/views/admin_tags.html.php 45 DIRTY_ATTR $tag->id modules/tag/views/admin_tags.html.php 46 DIRTY $tag->count -modules/tag/views/tag_block.html.php 28 DIRTY $cloud -modules/tag/views/tag_block.html.php 30 DIRTY $form +modules/tag/views/tag_block.html.php 26 DIRTY $cloud +modules/tag/views/tag_block.html.php 28 DIRTY $form modules/tag/views/tag_cloud.html.php 4 DIRTY_ATTR (int)(($tag->count/$max_count)*7) modules/tag/views/tag_cloud.html.php 5 DIRTY $tag->count modules/tag/views/tag_cloud.html.php 6 DIRTY_JS $tag->url() diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index e7abbef9..e4336f7f 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -92,7 +92,7 @@ id") ?>" - data-open-text="" + data-open-text="for_html_attr() ?>" class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left"> id != $user->id && !$user->guest): ?> -- cgit v1.2.3 From 86a21cc88127ea44d47e708c7093aa236317609d Mon Sep 17 00:00:00 2001 From: shadlaws Date: Tue, 12 Mar 2013 10:33:33 +0100 Subject: #2055, 2056 - jQuery updates for .attr("value", [value]) and .keyup(handler). - changed .attr("value", [value]) to .val([value]) for new jQuery. - changed .keyup(handler) to .on("input keyup", handler) to fire on mouse-only cut'n'paste. --- modules/gallery/js/l10n_client.js | 14 +++++++------- modules/gallery/views/admin_advanced_settings.html.php | 4 ++-- modules/user/js/password_strength.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'modules/user') diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index 6d919c29..261461b9 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -121,11 +121,11 @@ jQuery.extend(Gallery, { translation[form] = ''; } $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']") - .attr('value', translation[form]); + .val(translation[form]); $('#plural-' + form).removeClass('hidden'); } } else { - $('#l10n-edit-translation').attr('value', translation); + $('#l10n-edit-translation').val(translation); $('#l10n-edit-translation').removeClass('hidden'); } }; @@ -167,10 +167,10 @@ jQuery.extend(Gallery, { text = source['one']; } $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']") - .attr('value', text); + .val(text); } } else { - $('#l10n-edit-translation').attr('value', source); + $('#l10n-edit-translation').val(source); } } @@ -240,7 +240,7 @@ Gallery.behaviors.l10nClient = function(context) { }); // Custom listener for l10n_client livesearch - $('#l10n-client #g-l10n-search').keyup(function(key) { + $('#l10n-client #g-l10n-search').on("input keyup", function(key) { Gallery.l10nClient.filter($('#l10n-client #g-l10n-search').val()); }); @@ -264,11 +264,11 @@ Gallery.behaviors.l10nClient = function(context) { if (is_plural) { for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; - translation[form] = $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']").attr('value'); + translation[form] = $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']").val(); is_non_empty = is_non_empty || translation[form]; } } else { - translation = $('#l10n-edit-translation').attr('value'); + translation = $('#l10n-edit-translation').val(); is_non_empty = translation; } Gallery.l10nClient.setString(Gallery.l10nClient.selected, translation); diff --git a/modules/gallery/views/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php index 6745f0df..f4f0c81d 100644 --- a/modules/gallery/views/admin_advanced_settings.html.php +++ b/modules/gallery/views/admin_advanced_settings.html.php @@ -39,8 +39,8 @@