[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-557-g22703a5

Jesse Vincent jesse at bestpractical.com
Tue Aug 24 21:56:09 EDT 2010


The branch, 3.9-trunk has been updated
       via  22703a517b17e3b12929dfe78eb6d592cad1e73c (commit)
       via  c00e19fff60921584b0ccd23d8c492ab49a87680 (commit)
       via  01ae221ccb7ebf7096934231f53796b6554e356d (commit)
      from  2551aae84d6098f583dcc31b91a92961107ee786 (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm        |  166 ++++++++++++++++++++--------------
 share/html/Elements/HeaderJavascript |   86 +-----------------
 share/html/NoAuth/js/util.js         |   67 ++++++++++++++
 3 files changed, 165 insertions(+), 154 deletions(-)

- Log -----------------------------------------------------------------
commit 01ae221ccb7ebf7096934231f53796b6554e356d
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 19:53:04 2010 -0400

    Start to update the fieldtypes datastructure to inline other field
    metadata

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 20a174c..087f239 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -57,56 +57,56 @@ use RT::ObjectCustomFieldValues;
 
 
 our %FieldTypes = (
-    Select => [
+    Select => { labels => [
         'Select multiple values',    # loc
         'Select one value',        # loc
         'Select up to [_1] values',    # loc
-    ],
-    Freeform => [
+    ]},
+    Freeform => { labels => [
         'Enter multiple values',    # loc
         'Enter one value',        # loc
         'Enter up to [_1] values',    # loc
-    ],
-    Text => [
+    ]},
+    Text => { labels => [
         'Fill in multiple text areas',    # loc
         'Fill in one text area',    # loc
         'Fill in up to [_1] text areas',# loc
-    ],
-    Wikitext => [
+    ]},
+    Wikitext => { labels => [
         'Fill in multiple wikitext areas',    # loc
         'Fill in one wikitext area',    # loc
         'Fill in up to [_1] wikitext areas',# loc
-    ],
-    Image => [
+    ]},
+    Image => { labels => [
         'Upload multiple images',    # loc
         'Upload one image',        # loc
         'Upload up to [_1] images',    # loc
-    ],
-    Binary => [
+    ]},
+    Binary => { labels => [
         'Upload multiple files',    # loc
         'Upload one file',        # loc
         'Upload up to [_1] files',    # loc
-    ],
-    Combobox => [
+    ]},
+    Combobox => { labels => [
         'Combobox: Select or enter multiple values',    # loc
         'Combobox: Select or enter one value',        # loc
         'Combobox: Select or enter up to [_1] values',    # loc
-    ],
-    Autocomplete => [
+    ]},
+    Autocomplete => { labels => [
         'Enter multiple values with autocompletion',    # loc
         'Enter one value with autocompletion',            # loc
         'Enter up to [_1] values with autocompletion',    # loc
-    ],
-    Date => [
+    ]},
+    Date => { labels => [
         'Select multiple dates',	# loc
         'Select date',			# loc
         'Select up to [_1] dates',	# loc
-    ],
-    DateTime => [
+    ]},
+    DateTime => { labels => [
         'Select multiple datetimes',	# loc
         'Select datetime',			# loc
         'Select up to [_1] datetimes',	# loc
-    ],
+    ]},
 );
 
 our %RenderTypes = (
@@ -595,7 +595,7 @@ sub FriendlyType {
     my $max  = @_ ? shift : $self->MaxValues;
     $max = 0 unless $max;
 
-    if (my $friendly_type = $FieldTypes{$type}[$max>2 ? 2 : $max]) {
+    if (my $friendly_type = $FieldTypes{$type}->{labels}->[$max>2 ? 2 : $max]) {
         return ( $self->loc( $friendly_type, $max ) );
     }
     else {

commit c00e19fff60921584b0ccd23d8c492ab49a87680
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 21:10:46 2010 -0400

    Replace the standalone RenderTypes data structure

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 087f239..d35b2a6 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -57,71 +57,100 @@ use RT::ObjectCustomFieldValues;
 
 
 our %FieldTypes = (
-    Select => { labels => [
-        'Select multiple values',    # loc
-        'Select one value',        # loc
-        'Select up to [_1] values',    # loc
-    ]},
-    Freeform => { labels => [
-        'Enter multiple values',    # loc
-        'Enter one value',        # loc
-        'Enter up to [_1] values',    # loc
-    ]},
-    Text => { labels => [
-        'Fill in multiple text areas',    # loc
-        'Fill in one text area',    # loc
-        'Fill in up to [_1] text areas',# loc
-    ]},
-    Wikitext => { labels => [
-        'Fill in multiple wikitext areas',    # loc
-        'Fill in one wikitext area',    # loc
-        'Fill in up to [_1] wikitext areas',# loc
-    ]},
-    Image => { labels => [
-        'Upload multiple images',    # loc
-        'Upload one image',        # loc
-        'Upload up to [_1] images',    # loc
-    ]},
-    Binary => { labels => [
-        'Upload multiple files',    # loc
-        'Upload one file',        # loc
-        'Upload up to [_1] files',    # loc
-    ]},
-    Combobox => { labels => [
-        'Combobox: Select or enter multiple values',    # loc
-        'Combobox: Select or enter one value',        # loc
-        'Combobox: Select or enter up to [_1] values',    # loc
-    ]},
-    Autocomplete => { labels => [
-        'Enter multiple values with autocompletion',    # loc
-        'Enter one value with autocompletion',            # loc
-        'Enter up to [_1] values with autocompletion',    # loc
-    ]},
-    Date => { labels => [
-        'Select multiple dates',	# loc
-        'Select date',			# loc
-        'Select up to [_1] dates',	# loc
-    ]},
-    DateTime => { labels => [
-        'Select multiple datetimes',	# loc
-        'Select datetime',			# loc
-        'Select up to [_1] datetimes',	# loc
-    ]},
-);
-
-our %RenderTypes = (
     Select => {
-        multiple => [
-            # Default is the first one
-            'Select box',   # loc
-            'List',         # loc
-        ],
-        single => [
-            'Select box',   # loc
-            'Dropdown',     # loc
-            'List',         # loc
-        ]
+        selection_type => 1,
+
+        labels => [ 'Select multiple values',      # loc
+                    'Select one value',            # loc
+                    'Select up to [_1] values',    # loc
+                  ],
+
+        render_types => {
+            multiple => [
+
+                # Default is the first one
+                'Select box',              # loc
+                'List',                    # loc
+            ],
+            single => [ 'Select box',              # loc
+                        'Dropdown',                # loc
+                        'List',                    # loc
+                      ]
+        },
+
     },
+    Freeform => {
+        selection_type => 0,
+
+        labels => [ 'Enter multiple values',       # loc
+                    'Enter one value',             # loc
+                    'Enter up to [_1] values',     # loc
+                  ]
+                },
+    Text => {
+        selection_type => 0,
+        labels         => [
+                    'Fill in multiple text areas',      # loc
+                    'Fill in one text area',            # loc
+                    'Fill in up to [_1] text areas',    # loc
+                  ]
+            },
+    Wikitext => {
+        selection_type => 0,
+        labels         => [
+                    'Fill in multiple wikitext areas',      # loc
+                    'Fill in one wikitext area',            # loc
+                    'Fill in up to [_1] wikitext areas',    # loc
+                  ]
+                },
+    Image => {
+        selection_type => 0,
+        labels         => [
+                    'Upload multiple images',               # loc
+                    'Upload one image',                     # loc
+                    'Upload up to [_1] images',             # loc
+                  ]
+             },
+    Binary => {
+        selection_type => 0,
+        labels         => [
+                    'Upload multiple files',                # loc
+                    'Upload one file',                      # loc
+                    'Upload up to [_1] files',              # loc
+                  ]
+              },
+    Combobox => {
+        selection_type => 1,
+        labels         => [
+                    'Combobox: Select or enter multiple values',      # loc
+                    'Combobox: Select or enter one value',            # loc
+                    'Combobox: Select or enter up to [_1] values',    # loc
+                  ]
+                },
+    Autocomplete => {
+        selection_type => 1,
+        labels         => [
+                    'Enter multiple values with autocompletion',      # loc
+                    'Enter one value with autocompletion',            # loc
+                    'Enter up to [_1] values with autocompletion',    # loc
+                  ]
+    },
+    Date => {
+        selection_type => 0,
+        labels         => [
+                    'Select multiple dates',                          # loc
+                    'Select date',                                    # loc
+                    'Select up to [_1] dates',                        # loc
+                  ]
+            },
+    DateTime => {
+        selection_type => 0,
+        labels         => [
+                    'Select multiple datetimes',                      # loc
+                    'Select datetime',                                # loc
+                    'Select up to [_1] datetimes',                    # loc
+                  ]
+                },
 );
 
 
@@ -524,7 +553,7 @@ sub HasRenderTypes {
     my $self = shift;
     my ($type, $max) = split /-/, (@_ ? shift : $self->TypeComposite), 2;
     return undef unless $type;
-    return defined $RenderTypes{$type}->{ $max == 1 ? 'single' : 'multiple' };
+    return defined $FieldTypes{$type}->{render_types}->{ $max == 1 ? 'single' : 'multiple' };
 }
 
 # {{{ IsSelectionType
@@ -540,8 +569,7 @@ sub IsSelectionType {
     my $self = shift;
     my $type = @_? shift : $self->Type;
     return undef unless $type;
-
-    $type =~ /(?:Select|Combobox|Autocomplete)/;
+    return $FieldTypes{$type}->{selection_type};
 }
 
 # }}}
@@ -933,7 +961,7 @@ sub DefaultRenderType {
     my $composite    = @_ ? shift : $self->TypeComposite;
     my ($type, $max) = split /-/, $composite, 2;
     return unless $type and $self->HasRenderTypes($composite);
-    return defined $RenderTypes{$type}->{ $max == 1 ? 'single' : 'multiple' }[0];
+    return defined $FieldTypes{$type}->{render_types}->{ $max == 1 ? 'single' : 'multiple' }[0];
 }
 
 =head2 RenderTypes [TYPE COMPOSITE]
@@ -948,7 +976,7 @@ sub RenderTypes {
     my $composite    = @_ ? shift : $self->TypeComposite;
     my ($type, $max) = split /-/, $composite, 2;
     return unless $type and $self->HasRenderTypes($composite);
-    return @{$RenderTypes{$type}->{ $max == 1 ? 'single' : 'multiple' }};
+    return @{$FieldTypes{$type}->{render_types}->{ $max == 1 ? 'single' : 'multiple' }};
 }
 
 =head2 SetLookupType

commit 22703a517b17e3b12929dfe78eb6d592cad1e73c
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 21:55:32 2010 -0400

    remove 3k from every page of RT that's loaded by offloading javascript
    into a library where it belongs

diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index acae3e8..30ddf67 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -58,40 +58,6 @@ $onload => undef
 <script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/squished.js"></script>
 % }
 
-<script type="text/javascript">
-	jQuery(function() {
-		jQuery(".ui-datepicker:not(.withtime)").datepicker( {
-            dateFormat: 'yy-mm-dd',
-            constrainInput: false
-        } );
-
-		jQuery(".ui-datepicker.withtime").datepicker( {
-            dateFormat: 'yy-mm-dd',
-            constrainInput: false, 
-            onSelect: function( dateText, inst ) { 
-                // trigger timepicker to get time
-                var button = document.createElement('input');
-                button.setAttribute('type',  'button');
-                jQuery(button).width('5em');
-                jQuery(button).insertAfter(this);
-                jQuery(button).timepickr({val: '00:00'});
-                var date_input = this;
-
-                jQuery(button).blur( function() {
-                    var time = jQuery(button).val();
-                    if ( ! time.match(/\d\d:\d\d/) ) {
-                        time = '00:00';
-                    }
-                    jQuery(date_input).val(  dateText + ' ' + time + ':00' );
-                    jQuery(button).remove();
-                } );
-
-                jQuery(button).focus();
-            }
-        } );
-	});
-</script>
-
 % if ( RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'}) ) {
 <script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/RichText/fckeditor.js"></script>
 % }
@@ -100,61 +66,11 @@ $onload => undef
 % if ( $focus ) {
     jQuery(function () { focusElementById('<% $focus %>') });
 % }
-
 % if ( $onload ) {
     jQuery( <% $onload |n %> );
 % }
 
 % if ( RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
-    function ReplaceAllTextareas() {
-        var sAgent = navigator.userAgent.toLowerCase();
-        if (!FCKeditor_IsCompatibleBrowser() ||
-            sAgent.indexOf('iphone') != -1 ||
-            sAgent.indexOf('android') != -1 )
-            return false;
-
-        // replace all content and signature message boxes
-        var allTextAreas = document.getElementsByTagName("textarea");
-
-        for (var i=0; i < allTextAreas.length; i++) {
-            var textArea = allTextAreas[i];
-            if ( (textArea.getAttribute('class') == 'messagebox')
-              || (textArea.getAttribute('className') == 'messagebox')) {
-                // Turn the original plain text content into HTML 
-
-%# Special case - when we re-edit a textarea, don't re-encode it
-% if (!$m->request_args->{'FCKeditorEncoded'}) {
-                textArea.value = textArea.value.replace(
-                    /&/g, "&amp;"
-                ).replace(
-                    /</g, "&lt;"
-                ).replace(
-                    />/g, "&gt;"
-                ).replace(
-                    /\n/g, "\n<br />"
-                );
-% }
-
-%# for this template..
-                var FCKeditorEncoded = document.createElement('input');
-                FCKeditorEncoded.setAttribute('type', 'hidden');
-                FCKeditorEncoded.setAttribute('name', 'FCKeditorEncoded');
-                FCKeditorEncoded.setAttribute('value', '1');
-                textArea.parentNode.appendChild(FCKeditorEncoded);
-
-%# for FCKeditor..
-                var typeField = document.createElement('input');
-                typeField.setAttribute('type', 'hidden');
-                typeField.setAttribute('name', textArea.name + 'Type');
-                typeField.setAttribute('value', 'text/html');
-                textArea.parentNode.appendChild(typeField);
-
-                var oFCKeditor = new FCKeditor( textArea.name, '100%', <% RT->Config->Get('MessageBoxRichTextHeight', $session{CurrentUser} ) %> );
-                oFCKeditor.BasePath = "<%RT->Config->Get('WebPath')%>/NoAuth/RichText/";
-                oFCKeditor.ReplaceTextarea();
-            }
-        }
-    }
-    jQuery(ReplaceAllTextareas);
+    jQuery().ready(function ()  { ReplaceAllTextareas('<%$m->request_args->{'FCKeditorEncoded'} || 0 %>') });
 % }
 --></script>
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 9c47065..bdb0f24 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -213,3 +213,70 @@ function doOnLoad( js ) {
     jQuery(js);
 }
 
+
+jQuery(function() {
+		jQuery(".ui-datepicker:not(.withtime)").datepicker( {
+            dateFormat: 'yy-mm-dd',
+            constrainInput: false
+        } );
+
+		jQuery(".ui-datepicker.withtime").datepicker( {
+            dateFormat: 'yy-mm-dd',
+            constrainInput: false,
+            onSelect: function( dateText, inst ) {
+                // trigger timepicker to get time
+                var button = document.createElement('input');
+                button.setAttribute('type',  'button');
+                jQuery(button).width('5em');
+                jQuery(button).insertAfter(this);
+                jQuery(button).timepickr({val: '00:00'});
+                var date_input = this;
+
+                jQuery(button).blur( function() {
+                    var time = jQuery(button).val();
+                    if ( ! time.match(/\d\d:\d\d/) ) {
+                        time = '00:00';
+                    }
+                    jQuery(date_input).val(  dateText + ' ' + time + ':00' );
+                    jQuery(button).remove();
+                } );
+
+                jQuery(button).focus();
+            }
+        } );
+	});
+
+    function ReplaceAllTextareas(encoded) {
+        var sAgent = navigator.userAgent.toLowerCase();
+        if (!FCKeditor_IsCompatibleBrowser() ||
+            sAgent.indexOf('iphone') != -1 ||
+            sAgent.indexOf('android') != -1 )
+            return false;
+
+        // replace all content and signature message boxes
+        var allTextAreas = document.getElementsByTagName("textarea");
+
+        for (var i=0; i < allTextAreas.length; i++) {
+            var textArea = allTextAreas[i];
+            if ( (textArea.getAttribute('class') == 'messagebox')
+              || (textArea.getAttribute('className') == 'messagebox')) {
+                // Turn the original plain text content into HTML
+                // if (encoded == 0) textArea.value = textArea.value .replace( /&/g, "&amp;") .replace( /</g, "&lt;") .replace( />/g, "&gt;") .replace( /\n/g, "\n<br />");
+                var FCKeditorEncoded = document.createElement('input');
+                FCKeditorEncoded.setAttribute('type', 'hidden');
+                FCKeditorEncoded.setAttribute('name', 'FCKeditorEncoded');
+                FCKeditorEncoded.setAttribute('value', '1');
+                textArea.parentNode.appendChild(FCKeditorEncoded);
+
+                var typeField = document.createElement('input');
+                typeField.setAttribute('type', 'hidden');
+                typeField.setAttribute('name', textArea.name + 'Type');
+                typeField.setAttribute('value', 'text/html');
+                textArea.parentNode.appendChild(typeField);
+
+                var oFCKeditor = new FCKeditor( textArea.name, '100%', <% RT->Config->Get('MessageBoxRichTextHeight', $session{CurrentUser} ) %> );
+                oFCKeditor.BasePath = "<%RT->Config->Get('WebPath')%>/NoAuth/RichText/";
+                oFCKeditor.ReplaceTextarea();
+            }
+        }
+    };

-----------------------------------------------------------------------


More information about the Rt-commit mailing list