WORK IN PROGRESS, GET STABLE SOURCE FROM DOWNLOAD TAB

Adds search indicator

[TFS Changeset #64177]
This commit is contained in:
Shandem
2010-02-25 13:53:03 +00:00
parent 5a74f618da
commit f47c76e4db
7 changed files with 123 additions and 172 deletions

View File

@@ -1,4 +1,4 @@
<clientDependency isDebugMode="false" version="4">
<clientDependency isDebugMode="false" version="5">
<fileRegistration defaultProvider="PageHeaderProvider" fileDependencyExtensions="js,css" enableCompositeFiles="true">
<providers>
<add name="PageHeaderProvider" type="ClientDependency.Core.FileRegistration.Providers.PageHeaderProvider, ClientDependency.Core" />

View File

@@ -446,7 +446,6 @@
<Compile Include="umbraco\controls\ContentTypeControlNew.ascx.designer.cs">
<DependentUpon>ContentTypeControlNew.ascx</DependentUpon>
</Compile>
<Compile Include="umbraco\controls\datagrid\DropDownColumn.cs" />
<Compile Include="umbraco\controls\dualSelectBox.cs" />
<Compile Include="umbraco\controls\Extenders\CustomDragDropDesigner.cs" />
<Compile Include="umbraco\controls\Extenders\CustomDragDropExtender.cs" />

View File

@@ -35,8 +35,11 @@ namespace umbraco.presentation.umbraco.Search
app = UmbracoContext.Current.Request["app"];
}
IndexType indexType = (IndexType)Enum.Parse(typeof(IndexType), app);
int limit = 100;
int.TryParse(UmbracoContext.Current.Request["limit"], out limit);
int limit;
if (!int.TryParse(UmbracoContext.Current.Request["limit"], out limit))
{
limit = 100;
}
//if it doesn't start with "*", then search only nodeName and nodeId
var criteria = new SearchCriteria(txt
@@ -52,6 +55,7 @@ namespace umbraco.presentation.umbraco.Search
.SearchProviderCollection["InternalSearch"]
.Search(criteria);
JavaScriptSerializer js = new JavaScriptSerializer();
context.Response.Write(js.Serialize(results));
}

View File

