@@ -122,3 +122,49 @@ VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_loca
122122VE . helpers . warn = function ( msg ) {
123123 alert ( 'WARNING: ' + msg ) ;
124124}
125+
126+ VE . helpers . extendPasswordFields = function ( ) {
127+ var references = [ '.password' ] ;
128+
129+ $ ( document ) . ready ( function ( ) {
130+ $ ( references ) . each ( function ( i , ref ) {
131+ VE . helpers . initAdditionalPasswordFieldElements ( ref ) ;
132+ } ) ;
133+ } ) ;
134+ }
135+
136+ VE . helpers . initAdditionalPasswordFieldElements = function ( ref ) {
137+ var enabled = $ . cookie ( 'hide_passwords' ) == '1' ? true : false ;
138+ if ( enabled ) {
139+ VE . helpers . hidePasswordFieldText ( ref ) ;
140+ }
141+
142+ $ ( ref ) . prop ( 'autocomplete' , 'off' ) ;
143+
144+ var enabled_html = enabled ? '' : 'show-passwords-enabled-action' ;
145+ var html = '<span class="hide-password"><img class="toggle-psw-visibility-icon ' + enabled_html + '" onClick="VE.helpers.toggleHiddenPasswordText(\'' + ref + '\', this)" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAANlJREFUOI3d0UtKA0EQBuBP0eQCitkJLiXiSSTkUCKIIPg8SJCouDELrxDRCxi3SUQimXFhjRSDZq8/FE3/jyqqm3+JXVziGbOoJ1xgZ1GwiXMUKDFBH1cYB1fgBI16uIG7MJW4x1rS1zFIeh8rucFREicR7mKEV3SwgWnyHVThLXzUuotwxY2Cu0ncDJvLccko4lxKXPkL9509TMQ4du7E5BfsoYW35NvPU1dxncRB7FyhhYek99Qeka+fOMU8TNPY+TZNnuP4p3BGG2d4xHvUMJpvLwr+UXwCQghNMl5Zo0AAAAAASUVORK5CYII=" /></span>' ;
146+ $ ( ref ) . after ( html ) ;
147+ }
148+
149+ VE . helpers . hidePasswordFieldText = function ( ref ) {
150+ $ . cookie ( 'hide_passwords' , '1' , { expires : 365 , path : '/' } ) ;
151+ $ ( ref ) . prop ( 'type' , 'password' ) ;
152+ }
153+
154+ VE . helpers . revealPasswordFieldText = function ( ref ) {
155+ $ . cookie ( 'hide_passwords' , '0' , { expires : 365 , path : '/' } ) ;
156+ $ ( ref ) . prop ( 'type' , 'text' ) ;
157+ }
158+
159+ VE . helpers . toggleHiddenPasswordText = function ( ref , triggering_elm ) {
160+ $ ( triggering_elm ) . toggleClass ( 'show-passwords-enabled-action' ) ;
161+
162+ if ( $ ( ref ) . prop ( 'type' ) == 'text' ) {
163+ VE . helpers . hidePasswordFieldText ( ref ) ;
164+ }
165+ else {
166+ VE . helpers . revealPasswordFieldText ( ref ) ;
167+ }
168+ }
169+
170+ VE . helpers . extendPasswordFields ( ) ;
0 commit comments