diff options
Diffstat (limited to 'rt/share/html/NoAuth/js')
-rw-r--r-- | rt/share/html/NoAuth/js/autohandler | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/cascaded.js | 100 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/combobox.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/dhandler | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/history-folding.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/jquery-ui-patch-datepicker.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/jquery_noconflict.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/late.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/titlebox-state.js | 2 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/userautocomplete.js | 20 | ||||
-rw-r--r-- | rt/share/html/NoAuth/js/util.js | 33 |
11 files changed, 116 insertions, 53 deletions
diff --git a/rt/share/html/NoAuth/js/autohandler b/rt/share/html/NoAuth/js/autohandler index b994580d3..29444400f 100644 --- a/rt/share/html/NoAuth/js/autohandler +++ b/rt/share/html/NoAuth/js/autohandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/cascaded.js b/rt/share/html/NoAuth/js/cascaded.js index 349d18187..b72a33f67 100644 --- a/rt/share/html/NoAuth/js/cascaded.js +++ b/rt/share/html/NoAuth/js/cascaded.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -45,50 +45,98 @@ %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} -function filter_cascade (id, val) { +function filter_cascade (id, vals) { + var element = document.getElementById(id); + if (!element) { return }; + + if ( element.tagName == 'SELECT' ) { + return filter_cascade_select.apply(this, arguments); + } + else { + if ( !( vals instanceof Array ) ) { + vals = [vals]; + } + + if ( arguments.length == 3 && (vals.length == 0 || (vals.length == 1 && vals[0] == '')) ) { + // no category, and the category is from a hierchical cf; + // leave it empty + jQuery(element).find('div').hide(); + } + else { + jQuery(element).find('div').hide().find('input').attr('disabled', 'disabled'); + jQuery(element).find('div[name=]').show().find('input').attr('disabled', ''); + jQuery(element).find('div.none').show().find('input').attr('disabled',''); + for ( var j = 0; j < vals.length; j++ ) { + jQuery(element).find('div[name^=' + vals[j] + ']').show().find('input').attr('disabled', ''); + } + } + } +} + +function filter_cascade_select (id, vals) { var select = document.getElementById(id); var complete_select = document.getElementById(id + "-Complete" ); + if ( !( vals instanceof Array ) ) { + vals = [vals]; + } if (!select) { return }; var i; var children = select.childNodes; if ( complete_select ) { - while (select.hasChildNodes()){ - select.removeChild(select.firstChild); - } + jQuery(select).children().remove(); var complete_children = complete_select.childNodes; - if ( val == '' && arguments.length == 3 ) { - // no category, and the category is from a hierchical cf; - // leave this set of options empty - } else if ( val == '' ) { - // no category, let's clone all node - for (i in complete_children) { - if ( complete_children[i].cloneNode ) { - new_option = complete_children[i].cloneNode(true); - select.appendChild(new_option); - } + var cloned_labels = {}; + var cloned_empty_label; + for ( var j = 0; j < vals.length; j++ ) { + var val = vals[j]; + if ( val == '' && arguments.length == 3 ) { + // no category, and the category is from a hierchical cf; + // leave this set of options empty + } else if ( val == '' ) { + // no category, let's clone all node + jQuery(select).append(jQuery(complete_children).clone()); + break; } - } - else { - for (i in complete_children) { - if (!complete_children[i].label || - (complete_children[i].hasAttribute && - !complete_children[i].hasAttribute('label') ) || - complete_children[i].label.substr(0, val.length) == val ) { - if ( complete_children[i].cloneNode ) { - new_option = complete_children[i].cloneNode(true); - select.appendChild(new_option); + else { + var labels_to_clone = {}; + for (i = 0; i < complete_children.length; i++) { + if (!complete_children[i].label || + (complete_children[i].hasAttribute && + !complete_children[i].hasAttribute('label') ) ) { + if ( cloned_empty_label ) { + continue; + } } + else if ( complete_children[i].label.substr(0, val.length) == val ) { + if ( cloned_labels[complete_children[i].label] ) { + continue; + } + labels_to_clone[complete_children[i].label] = true; + } + else { + continue; + } + + jQuery(select).append(jQuery(complete_children[i]).clone()); + } + + if ( !cloned_empty_label ) + cloned_empty_label = true; + + for ( label in labels_to_clone ) { + if ( !cloned_labels[label] ) + cloned_labels[label] = true; } } } } else { // for back compatibility - for (i in children) { + for (i = 0; i < children.length; i++) { if (!children[i].label) { continue }; if ( val == '' && arguments.length == 3 ) { hide(children[i]); diff --git a/rt/share/html/NoAuth/js/combobox.js b/rt/share/html/NoAuth/js/combobox.js index 51dded95e..27fa3881e 100644 --- a/rt/share/html/NoAuth/js/combobox.js +++ b/rt/share/html/NoAuth/js/combobox.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/dhandler b/rt/share/html/NoAuth/js/dhandler index 5e0ef1570..8059cd75c 100644 --- a/rt/share/html/NoAuth/js/dhandler +++ b/rt/share/html/NoAuth/js/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/history-folding.js b/rt/share/html/NoAuth/js/history-folding.js index 629ec739a..c4e441878 100644 --- a/rt/share/html/NoAuth/js/history-folding.js +++ b/rt/share/html/NoAuth/js/history-folding.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/jquery-ui-patch-datepicker.js b/rt/share/html/NoAuth/js/jquery-ui-patch-datepicker.js index b9e5a7789..4b2183293 100644 --- a/rt/share/html/NoAuth/js/jquery-ui-patch-datepicker.js +++ b/rt/share/html/NoAuth/js/jquery-ui-patch-datepicker.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/jquery_noconflict.js b/rt/share/html/NoAuth/js/jquery_noconflict.js index 87fe06cb3..b71b1cdd8 100644 --- a/rt/share/html/NoAuth/js/jquery_noconflict.js +++ b/rt/share/html/NoAuth/js/jquery_noconflict.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/late.js b/rt/share/html/NoAuth/js/late.js index 37ba9513e..763f2c15d 100644 --- a/rt/share/html/NoAuth/js/late.js +++ b/rt/share/html/NoAuth/js/late.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/titlebox-state.js b/rt/share/html/NoAuth/js/titlebox-state.js index 6e410939b..b8399a8dd 100644 --- a/rt/share/html/NoAuth/js/titlebox-state.js +++ b/rt/share/html/NoAuth/js/titlebox-state.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/NoAuth/js/userautocomplete.js b/rt/share/html/NoAuth/js/userautocomplete.js index 3c3f5fe07..b2b0f765a 100644 --- a/rt/share/html/NoAuth/js/userautocomplete.js +++ b/rt/share/html/NoAuth/js/userautocomplete.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -105,6 +105,22 @@ jQuery(function() { if (queryargs.length) options.source += "?" + queryargs.join("&"); - jQuery(input).autocomplete(options); + jQuery(input) + .addClass('autocompletes-user') + .autocomplete(options) + .data("autocomplete") + ._renderItem = function(ul, item) { + var rendered = jQuery("<a/>"); + + if (item.html == null) + rendered.text( item.label ); + else + rendered.html( item.html ); + + return jQuery("<li/>") + .data( "item.autocomplete", item ) + .append( rendered ) + .appendTo( ul ); + }; } }); diff --git a/rt/share/html/NoAuth/js/util.js b/rt/share/html/NoAuth/js/util.js index a267940ae..cc6e27535 100644 --- a/rt/share/html/NoAuth/js/util.js +++ b/rt/share/html/NoAuth/js/util.js @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -273,7 +273,7 @@ function textToHTML(value) { .replace(/\n/g, "\n<br />"); }; -function ReplaceAllTextareas(encoded) { +function ReplaceAllTextareas() { var sAgent = navigator.userAgent.toLowerCase(); if (!CKEDITOR.env.isCompatible || sAgent.indexOf('iphone') != -1 || @@ -288,23 +288,12 @@ function ReplaceAllTextareas(encoded) { var textArea = allTextAreas[i]; if (jQuery(textArea).hasClass("messagebox")) { // Turn the original plain text content into HTML - if (encoded == 0) { + var type = jQuery("#"+textArea.name+"Type"); + if (type.val() != "text/html") textArea.value = textToHTML(textArea.value); - } - // For this javascript - var CKeditorEncoded = document.createElement('input'); - CKeditorEncoded.setAttribute('type', 'hidden'); - CKeditorEncoded.setAttribute('name', 'CKeditorEncoded'); - CKeditorEncoded.setAttribute('value', '1'); - textArea.parentNode.appendChild(CKeditorEncoded); - - // 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); + // Set the type + type.val("text/html"); CKEDITOR.replace(textArea.name,{width:'100%',height:<% RT->Config->Get('MessageBoxRichTextHeight') |n,j%>}); CKEDITOR.basePath = <%RT->Config->Get('WebPath')|n,j%>+"/NoAuth/RichText/"; @@ -336,6 +325,16 @@ function update_addprincipal_title(title) { // when a value is selected from the autocompleter function addprincipal_onselect(ev, ui) { + + // if principal link exists, we shall go there instead + var principal_link = jQuery(ev.target).closest('form').find('ul.ui-tabs-nav a[href="#acl-' + ui.item.id + '"]:first'); + if (principal_link.size()) { + jQuery(this).val('').blur(); + update_addprincipal_title( '' ); // reset title to blank for #acl-AddPrincipal + principal_link.click(); + return false; + } + // pass the item's value along as the title since the input's value // isn't actually updated yet toggle_addprincipal_validity(this, true, ui.item.value); |