fixws and 'new' button in grid query
This commit is contained in:
@@ -51,7 +51,7 @@ function doClickSave() {
|
||||
xhr.setRequestHeader('web2py-component-location',document.location);
|
||||
xhr.setRequestHeader('web2py-component-element','doClickSave');},
|
||||
success: function(json,text,xhr){
|
||||
|
||||
|
||||
// show flash message (if any)
|
||||
var flash=xhr.getResponseHeader('web2py-component-flash');
|
||||
if (flash) jQuery('.flash').html(flash).slideDown();
|
||||
@@ -73,13 +73,13 @@ function doClickSave() {
|
||||
editAreaLoader.setSelectionRange('body', json.highlight.start, json.highlight.end);
|
||||
} else {
|
||||
jQuery("input[name='saved_on']").attr('style','background-color:#99FF99');
|
||||
jQuery(".flash").delay(1000).fadeOut('slow');
|
||||
jQuery(".flash").delay(1000).fadeOut('slow');
|
||||
}
|
||||
// console.info(jQuery("input[name='file_hash']").val());
|
||||
|
||||
|
||||
var output = '<b>exposes:</b> ';
|
||||
for ( var i in json.functions) {
|
||||
output += ' <a href="/' + json.application + '/' + json.controller + '/' + json.functions[i] + '">' + json.functions[i] + '</a>,';
|
||||
output += ' <a href="/' + json.application + '/' + json.controller + '/' + json.functions[i] + '">' + json.functions[i] + '</a>,';
|
||||
}
|
||||
if(output!='<b>exposes:</b> ') {
|
||||
jQuery("#exposed").html( output.substring(0, output.length-1));
|
||||
@@ -89,7 +89,7 @@ function doClickSave() {
|
||||
on_error();
|
||||
}
|
||||
},
|
||||
error: function(json) { on_error(); }
|
||||
error: function(json) { on_error(); }
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -102,3 +102,4 @@ function keepalive(url) {
|
||||
success: function(){},
|
||||
error: function(x) { on_error(); } });
|
||||
}
|
||||
|
||||
|
||||
@@ -60,3 +60,4 @@ jQuery(document).ready(function () {
|
||||
// todo: some key - toggle off
|
||||
// todo: drag scrollbar up - toggle off
|
||||
// todo: drag scrollbar to bottom - toggle off
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,28 +2,28 @@
|
||||
(c) Copyrights 2007 - 2008
|
||||
|
||||
Original idea by by Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||
|
||||
jQuery Plugin by Tzury Bar Yochay
|
||||
|
||||
jQuery Plugin by Tzury Bar Yochay
|
||||
tzury.by@gmail.com
|
||||
http://evalinux.wordpress.com
|
||||
http://facebook.com/profile.php?id=513676303
|
||||
|
||||
Project's sites:
|
||||
Project's sites:
|
||||
http://code.google.com/p/js-hotkeys/
|
||||
http://github.com/tzuryby/hotkeys/tree/master
|
||||
|
||||
License: same as jQuery license.
|
||||
License: same as jQuery license.
|
||||
|
||||
USAGE:
|
||||
// simple usage
|
||||
$(document).bind('keydown', 'Ctrl+c', function(){ alert('copy anyone?');});
|
||||
|
||||
|
||||
// special options such as disableInIput
|
||||
$(document).bind('keydown', {combi:'Ctrl+x', disableInInput: true} , function() {});
|
||||
|
||||
|
||||
Note:
|
||||
This plugin wraps the following jQuery methods: $.fn.find, $.fn.bind and $.fn.unbind
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,23 +32,23 @@ Note:
|
||||
jQuery.fn.__bind__ = jQuery.fn.bind;
|
||||
jQuery.fn.__unbind__ = jQuery.fn.unbind;
|
||||
jQuery.fn.__find__ = jQuery.fn.find;
|
||||
|
||||
|
||||
var hotkeys = {
|
||||
version: '0.7.8',
|
||||
override: /keydown|keypress|keyup/g,
|
||||
triggersMap: {},
|
||||
|
||||
specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll',
|
||||
|
||||
specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll',
|
||||
20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',
|
||||
35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down',
|
||||
112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8',
|
||||
35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down',
|
||||
112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8',
|
||||
120:'f9', 121:'f10', 122:'f11', 123:'f12' },
|
||||
|
||||
shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
|
||||
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
|
||||
|
||||
shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
|
||||
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
|
||||
".":">", "/":"?", "\\":"|" },
|
||||
|
||||
newTrigger: function (type, combi, callback) {
|
||||
|
||||
newTrigger: function (type, combi, callback) {
|
||||
// i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}}
|
||||
var result = {};
|
||||
result[type] = {};
|
||||
@@ -58,17 +58,17 @@ Note:
|
||||
};
|
||||
// add firefox num pad char codes
|
||||
if (jQuery.browser.mozilla){
|
||||
hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99:
|
||||
hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99:
|
||||
'3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9' });
|
||||
}
|
||||
|
||||
// a wrapper around of $.fn.find
|
||||
|
||||
// a wrapper around of $.fn.find
|
||||
// see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d
|
||||
jQuery.fn.find = function( selector ) {
|
||||
this.query=selector;
|
||||
return jQuery.fn.__find__.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
jQuery.fn.unbind = function (type, combi, fn){
|
||||
if (jQuery.isFunction(combi)){
|
||||
fn = combi;
|
||||
@@ -84,27 +84,27 @@ Note:
|
||||
// call jQuery original unbind
|
||||
return this.__unbind__(type, fn);
|
||||
};
|
||||
|
||||
|
||||
jQuery.fn.bind = function(type, data, fn){
|
||||
// grab keyup,keydown,keypress
|
||||
var handle = type.match(hotkeys.override);
|
||||
|
||||
|
||||
if (jQuery.isFunction(data) || !handle){
|
||||
// call jQuery.bind only
|
||||
return this.__bind__(type, data, fn);
|
||||
}
|
||||
else{
|
||||
// split the job
|
||||
var result = null,
|
||||
var result = null,
|
||||
// pass the rest to the original $.fn.bind
|
||||
pass2jq = jQuery.trim(type.replace(hotkeys.override, ''));
|
||||
|
||||
|
||||
// see if there are other types, pass them to the original $.fn.bind
|
||||
if (pass2jq){
|
||||
// call original jQuery.bind()
|
||||
result = this.__bind__(pass2jq, data, fn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (typeof data === "string"){
|
||||
data = {'combi': data};
|
||||
}
|
||||
@@ -114,10 +114,10 @@ Note:
|
||||
var combi = data.combi.toLowerCase(),
|
||||
trigger = hotkeys.newTrigger(eventType, combi, fn),
|
||||
selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
|
||||
|
||||
|
||||
//trigger[eventType][combi].propagate = data.propagate;
|
||||
trigger[eventType][combi].disableInInput = data.disableInInput;
|
||||
|
||||
|
||||
// first time selector is bounded
|
||||
if (!hotkeys.triggersMap[selectorId]) {
|
||||
hotkeys.triggersMap[selectorId] = trigger;
|
||||
@@ -137,12 +137,12 @@ Note:
|
||||
else {
|
||||
hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length] = trigger[eventType][combi];
|
||||
}
|
||||
|
||||
|
||||
// add attribute and call $.event.add per matched element
|
||||
this.each(function(){
|
||||
// jQuery wrapper for the current element
|
||||
var jqElem = jQuery(this);
|
||||
|
||||
|
||||
// element already associated with another collection
|
||||
if (jqElem.attr('hkId') && jqElem.attr('hkId') !== selectorId){
|
||||
selectorId = jqElem.attr('hkId') + ";" + selectorId;
|
||||
@@ -155,7 +155,7 @@ Note:
|
||||
return result;
|
||||
}
|
||||
};
|
||||
// work-around for opera and safari where (sometimes) the target is the element which was last
|
||||
// work-around for opera and safari where (sometimes) the target is the element which was last
|
||||
// clicked with the mouse and not the document event it would make sense to get the document
|
||||
hotkeys.findElement = function (elem){
|
||||
if (!jQuery(elem).attr('hkId')){
|
||||
@@ -169,10 +169,10 @@ Note:
|
||||
};
|
||||
// the event handler
|
||||
hotkeys.handler = function(event) {
|
||||
var target = hotkeys.findElement(event.currentTarget),
|
||||
var target = hotkeys.findElement(event.currentTarget),
|
||||
jTarget = jQuery(target),
|
||||
ids = jTarget.attr('hkId');
|
||||
|
||||
|
||||
if(ids){
|
||||
ids = ids.split(';');
|
||||
var code = event.which,
|
||||
@@ -181,8 +181,8 @@ Note:
|
||||
// prevent f5 overlapping with 't' (or f4 with 's', etc.)
|
||||
character = !special && String.fromCharCode(code).toLowerCase(),
|
||||
shift = event.shiftKey,
|
||||
ctrl = event.ctrlKey,
|
||||
// patch for jquery 1.2.5 && 1.2.6 see more at:
|
||||
ctrl = event.ctrlKey,
|
||||
// patch for jquery 1.2.5 && 1.2.6 see more at:
|
||||
// http://groups.google.com/group/jquery-en/browse_thread/thread/83e10b3bb1f1c32b
|
||||
alt = event.altKey || event.originalEvent.altKey,
|
||||
mapPoint = null;
|
||||
@@ -193,9 +193,9 @@ Note:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//find by: id.type.combi.options
|
||||
if (mapPoint){
|
||||
|
||||
//find by: id.type.combi.options
|
||||
if (mapPoint){
|
||||
var trigger;
|
||||
// event type is associated with the hkId
|
||||
if(!shift && !ctrl && !alt) { // No Modifiers
|
||||
@@ -207,12 +207,12 @@ Note:
|
||||
if(alt) modif +='alt+';
|
||||
if(ctrl) modif+= 'ctrl+';
|
||||
if(shift) modif += 'shift+';
|
||||
|
||||
|
||||
// modifiers + special keys or modifiers + character or modifiers + shift character or just shift character
|
||||
trigger = mapPoint[modif+special];
|
||||
if (!trigger){
|
||||
if (character){
|
||||
trigger = mapPoint[modif+character]
|
||||
trigger = mapPoint[modif+character]
|
||||
|| mapPoint[modif+hotkeys.shiftNums[character]]
|
||||
// '$' can be triggered as 'Shift+4' or 'Shift+$' or just '$'
|
||||
|| (modif === 'shift+' && mapPoint[hotkeys.shiftNums[character]]);
|
||||
@@ -225,7 +225,7 @@ Note:
|
||||
if(trigger[x].disableInInput){
|
||||
// double check event.currentTarget and event.target
|
||||
var elem = jQuery(event.target);
|
||||
if (jTarget.is("input") || jTarget.is("textarea")
|
||||
if (jTarget.is("input") || jTarget.is("textarea")
|
||||
|| elem.is("input") || elem.is("textarea")) {
|
||||
return true;
|
||||
}
|
||||
@@ -242,3 +242,4 @@ Note:
|
||||
window.hotkeys = hotkeys;
|
||||
return jQuery;
|
||||
})(jQuery);
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
+270
-270
@@ -1,270 +1,270 @@
|
||||
/*
|
||||
// jQuery multiSelect
|
||||
//
|
||||
// Version 1.0 beta
|
||||
//
|
||||
// Cory S.N. LaViska
|
||||
// A Beautiful Site (http://abeautifulsite.net/)
|
||||
// 06 April 2008
|
||||
//
|
||||
// Visit http://abeautifulsite.net/notebook.php?article=62 for more information
|
||||
//
|
||||
// Usage: $('#control_id').multiSelect( options, callback )
|
||||
//
|
||||
// Options: selectAll - whether or not to display the Select All option; true/false, default = true
|
||||
// selectAllText - text to display for selecting/unselecting all options simultaneously
|
||||
// noneSelected - text to display when there are no selected items in the list
|
||||
// oneOrMoreSelected - text to display when there are one or more selected items in the list
|
||||
// (note: you can use % as a placeholder for the number of items selected).
|
||||
// Use * to show a comma separated list of all selected; default = '% selected'
|
||||
//
|
||||
// Dependencies: jQuery 1.2 or higher (http://jquery.com/)
|
||||
// the jQuery Dimensions plugin (http://plugins.jquery.com/project/dimensions)
|
||||
//
|
||||
// Licensing & Terms of Use
|
||||
//
|
||||
// jQuery File Tree is licensed under a Creative Commons License and is copyrighted (C)2008 by Cory S.N. LaViska.
|
||||
// For details, visit http://creativecommons.org/licenses/by/3.0/us/
|
||||
//
|
||||
*/
|
||||
if(jQuery) (function($){
|
||||
|
||||
$.extend($.fn, {
|
||||
multiSelect: function(o, callback) {
|
||||
// Default options
|
||||
if( !o ) var o = {};
|
||||
if( o.selectAll == undefined ) o.selectAll = true;
|
||||
if( o.selectAllText == undefined ) o.selectAllText = "Select All";
|
||||
if( o.noneSelected == undefined ) o.noneSelected = 'Select options';
|
||||
if( o.oneOrMoreSelected == undefined ) o.oneOrMoreSelected = '% selected';
|
||||
|
||||
// Initialize each multiSelect
|
||||
$(this).each( function() {
|
||||
var select = $(this);
|
||||
var html = '<input type="text" readonly="readonly" class="multiSelect" value="" style="cursor: default;" />';
|
||||
html += '<div class="multiSelectOptions" style="position: absolute; z-index: 99999; display: none;">';
|
||||
if( o.selectAll ) html += '<label class="selectAll"><input type="checkbox" class="selectAll" />' + o.selectAllText + '</label>';
|
||||
$(select).find('OPTION').each( function() {
|
||||
if( $(this).val() != '' ) {
|
||||
html += '<label><input type="checkbox" name="' + $(select).attr('name') + '" value="' + $(this).val() + '"';
|
||||
if( $(this).attr('selected') ) html += ' checked="checked"';
|
||||
html += ' />' + $(this).html() + '</label>';
|
||||
}
|
||||
});
|
||||
html += '</div>';
|
||||
$(select).after(html);
|
||||
|
||||
// Events
|
||||
$(select).next('.multiSelect').mouseover( function() {
|
||||
$(this).addClass('hover');
|
||||
}).mouseout( function() {
|
||||
$(this).removeClass('hover');
|
||||
}).click( function() {
|
||||
// Show/hide on click
|
||||
if( $(this).hasClass('active') ) {
|
||||
$(this).multiSelectOptionsHide();
|
||||
} else {
|
||||
$(this).multiSelectOptionsShow();
|
||||
}
|
||||
return false;
|
||||
}).focus( function() {
|
||||
// So it can be styled with CSS
|
||||
$(this).addClass('focus');
|
||||
}).blur( function() {
|
||||
// So it can be styled with CSS
|
||||
$(this).removeClass('focus');
|
||||
});
|
||||
|
||||
// Determine if Select All should be checked initially
|
||||
if( o.selectAll ) {
|
||||
var sa = true;
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').not('.selectAll').each( function() {
|
||||
if( !$(this).attr('checked') ) sa = false;
|
||||
});
|
||||
if( sa ) $(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').attr('checked', true).parent().addClass('checked');
|
||||
}
|
||||
|
||||
// Handle Select All
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').click( function() {
|
||||
if( $(this).attr('checked') == true ) $(this).parent().parent().find('INPUT:checkbox').attr('checked', true).parent().addClass('checked'); else $(this).parent().parent().find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
|
||||
});
|
||||
|
||||
// Handle checkboxes
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').click( function() {
|
||||
$(this).parent().parent().multiSelectUpdateSelected(o);
|
||||
$(this).parent().parent().find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
$(this).parent().parent().prev('.multiSelect').focus();
|
||||
if( !$(this).attr('checked') ) $(this).parent().parent().find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
});
|
||||
|
||||
// Initial display
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').each( function() {
|
||||
$(this).multiSelectUpdateSelected(o);
|
||||
$(this).find('INPUT:checked').parent().addClass('checked');
|
||||
});
|
||||
|
||||
// Handle hovers
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('LABEL').mouseover( function() {
|
||||
$(this).parent().find('LABEL').removeClass('hover');
|
||||
$(this).addClass('hover');
|
||||
}).mouseout( function() {
|
||||
$(this).parent().find('LABEL').removeClass('hover');
|
||||
});
|
||||
|
||||
// Keyboard
|
||||
$(select).next('.multiSelect').keydown( function(e) {
|
||||
// Is dropdown visible?
|
||||
if( $(this).next('.multiSelectOptions').is(':visible') ) {
|
||||
// Dropdown is visible
|
||||
// Tab
|
||||
if( e.keyCode == 9 ) {
|
||||
$(this).addClass('focus').trigger('click'); // esc, left, right - hide
|
||||
$(this).focus().next(':input').focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ESC, Left, Right
|
||||
if( e.keyCode == 27 || e.keyCode == 37 || e.keyCode == 39 ) {
|
||||
// Hide dropdown
|
||||
$(this).addClass('focus').trigger('click');
|
||||
}
|
||||
// Down
|
||||
if( e.keyCode == 40 ) {
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
// Default to first item
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
} else {
|
||||
// Move down, cycle to top if on bottom
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').next('LABEL').addClass('hover');
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Up
|
||||
if( e.keyCode == 38 ) {
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
// Default to first item
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
} else {
|
||||
// Move up, cycle to bottom if on top
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').prev('LABEL').addClass('hover');
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
$(this).next('.multiSelectOptions').find('LABEL:last').addClass('hover');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Enter, Space
|
||||
if( e.keyCode == 13 || e.keyCode == 32 ) {
|
||||
// Select All
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').hasClass('selectAll') ) {
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
|
||||
// Uncheck all
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
|
||||
} else {
|
||||
// Check all
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', true).parent().addClass('checked');
|
||||
}
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
if( callback ) callback($(this));
|
||||
return false;
|
||||
}
|
||||
// Other checkboxes
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
|
||||
// Uncheck
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', false);
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
// Select all status can't be checked at this point
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
} else {
|
||||
// Check
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', true);
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// Dropdown is not visible
|
||||
if( e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.keyCode == 32 ) { // down, enter, space - show
|
||||
// Show dropdown
|
||||
$(this).removeClass('focus').trigger('click');
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
return false;
|
||||
}
|
||||
// Tab key
|
||||
if( e.keyCode == 9 ) {
|
||||
// Shift focus to next INPUT element on page
|
||||
$(this).focus().next(':input').focus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Prevent enter key from submitting form
|
||||
if( e.keyCode == 13 ) return false;
|
||||
});
|
||||
|
||||
// Eliminate the original form element
|
||||
$(select).remove();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// Hide the dropdown
|
||||
multiSelectOptionsHide: function() {
|
||||
$(this).removeClass('active').next('.multiSelectOptions').hide();
|
||||
},
|
||||
|
||||
// Show the dropdown
|
||||
multiSelectOptionsShow: function() {
|
||||
// Hide any open option boxes
|
||||
$('.multiSelect').multiSelectOptionsHide();
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('hover');
|
||||
$(this).addClass('active').next('.multiSelectOptions').show();
|
||||
|
||||
// Position it
|
||||
var offset = $(this).offset();
|
||||
$(this).next('.multiSelectOptions').css({ top: offset.top + $(this).outerHeight() + 'px' });
|
||||
$(this).next('.multiSelectOptions').css({ left: offset.left + 'px' });
|
||||
|
||||
// Disappear on hover out
|
||||
multiSelectCurrent = $(this);
|
||||
var timer = '';
|
||||
$(this).next('.multiSelectOptions').hover( function() {
|
||||
clearTimeout(timer);
|
||||
}, function() {
|
||||
timer = setTimeout('$(multiSelectCurrent).multiSelectOptionsHide(); $(multiSelectCurrent).unbind("hover");', 250);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// Update the textbox with the total number of selected items
|
||||
multiSelectUpdateSelected: function(o) {
|
||||
var i = 0, s = '';
|
||||
$(this).find('INPUT:checkbox:checked').not('.selectAll').each( function() {
|
||||
i++;
|
||||
})
|
||||
if( i == 0 ) {
|
||||
$(this).prev('INPUT.multiSelect').val( o.noneSelected );
|
||||
} else {
|
||||
if( o.oneOrMoreSelected == '*' ) {
|
||||
var display = '';
|
||||
$(this).find('INPUT:checkbox:checked').each( function() {
|
||||
if( $(this).parent().text() != o.selectAllText ) display = display + $(this).parent().text() + ', ';
|
||||
});
|
||||
display = display.substr(0, display.length - 2);
|
||||
$(this).prev('INPUT.multiSelect').val( display );
|
||||
} else {
|
||||
$(this).prev('INPUT.multiSelect').val( o.oneOrMoreSelected.replace('%', i) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
/*
|
||||
// jQuery multiSelect
|
||||
//
|
||||
// Version 1.0 beta
|
||||
//
|
||||
// Cory S.N. LaViska
|
||||
// A Beautiful Site (http://abeautifulsite.net/)
|
||||
// 06 April 2008
|
||||
//
|
||||
// Visit http://abeautifulsite.net/notebook.php?article=62 for more information
|
||||
//
|
||||
// Usage: $('#control_id').multiSelect( options, callback )
|
||||
//
|
||||
// Options: selectAll - whether or not to display the Select All option; true/false, default = true
|
||||
// selectAllText - text to display for selecting/unselecting all options simultaneously
|
||||
// noneSelected - text to display when there are no selected items in the list
|
||||
// oneOrMoreSelected - text to display when there are one or more selected items in the list
|
||||
// (note: you can use % as a placeholder for the number of items selected).
|
||||
// Use * to show a comma separated list of all selected; default = '% selected'
|
||||
//
|
||||
// Dependencies: jQuery 1.2 or higher (http://jquery.com/)
|
||||
// the jQuery Dimensions plugin (http://plugins.jquery.com/project/dimensions)
|
||||
//
|
||||
// Licensing & Terms of Use
|
||||
//
|
||||
// jQuery File Tree is licensed under a Creative Commons License and is copyrighted (C)2008 by Cory S.N. LaViska.
|
||||
// For details, visit http://creativecommons.org/licenses/by/3.0/us/
|
||||
//
|
||||
*/
|
||||
if(jQuery) (function($){
|
||||
|
||||
$.extend($.fn, {
|
||||
multiSelect: function(o, callback) {
|
||||
// Default options
|
||||
if( !o ) var o = {};
|
||||
if( o.selectAll == undefined ) o.selectAll = true;
|
||||
if( o.selectAllText == undefined ) o.selectAllText = "Select All";
|
||||
if( o.noneSelected == undefined ) o.noneSelected = 'Select options';
|
||||
if( o.oneOrMoreSelected == undefined ) o.oneOrMoreSelected = '% selected';
|
||||
|
||||
// Initialize each multiSelect
|
||||
$(this).each( function() {
|
||||
var select = $(this);
|
||||
var html = '<input type="text" readonly="readonly" class="multiSelect" value="" style="cursor: default;" />';
|
||||
html += '<div class="multiSelectOptions" style="position: absolute; z-index: 99999; display: none;">';
|
||||
if( o.selectAll ) html += '<label class="selectAll"><input type="checkbox" class="selectAll" />' + o.selectAllText + '</label>';
|
||||
$(select).find('OPTION').each( function() {
|
||||
if( $(this).val() != '' ) {
|
||||
html += '<label><input type="checkbox" name="' + $(select).attr('name') + '" value="' + $(this).val() + '"';
|
||||
if( $(this).attr('selected') ) html += ' checked="checked"';
|
||||
html += ' />' + $(this).html() + '</label>';
|
||||
}
|
||||
});
|
||||
html += '</div>';
|
||||
$(select).after(html);
|
||||
|
||||
// Events
|
||||
$(select).next('.multiSelect').mouseover( function() {
|
||||
$(this).addClass('hover');
|
||||
}).mouseout( function() {
|
||||
$(this).removeClass('hover');
|
||||
}).click( function() {
|
||||
// Show/hide on click
|
||||
if( $(this).hasClass('active') ) {
|
||||
$(this).multiSelectOptionsHide();
|
||||
} else {
|
||||
$(this).multiSelectOptionsShow();
|
||||
}
|
||||
return false;
|
||||
}).focus( function() {
|
||||
// So it can be styled with CSS
|
||||
$(this).addClass('focus');
|
||||
}).blur( function() {
|
||||
// So it can be styled with CSS
|
||||
$(this).removeClass('focus');
|
||||
});
|
||||
|
||||
// Determine if Select All should be checked initially
|
||||
if( o.selectAll ) {
|
||||
var sa = true;
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').not('.selectAll').each( function() {
|
||||
if( !$(this).attr('checked') ) sa = false;
|
||||
});
|
||||
if( sa ) $(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').attr('checked', true).parent().addClass('checked');
|
||||
}
|
||||
|
||||
// Handle Select All
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').click( function() {
|
||||
if( $(this).attr('checked') == true ) $(this).parent().parent().find('INPUT:checkbox').attr('checked', true).parent().addClass('checked'); else $(this).parent().parent().find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
|
||||
});
|
||||
|
||||
// Handle checkboxes
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').click( function() {
|
||||
$(this).parent().parent().multiSelectUpdateSelected(o);
|
||||
$(this).parent().parent().find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
$(this).parent().parent().prev('.multiSelect').focus();
|
||||
if( !$(this).attr('checked') ) $(this).parent().parent().find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
});
|
||||
|
||||
// Initial display
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').each( function() {
|
||||
$(this).multiSelectUpdateSelected(o);
|
||||
$(this).find('INPUT:checked').parent().addClass('checked');
|
||||
});
|
||||
|
||||
// Handle hovers
|
||||
$(select).next('.multiSelect').next('.multiSelectOptions').find('LABEL').mouseover( function() {
|
||||
$(this).parent().find('LABEL').removeClass('hover');
|
||||
$(this).addClass('hover');
|
||||
}).mouseout( function() {
|
||||
$(this).parent().find('LABEL').removeClass('hover');
|
||||
});
|
||||
|
||||
// Keyboard
|
||||
$(select).next('.multiSelect').keydown( function(e) {
|
||||
// Is dropdown visible?
|
||||
if( $(this).next('.multiSelectOptions').is(':visible') ) {
|
||||
// Dropdown is visible
|
||||
// Tab
|
||||
if( e.keyCode == 9 ) {
|
||||
$(this).addClass('focus').trigger('click'); // esc, left, right - hide
|
||||
$(this).focus().next(':input').focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ESC, Left, Right
|
||||
if( e.keyCode == 27 || e.keyCode == 37 || e.keyCode == 39 ) {
|
||||
// Hide dropdown
|
||||
$(this).addClass('focus').trigger('click');
|
||||
}
|
||||
// Down
|
||||
if( e.keyCode == 40 ) {
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
// Default to first item
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
} else {
|
||||
// Move down, cycle to top if on bottom
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').next('LABEL').addClass('hover');
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Up
|
||||
if( e.keyCode == 38 ) {
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
// Default to first item
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
} else {
|
||||
// Move up, cycle to bottom if on top
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').prev('LABEL').addClass('hover');
|
||||
if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
|
||||
$(this).next('.multiSelectOptions').find('LABEL:last').addClass('hover');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Enter, Space
|
||||
if( e.keyCode == 13 || e.keyCode == 32 ) {
|
||||
// Select All
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').hasClass('selectAll') ) {
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
|
||||
// Uncheck all
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
|
||||
} else {
|
||||
// Check all
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', true).parent().addClass('checked');
|
||||
}
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
if( callback ) callback($(this));
|
||||
return false;
|
||||
}
|
||||
// Other checkboxes
|
||||
if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
|
||||
// Uncheck
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', false);
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
// Select all status can't be checked at this point
|
||||
$(this).next('.multiSelectOptions').find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
} else {
|
||||
// Check
|
||||
$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', true);
|
||||
$(this).next('.multiSelectOptions').multiSelectUpdateSelected(o);
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
|
||||
if( callback ) callback($(this));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// Dropdown is not visible
|
||||
if( e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.keyCode == 32 ) { // down, enter, space - show
|
||||
// Show dropdown
|
||||
$(this).removeClass('focus').trigger('click');
|
||||
$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
|
||||
return false;
|
||||
}
|
||||
// Tab key
|
||||
if( e.keyCode == 9 ) {
|
||||
// Shift focus to next INPUT element on page
|
||||
$(this).focus().next(':input').focus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Prevent enter key from submitting form
|
||||
if( e.keyCode == 13 ) return false;
|
||||
});
|
||||
|
||||
// Eliminate the original form element
|
||||
$(select).remove();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// Hide the dropdown
|
||||
multiSelectOptionsHide: function() {
|
||||
$(this).removeClass('active').next('.multiSelectOptions').hide();
|
||||
},
|
||||
|
||||
// Show the dropdown
|
||||
multiSelectOptionsShow: function() {
|
||||
// Hide any open option boxes
|
||||
$('.multiSelect').multiSelectOptionsHide();
|
||||
$(this).next('.multiSelectOptions').find('LABEL').removeClass('hover');
|
||||
$(this).addClass('active').next('.multiSelectOptions').show();
|
||||
|
||||
// Position it
|
||||
var offset = $(this).offset();
|
||||
$(this).next('.multiSelectOptions').css({ top: offset.top + $(this).outerHeight() + 'px' });
|
||||
$(this).next('.multiSelectOptions').css({ left: offset.left + 'px' });
|
||||
|
||||
// Disappear on hover out
|
||||
multiSelectCurrent = $(this);
|
||||
var timer = '';
|
||||
$(this).next('.multiSelectOptions').hover( function() {
|
||||
clearTimeout(timer);
|
||||
}, function() {
|
||||
timer = setTimeout('$(multiSelectCurrent).multiSelectOptionsHide(); $(multiSelectCurrent).unbind("hover");', 250);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// Update the textbox with the total number of selected items
|
||||
multiSelectUpdateSelected: function(o) {
|
||||
var i = 0, s = '';
|
||||
$(this).find('INPUT:checkbox:checked').not('.selectAll').each( function() {
|
||||
i++;
|
||||
})
|
||||
if( i == 0 ) {
|
||||
$(this).prev('INPUT.multiSelect').val( o.noneSelected );
|
||||
} else {
|
||||
if( o.oneOrMoreSelected == '*' ) {
|
||||
var display = '';
|
||||
$(this).find('INPUT:checkbox:checked').each( function() {
|
||||
if( $(this).parent().text() != o.selectAllText ) display = display + $(this).parent().text() + ', ';
|
||||
});
|
||||
display = display.substr(0, display.length - 2);
|
||||
$(this).prev('INPUT.multiSelect').val( display );
|
||||
} else {
|
||||
$(this).prev('INPUT.multiSelect').val( o.oneOrMoreSelected.replace('%', i) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -18,7 +18,7 @@ function ajax(u,s,t) {
|
||||
}
|
||||
if (pcs.length>0){query = pcs.join("&");}
|
||||
}
|
||||
jQuery.ajax({type: "POST", url: u, data: query, success: function(msg) { if(t) { if(t==':eval') eval(msg); else jQuery("#" + t).html(msg); } } });
|
||||
jQuery.ajax({type: "POST", url: u, data: query, success: function(msg) { if(t) { if(t==':eval') eval(msg); else jQuery("#" + t).html(msg); } } });
|
||||
}
|
||||
|
||||
String.prototype.reverse = function () { return this.split('').reverse().join('');};
|
||||
@@ -30,9 +30,9 @@ function web2py_ajax_fields(target) {
|
||||
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
|
||||
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
|
||||
jQuery("input.date",target).each(function() {Calendar.setup({inputField:this, ifFormat:date_format, showsTime:false });});
|
||||
jQuery("input.datetime",target).each(function() {Calendar.setup({inputField:this, ifFormat:datetime_format, showsTime: true, timeFormat: "24" });});
|
||||
jQuery("input.datetime",target).each(function() {Calendar.setup({inputField:this, ifFormat:datetime_format, showsTime: true, timeFormat: "24" });});
|
||||
jQuery("input.time",target).each(function(){jQuery(this).timeEntry();});
|
||||
|
||||
|
||||
};
|
||||
|
||||
function web2py_ajax_init(target) {
|
||||
@@ -43,7 +43,7 @@ function web2py_ajax_init(target) {
|
||||
web2py_ajax_fields(target);
|
||||
};
|
||||
|
||||
jQuery(function() {
|
||||
jQuery(function() {
|
||||
var flash = jQuery('.flash');
|
||||
flash.hide();
|
||||
if(flash.html()) flash.slideDown();
|
||||
@@ -68,7 +68,7 @@ function web2py_trap_link(target) {
|
||||
web2py_ajax_page('get',link.attr('href'),[],target);
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
function web2py_ajax_page(method,action,data,target) {
|
||||
jQuery.ajax({'type':method,'url':action,'data':data,
|
||||
@@ -77,16 +77,16 @@ function web2py_ajax_page(method,action,data,target) {
|
||||
xhr.setRequestHeader('web2py-component-element',target);},
|
||||
'complete':function(xhr,text){
|
||||
var html=xhr.responseText;
|
||||
var content=xhr.getResponseHeader('web2py-component-content');
|
||||
var content=xhr.getResponseHeader('web2py-component-content');
|
||||
var command=xhr.getResponseHeader('web2py-component-command');
|
||||
var flash=xhr.getResponseHeader('web2py-component-flash');
|
||||
var t = jQuery('#'+target);
|
||||
if(content=='prepend') t.prepend(html);
|
||||
if(content=='prepend') t.prepend(html);
|
||||
else if(content=='append') t.append(html);
|
||||
else if(content!='hide') t.html(html);
|
||||
else if(content!='hide') t.html(html);
|
||||
web2py_trap_form(action,target);
|
||||
web2py_trap_link(target);
|
||||
web2py_ajax_init('#'+target);
|
||||
web2py_ajax_init('#'+target);
|
||||
if(command) eval(command);
|
||||
if(flash) jQuery('.flash').html(flash).slideDown();
|
||||
}
|
||||
@@ -104,3 +104,4 @@ function web2py_comet(url,onmessage,onopen,onclose) {
|
||||
return true; // supported
|
||||
} else return false; // not supported
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user