@@ -26,8 +26,6 @@
},
parse: function(data) {
var parsed = [];
//data = data.results;
for (var i = 0; i < data.length; i++) {
parsed[parsed.length] = {
data: data[i],
@@ -35,7 +33,6 @@
result: data[i].Fields.nodeName
};
}
return parsed;
},
formatItem: function(item) {
@@ -50,6 +47,7 @@
$("#umbSearchField").val(UmbClientMgr.uiKeys()["general_typeToSearch"]);
right.focus();
});
$(this).focus(function() {
$(this).val('');

View File

@@ -1,99 +0,0 @@
using System;
using System.Collections;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Data;
namespace umbraco.controls.datagrid
{
public class DropDownColumn : DataGridColumn
{
private ListItemCollection _datasource = new ListItemCollection();
private string _datafield;
private string _dataValueField;
public ListItemCollection Items
{
get
{
return _datasource;
}
set
{
_datasource = value;
}
}
public string DataField
{
get
{
return _datafield;
}
set
{
_datafield = value;
}
}
public string DataValueField
{
get
{
return _dataValueField;
}
set
{
_dataValueField = value;
}
}
public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
{
base.InitializeCell (cell, columnIndex, itemType);
switch (itemType)
{
case ListItemType.Header :
cell.Text = HeaderText;
break;
case ListItemType.AlternatingItem :
case ListItemType.Item :
case ListItemType.EditItem :
cell.DataBinding += new System.EventHandler(EditItemDataBinding);
DropDownList DDL = new DropDownList();
cell.Controls.Add(DDL);
break;
}
}
private void ItemDataBinding(object sender, System.EventArgs e)
{
TableCell cell = (TableCell) sender;
DataGridItem DGI = (DataGridItem) cell.NamingContainer;
cell.Text = ((DataRowView) DGI.DataItem)[DataField].ToString();
}
private void EditItemDataBinding(object sender, System.EventArgs e)
{
TableCell cell = (TableCell) sender;
DataGridItem DGI = (DataGridItem) cell.NamingContainer;
DropDownList DDL = (DropDownList) cell.Controls[0];
string selectedValue = "";
try
{
}
catch {}
foreach (ListItem li in Items)
{
if (li.Value == selectedValue)
li.Selected = true;
DDL.Items.Add(li);
}
}
}
}

View File

@@ -155,3 +155,10 @@ img
{
font-size:smaller;
}
.ac_loading
{
background-image: url('../images/throbber.gif');
background-position:right;
background-repeat:no-repeat;
}

View File

@@ -1,17 +1,16 @@
//
// Autocomplete - jQuery plugin 1.0.2
//
// Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
//
// Dual licensed under the MIT and GPL licenses:
// http://www.opensource.org/licenses/mit-license.php
// http://www.gnu.org/licenses/gpl.html
//
// Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
//
//
/*
* jQuery Autocomplete plugin 1.1
*
* Copyright (c) 2009 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
*/
(function($) {
; (function($) {
$.fn.extend({
autocomplete: function(urlOrData, options) {
@@ -90,6 +89,9 @@
// only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
// a keypress means the input has focus
// avoids issue where input had focus before the autocomplete was applied
hasFocus = 1;
// track last key pressed
lastKeyPressCode = event.keyCode;
switch (event.keyCode) {
@@ -130,7 +132,7 @@
}
break;
// matches also semicolon
// matches also semicolon
case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
case KEY.TAB:
case KEY.RETURN:
@@ -209,7 +211,21 @@
if (options.multiple) {
var words = trimWords($input.val());
if (words.length > 1) {
v = words.slice(0, words.length - 1).join(options.multipleSeparator) + options.multipleSeparator + v;
var seperator = options.multipleSeparator.length;
var cursorAt = $(input).selection().start;
var wordAt, progress = 0;
$.each(words, function(i, word) {
progress += word.length;
if (cursorAt <= progress) {
wordAt = i;
return false;
}
progress += seperator;
});
words[wordAt] = v;
// TODO this should set the cursor to the right position, but it gets overriden somewhere
//$.Autocompleter.Selection(input, progress + seperator, progress + seperator);
v = words.join(options.multipleSeparator);
}
v += options.multipleSeparator;
}
@@ -228,60 +244,59 @@
var currentValue = $input.val();
// UMBRACO SPECIFIC, open window on space
if (currentValue == ' ') {
$input.blur();
UmbClientMgr.openModalWindow("dialogs/search.aspx", 'Search', true, 620, 470);
if (!skipPrevCheck && currentValue == previousValue)
return;
previousValue = currentValue;
currentValue = lastWord(currentValue);
if (currentValue.length >= options.minChars) {
$input.addClass(options.loadingClass);
if (!options.matchCase)
currentValue = currentValue.toLowerCase();
request(currentValue, receiveData, hideResultsNow);
} else {
if (!skipPrevCheck && currentValue == previousValue)
return;
previousValue = currentValue;
currentValue = lastWord(currentValue);
if (currentValue.length >= options.minChars) {
$input.addClass(options.loadingClass);
if (!options.matchCase)
currentValue = currentValue.toLowerCase();
request(currentValue, receiveData, hideResultsNow);
} else {
stopLoading();
select.hide();
}
stopLoading();
select.hide();
}
};
function trimWords(value) {
if (!value) {
if (!value)
return [""];
}
var words = value.split(options.multipleSeparator);
var result = [];
$.each(words, function(i, value) {
if ($.trim(value))
result[i] = $.trim(value);
if (!options.multiple)
return [$.trim(value)];
return $.map(value.split(options.multipleSeparator), function(word) {
return $.trim(value).length ? $.trim(word) : null;
});
return result;
}
function lastWord(value) {
if (!options.multiple)
return value;
var words = trimWords(value);
if (words.length == 1)
return words[0];
var cursorAt = $(input).selection().start;
if (cursorAt == value.length) {
words = trimWords(value)
} else {
words = trimWords(value.replace(value.substring(cursorAt), ""));
}
return words[words.length - 1];
}
// fills in the input box with the first match (assumed to be the best match)
// fills in the input box w/the first match (assumed to be the best match)
// q: the term entered
// sValue: the first matching result
function autoFill(q, sValue) {
// autofill in the complete box with the first match as long as the user hasn't entered in more data
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
// if the last user key pressed was backspace, don't autofill
if (options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE) {
// fill in the value (keep the case the user has typed)
$input.val($input.val() + sValue.substring(lastWord(previousValue).length));
// select the portion of the value not typed by the user (so the next character will erase)
$.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
$(input).selection(previousValue.length, previousValue.length + sValue.length);
}
};
@@ -305,15 +320,14 @@
var words = trimWords($input.val()).slice(0, -1);
$input.val(words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : ""));
}
else
else {
$input.val("");
$input.trigger("result", null);
}
}
}
);
}
if (wasVisible)
// position cursor at end of input field
$.Autocompleter.Selection(input, input.value.length, input.value.length);
};
function receiveData(q, data) {
@@ -424,10 +438,12 @@
var length = 0;
function matchSubset(s, sub) {
var s = '' + s;
if (!options.matchCase)
s = s.toLowerCase();
var i = s.indexOf(sub);
if (options.matchContains == "word") {
i = s.toLowerCase().search("\\b" + sub.toLowerCase());
}
if (i == -1) return false;
return i == 0 || options.matchContains;
};
@@ -509,9 +525,9 @@
load: function(q) {
if (!options.cacheLength || !length)
return null;
/*
* if dealing with local data and matchContains than we must make sure
* to loop through all the data collections looking for matches
/*
* if dealing w/local data and matchContains than we must make sure
* to loop through all the data collections looking for matches
*/
if (!options.url && options.matchContains) {
// track all matches
@@ -745,22 +761,48 @@
};
};
$.Autocompleter.Selection = function(field, start, end) {
$.fn.selection = function(start, end) {
if (start !== undefined) {
return this.each(function() {
if (this.createTextRange) {
var selRange = this.createTextRange();
if (end === undefined || start == end) {
selRange.move("character", start);
selRange.select();
} else {
selRange.collapse(true);
selRange.moveStart("character", start);
selRange.moveEnd("character", end);
selRange.select();
}
} else if (this.setSelectionRange) {
this.setSelectionRange(start, end);
} else if (this.selectionStart) {
this.selectionStart = start;
this.selectionEnd = end;
}
});
}
var field = this[0];
if (field.createTextRange) {
var selRange = field.createTextRange();
selRange.collapse(true);
selRange.moveStart("character", start);
selRange.moveEnd("character", end);
selRange.select();
} else if (field.setSelectionRange) {
field.setSelectionRange(start, end);
} else {
if (field.selectionStart) {
field.selectionStart = start;
field.selectionEnd = end;
var range = document.selection.createRange(),
orig = field.value,
teststring = "<->",
textLength = range.text.length;
range.text = teststring;
var caretAt = field.value.indexOf(teststring);
field.value = orig;
this.selection(caretAt, caretAt + textLength);
return {
start: caretAt,
end: caretAt + textLength
}
} else if (field.selectionStart !== undefined) {
return {
start: field.selectionStart,
end: field.selectionEnd
}
}
field.focus();
};
})(jQuery);