fixed problem with web2py.js, thanks Niphlod
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.07.06.16.05.45
|
Version 2.6.0-development+timestamp.2013.07.07.12.24.46
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
(function ($, undefined) {
|
(function (jQuery, undefined) {
|
||||||
/*
|
/*
|
||||||
* Unobtrusive scripting adapter for jQuery, largely taken from
|
* Unobtrusive scripting adapter for jQuery, largely taken from
|
||||||
* the wonderful https://github.com/rails/jquery-ujs
|
* the wonderful https://github.com/rails/jquery-ujs
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
};
|
};
|
||||||
var web2py;
|
var web2py;
|
||||||
|
|
||||||
$.web2py = web2py = {
|
jQuery.web2py = web2py = {
|
||||||
|
|
||||||
popup: function (url) {
|
popup: function (url) {
|
||||||
newwindow = window.open(url, 'name', 'height=400,width=600');
|
newwindow = window.open(url, 'name', 'height=400,width=600');
|
||||||
@@ -21,23 +21,23 @@
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
collapse: function (id) {
|
collapse: function (id) {
|
||||||
$('#' + id).slideToggle();
|
jQuery('#' + id).slideToggle();
|
||||||
},
|
},
|
||||||
fade: function (id, value) {
|
fade: function (id, value) {
|
||||||
if(value > 0) $('#' + id).hide().fadeIn('slow');
|
if(value > 0) jQuery('#' + id).hide().fadeIn('slow');
|
||||||
else $('#' + id).show().fadeOut('slow');
|
else jQuery('#' + id).show().fadeOut('slow');
|
||||||
},
|
},
|
||||||
ajax: function (u, s, t) {
|
ajax: function (u, s, t) {
|
||||||
query = '';
|
query = '';
|
||||||
if(typeof s == "string") {
|
if(typeof s == "string") {
|
||||||
d = $(s).serialize();
|
d = jQuery(s).serialize();
|
||||||
if(d) {
|
if(d) {
|
||||||
query = d;
|
query = d;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pcs = [];
|
pcs = [];
|
||||||
if(s != null && s != undefined) for(i = 0; i < s.length; i++) {
|
if(s != null && s != undefined) for(i = 0; i < s.length; i++) {
|
||||||
q = $("[name=" + s[i] + "]").serialize();
|
q = jQuery("[name=" + s[i] + "]").serialize();
|
||||||
if(q) {
|
if(q) {
|
||||||
pcs.push(q);
|
pcs.push(q);
|
||||||
}
|
}
|
||||||
@@ -46,14 +46,14 @@
|
|||||||
query = pcs.join("&");
|
query = pcs.join("&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.ajax({
|
jQuery.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: u,
|
url: u,
|
||||||
data: query,
|
data: query,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
if(t) {
|
if(t) {
|
||||||
if(t == ':eval') eval(msg);
|
if(t == ':eval') eval(msg);
|
||||||
else if(typeof t == 'string') $("#" + t).html(msg);
|
else if(typeof t == 'string') jQuery("#" + t).html(msg);
|
||||||
else t(msg);
|
else t(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,14 +66,14 @@
|
|||||||
*/
|
*/
|
||||||
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
|
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";
|
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
|
||||||
$("input.date", target).each(function () {
|
jQuery("input.date", target).each(function () {
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField: this,
|
inputField: this,
|
||||||
ifFormat: date_format,
|
ifFormat: date_format,
|
||||||
showsTime: false
|
showsTime: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("input.datetime", target).each(function () {
|
jQuery("input.datetime", target).each(function () {
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField: this,
|
inputField: this,
|
||||||
ifFormat: datetime_format,
|
ifFormat: datetime_format,
|
||||||
@@ -81,24 +81,24 @@
|
|||||||
timeFormat: "24"
|
timeFormat: "24"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("input.time", target).each(function () {
|
jQuery("input.time", target).each(function () {
|
||||||
$(this).timeEntry();
|
jQuery(this).timeEntry();
|
||||||
});
|
});
|
||||||
/*adds btn class to buttons*/
|
/*adds btn class to buttons*/
|
||||||
$('button', target).addClass('btn');
|
jQuery('button', target).addClass('btn');
|
||||||
$('form input[type="submit"], form input[type="button"]', target).addClass('btn');
|
jQuery('form input[type="submit"], form input[type="button"]', target).addClass('btn');
|
||||||
/*no more inline javascript for PasswordWidget*/
|
/*no more inline javascript for PasswordWidget*/
|
||||||
$('input[type=password][data-w2p_entropy]', target).each(function () {
|
jQuery('input[type=password][data-w2p_entropy]', target).each(function () {
|
||||||
web2py.validate_entropy($(this));
|
web2py.validate_entropy(jQuery(this));
|
||||||
});
|
});
|
||||||
/*no more inline javascript for ListWidget*/
|
/*no more inline javascript for ListWidget*/
|
||||||
$('ul.w2p_list', target).each(function () {
|
jQuery('ul.w2p_list', target).each(function () {
|
||||||
function pe(ul, e) {
|
function pe(ul, e) {
|
||||||
var new_line = ml(ul);
|
var new_line = ml(ul);
|
||||||
rel(ul);
|
rel(ul);
|
||||||
if($(e.target).parent().is(':visible')) {
|
if(jQuery(e.target).parent().is(':visible')) {
|
||||||
//make sure we didn't delete the element before we insert after
|
//make sure we didn't delete the element before we insert after
|
||||||
new_line.insertAfter($(e.target).parent());
|
new_line.insertAfter(jQuery(e.target).parent());
|
||||||
} else {
|
} else {
|
||||||
//the line we clicked on was deleted, just add to end of list
|
//the line we clicked on was deleted, just add to end of list
|
||||||
new_line.appendTo(ul);
|
new_line.appendTo(ul);
|
||||||
@@ -108,27 +108,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rl(ul, e) {
|
function rl(ul, e) {
|
||||||
if($(ul).children().length > 1) {
|
if(jQuery(ul).children().length > 1) {
|
||||||
//only remove if we have more than 1 item so the list is never empty
|
//only remove if we have more than 1 item so the list is never empty
|
||||||
$(e.target).parent().remove();
|
jQuery(e.target).parent().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ml(ul) {
|
function ml(ul) {
|
||||||
var line = $(ul).find("li:first").clone(true);
|
var line = jQuery(ul).find("li:first").clone(true);
|
||||||
line.find(':text').val('');
|
line.find(':text').val('');
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rel(ul) {
|
function rel(ul) {
|
||||||
$(ul).find("li").each(function () {
|
jQuery(ul).find("li").each(function () {
|
||||||
var trimmed = $.trim($(this.firstChild).val());
|
var trimmed = jQuery.trim(jQuery(this.firstChild).val());
|
||||||
if(trimmed == '') $(this).remove();
|
if(trimmed == '') jQuery(this).remove();
|
||||||
else $(this.firstChild).val(trimmed);
|
else jQuery(this.firstChild).val(trimmed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var ul = this;
|
var ul = this;
|
||||||
$(ul).find(":text").after('<a href="#">+</a> <a href="#">-</a>').keypress(function (e) {
|
jQuery(ul).find(":text").after('<a href="#">+</a> <a href="#">-</a>').keypress(function (e) {
|
||||||
return(e.which == 13) ? pe(ul, e) : true;
|
return(e.which == 13) ? pe(ul, e) : true;
|
||||||
}).next().click(function (e) {
|
}).next().click(function (e) {
|
||||||
pe(ul, e);
|
pe(ul, e);
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
ajax_init: function (target) {
|
ajax_init: function (target) {
|
||||||
$('.hidden', target).hide();
|
jQuery('.hidden', target).hide();
|
||||||
web2py.manage_errors(target);
|
web2py.manage_errors(target);
|
||||||
web2py.ajax_fields(target);
|
web2py.ajax_fields(target);
|
||||||
web2py.show_if_handler(target);
|
web2py.show_if_handler(target);
|
||||||
@@ -148,16 +148,16 @@
|
|||||||
},
|
},
|
||||||
//manage errors in forms
|
//manage errors in forms
|
||||||
manage_errors: function(target) {
|
manage_errors: function(target) {
|
||||||
$('.error', target).hide().slideDown('slow');
|
jQuery('.error', target).hide().slideDown('slow');
|
||||||
//$('.error', target).hide().fadeIn('slow');
|
//jQuery('.error', target).hide().fadeIn('slow');
|
||||||
},
|
},
|
||||||
event_handlers: function () {
|
event_handlers: function () {
|
||||||
/* This is called once for page
|
/* This is called once for page
|
||||||
* Ideally it should bound all the things that are needed
|
* Ideally it should bound all the things that are needed
|
||||||
*/
|
*/
|
||||||
var doc = $(document);
|
var doc = jQuery(document);
|
||||||
doc.on('click', '.flash', function (e) {
|
doc.on('click', '.flash', function (e) {
|
||||||
var t = $(this);
|
var t = jQuery(this);
|
||||||
if(t.css('top') == '0px') t.slideUp('slow');
|
if(t.css('top') == '0px') t.slideUp('slow');
|
||||||
else t.fadeOut();
|
else t.fadeOut();
|
||||||
//if I want to display a clickable something
|
//if I want to display a clickable something
|
||||||
@@ -203,8 +203,8 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
trap_form: function (action, target) {
|
trap_form: function (action, target) {
|
||||||
$('#' + target + ' form').each(function (i) {
|
jQuery('#' + target + ' form').each(function (i) {
|
||||||
var form = $(this);
|
var form = jQuery(this);
|
||||||
form.attr('data-w2p_target', target);
|
form.attr('data-w2p_target', target);
|
||||||
if(!form.hasClass('no_trap')) {
|
if(!form.hasClass('no_trap')) {
|
||||||
//should be there by default ?
|
//should be there by default ?
|
||||||
@@ -218,8 +218,8 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
trap_link: function (target) {
|
trap_link: function (target) {
|
||||||
$('#' + target + ' a.w2p_trap').each(function (i) {
|
jQuery('#' + target + ' a.w2p_trap').each(function (i) {
|
||||||
var link = $(this);
|
var link = jQuery(this);
|
||||||
link.click(function (e) {
|
link.click(function (e) {
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
web2py.ajax_page('get', link.attr('href'), [], target);
|
web2py.ajax_page('get', link.attr('href'), [], target);
|
||||||
@@ -229,9 +229,9 @@
|
|||||||
},
|
},
|
||||||
ajax_page: function (method, action, data, target, element) {
|
ajax_page: function (method, action, data, target, element) {
|
||||||
//element is a new parameter, but should be put be put in front
|
//element is a new parameter, but should be put be put in front
|
||||||
if(element == undefined) element = $(document);
|
if(element == undefined) element = jQuery(document);
|
||||||
if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false
|
if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false
|
||||||
$.ajax({
|
jQuery.ajax({
|
||||||
'type': method,
|
'type': method,
|
||||||
'url': action,
|
'url': action,
|
||||||
'data': data,
|
'data': data,
|
||||||
@@ -256,10 +256,10 @@
|
|||||||
element.trigger('ajax:error', [xhr, status, error]);
|
element.trigger('ajax:error', [xhr, status, error]);
|
||||||
},
|
},
|
||||||
'complete': function (xhr, status) {
|
'complete': function (xhr, status) {
|
||||||
element.trigger('ajax:complete', [xhr, status]);
|
element.trigger('ajax:complete', [xhr, status]);
|
||||||
var html = xhr.responseText;
|
var html = xhr.responseText;
|
||||||
var content = xhr.getResponseHeader('web2py-component-content');
|
var content = xhr.getResponseHeader('web2py-component-content');
|
||||||
var t = $('#' + target);
|
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 == 'append') t.append(html);
|
||||||
else if(content != 'hide') t.html(html);
|
else if(content != 'hide') t.html(html);
|
||||||
@@ -272,8 +272,8 @@
|
|||||||
},
|
},
|
||||||
component: function (action, target, timeout, times, el) {
|
component: function (action, target, timeout, times, el) {
|
||||||
//element is a new parameter, but should be put in front
|
//element is a new parameter, but should be put in front
|
||||||
$(function () {
|
jQuery(function () {
|
||||||
var jelement = $("#" + target);
|
var jelement = jQuery("#" + target);
|
||||||
var element = jelement.get(0);
|
var element = jelement.get(0);
|
||||||
var statement = "jQuery('#" + target + "').get(0).reload();";
|
var statement = "jQuery('#" + target + "').get(0).reload();";
|
||||||
element.reload = function () {
|
element.reload = function () {
|
||||||
@@ -405,13 +405,13 @@
|
|||||||
enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled',
|
enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled',
|
||||||
// Triggers an event on an element and returns false if the event result is false
|
// Triggers an event on an element and returns false if the event result is false
|
||||||
fire: function (obj, name, data) {
|
fire: function (obj, name, data) {
|
||||||
var event = $.Event(name);
|
var event = jQuery.Event(name);
|
||||||
obj.trigger(event, data);
|
obj.trigger(event, data);
|
||||||
return event.result !== false;
|
return event.result !== false;
|
||||||
},
|
},
|
||||||
// Helper function, needed to provide consistent behavior in IE
|
// Helper function, needed to provide consistent behavior in IE
|
||||||
stopEverything: function (e) {
|
stopEverything: function (e) {
|
||||||
$(e.target).trigger('w2p:everythingStopped');
|
jQuery(e.target).trigger('w2p:everythingStopped');
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
el.addClass('disabled');
|
el.addClass('disabled');
|
||||||
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
||||||
// store enabled state
|
// store enabled state
|
||||||
el.data('w2p:enable-with', el[method]);
|
el.data('w2p:enable-with', el[method]());
|
||||||
/* little addition by default*/
|
/* little addition by default*/
|
||||||
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
||||||
el.data('w2p_disable_with', 'Working...');
|
el.data('w2p_disable_with', 'Working...');
|
||||||
@@ -454,46 +454,46 @@
|
|||||||
},
|
},
|
||||||
//helper for flash messages
|
//helper for flash messages
|
||||||
flash: function(message, status) {
|
flash: function(message, status) {
|
||||||
var flash = $('.flash');
|
var flash = jQuery('.flash');
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
flash.html(message).addClass(status);
|
flash.html(message).addClass(status);
|
||||||
if(flash.html()) flash.append('<span id="closeflash"> × </span>').slideDown();
|
if(flash.html()) flash.append('<span id="closeflash"> × </span>').slideDown();
|
||||||
},
|
},
|
||||||
hide_flash: function() {
|
hide_flash: function() {
|
||||||
$('.flash').hide().html('');
|
jQuery('.flash').hide().html('');
|
||||||
},
|
},
|
||||||
show_if_handler: function(target) {
|
show_if_handler: function(target) {
|
||||||
var triggers = {};
|
var triggers = {};
|
||||||
var show_if = function () {
|
var show_if = function () {
|
||||||
var t = $(this);
|
var t = jQuery(this);
|
||||||
var id = t.attr('id');
|
var id = t.attr('id');
|
||||||
t.attr('value', t.val());
|
t.attr('value', t.val());
|
||||||
for(var k = 0; k < triggers[id].length; k++) {
|
for(var k = 0; k < triggers[id].length; k++) {
|
||||||
var dep = $('#' + triggers[id][k], target);
|
var dep = jQuery('#' + triggers[id][k], target);
|
||||||
var tr = $('#' + triggers[id][k] + '__row', target);
|
var tr = jQuery('#' + triggers[id][k] + '__row', target);
|
||||||
if(t.is(dep.attr('data-show-if'))) tr.slideDown();
|
if(t.is(dep.attr('data-show-if'))) tr.slideDown();
|
||||||
else tr.hide();
|
else tr.hide();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$('[data-show-trigger]', target).each(function () {
|
jQuery('[data-show-trigger]', target).each(function () {
|
||||||
var name = $(this).attr('data-show-trigger');
|
var name = jQuery(this).attr('data-show-trigger');
|
||||||
if(!triggers[name]) triggers[name] = [];
|
if(!triggers[name]) triggers[name] = [];
|
||||||
triggers[name].push($(this).attr('id'));
|
triggers[name].push(jQuery(this).attr('id'));
|
||||||
});
|
});
|
||||||
for(var name in triggers) {
|
for(var name in triggers) {
|
||||||
$('#' + name, target).change(show_if).keyup(show_if);
|
jQuery('#' + name, target).change(show_if).keyup(show_if);
|
||||||
show_if.call($('#' + name, target));
|
show_if.call(jQuery('#' + name, target));
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
component_handler : function (target) {
|
component_handler : function (target) {
|
||||||
$('div[data-w2p_remote]', target).each(function () {
|
jQuery('div[data-w2p_remote]', target).each(function () {
|
||||||
var remote, times, timeout, target;
|
var remote, times, timeout, target;
|
||||||
var el = $(this);
|
var el = jQuery(this);
|
||||||
remote = el.data('w2p_remote');
|
remote = el.data('w2p_remote');
|
||||||
times = el.data('w2p_times');
|
times = el.data('w2p_times');
|
||||||
timeout = el.data('w2p_timeout');
|
timeout = el.data('w2p_timeout');
|
||||||
target = el.attr('id');
|
target = el.attr('id');
|
||||||
web2py.component(remote, target, timeout, times, $(this));
|
web2py.component(remote, target, timeout, times, jQuery(this));
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -539,36 +539,36 @@
|
|||||||
toremove = el.closest(toremove);
|
toremove = el.closest(toremove);
|
||||||
if(!toremove.length) {
|
if(!toremove.length) {
|
||||||
//this enables removal of whatever selector if a closest is not found
|
//this enables removal of whatever selector if a closest is not found
|
||||||
toremove = $(toremove);
|
toremove = jQuery(toremove);
|
||||||
}
|
}
|
||||||
toremove.remove();
|
toremove.remove();
|
||||||
}
|
}
|
||||||
/* removal code moved to the ajax:success event - END */
|
/* removal code moved to the ajax:success event - END */
|
||||||
},
|
},
|
||||||
a_handlers: function () {
|
a_handlers: function () {
|
||||||
var el = $(document);
|
var el = jQuery(document);
|
||||||
el.on('click', 'a[data-w2p_method]', function (e) {
|
el.on('click', 'a[data-w2p_method]', function (e) {
|
||||||
web2py.a_handler($(this), e);
|
web2py.a_handler(jQuery(this), e);
|
||||||
});
|
});
|
||||||
/* removal of element should happen only on success */
|
/* removal of element should happen only on success */
|
||||||
el.on('ajax:success', 'a[data-w2p_method][data-w2p_remove]', function (e) {
|
el.on('ajax:success', 'a[data-w2p_method][data-w2p_remove]', function (e) {
|
||||||
var el = $(this);
|
var el = jQuery(this);
|
||||||
var toremove = el.data('w2p_remove');
|
var toremove = el.data('w2p_remove');
|
||||||
if(toremove != undefined) {
|
if(toremove != undefined) {
|
||||||
toremove = el.closest(toremove);
|
toremove = el.closest(toremove);
|
||||||
if(!toremove.length) {
|
if(!toremove.length) {
|
||||||
//this enables removal of whatever selector if a closest is not found
|
//this enables removal of whatever selector if a closest is not found
|
||||||
toremove = $(toremove);
|
toremove = jQuery(toremove);
|
||||||
}
|
}
|
||||||
toremove.remove();
|
toremove.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
el.on('ajax:beforeSend', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
el.on('ajax:beforeSend', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
||||||
web2py.disableElement($(this));
|
web2py.disableElement(jQuery(this));
|
||||||
});
|
});
|
||||||
/*re-enable click on completion*/
|
/*re-enable click on completion*/
|
||||||
el.on('ajax:complete', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
el.on('ajax:complete', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
||||||
web2py.enableElement($(this));
|
web2py.enableElement(jQuery(this));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Disables form elements:
|
/* Disables form elements:
|
||||||
@@ -578,7 +578,7 @@
|
|||||||
*/
|
*/
|
||||||
disableFormElements: function(form) {
|
disableFormElements: function(form) {
|
||||||
form.find(web2py.disableSelector).each(function() {
|
form.find(web2py.disableSelector).each(function() {
|
||||||
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
var element = jQuery(this), method = element.is('button') ? 'html' : 'val';
|
||||||
var disable_with = element.data('w2p_disable_with');
|
var disable_with = element.data('w2p_disable_with');
|
||||||
if (disable_with == undefined) {
|
if (disable_with == undefined) {
|
||||||
element.data('w2p_disable_with', element[method]())
|
element.data('w2p_disable_with', element[method]())
|
||||||
@@ -595,26 +595,26 @@
|
|||||||
*/
|
*/
|
||||||
enableFormElements: function(form) {
|
enableFormElements: function(form) {
|
||||||
form.find(web2py.enableSelector).each(function() {
|
form.find(web2py.enableSelector).each(function() {
|
||||||
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
var element = jQuery(this), method = element.is('button') ? 'html' : 'val';
|
||||||
if (element.data('w2p:enable-with')) element[method](element.data('w2p:enable-with'));
|
if (element.data('w2p:enable-with')) element[method](element.data('w2p:enable-with'));
|
||||||
element.prop('disabled', false);
|
element.prop('disabled', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
form_handlers: function() {
|
form_handlers: function() {
|
||||||
var el = $(document);
|
var el = jQuery(document);
|
||||||
el.on('ajax:beforeSend', 'form[data-w2p_target]', function (e) {
|
el.on('ajax:beforeSend', 'form[data-w2p_target]', function (e) {
|
||||||
web2py.disableFormElements($(this));
|
web2py.disableFormElements(jQuery(this));
|
||||||
});
|
});
|
||||||
el.on('ajax:complete', 'form[data-w2p_target]', function (e) {
|
el.on('ajax:complete', 'form[data-w2p_target]', function (e) {
|
||||||
web2py.enableFormElements($(this));
|
web2py.enableFormElements(jQuery(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//end of functions
|
//end of functions
|
||||||
//main hook
|
//main hook
|
||||||
$(function () {
|
jQuery(function () {
|
||||||
var flash = $('.flash');
|
var flash = jQuery('.flash');
|
||||||
flash.hide();
|
flash.hide();
|
||||||
if(flash.html()) web2py.flash(flash.html());
|
if(flash.html()) web2py.flash(flash.html());
|
||||||
web2py.ajax_init(document);
|
web2py.ajax_init(document);
|
||||||
@@ -626,28 +626,28 @@
|
|||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
/* compatibility code - start */
|
/* compatibility code - start */
|
||||||
ajax = $.web2py.ajax;
|
ajax = jQuery.web2py.ajax;
|
||||||
web2py_component = $.web2py.component;
|
web2py_component = jQuery.web2py.component;
|
||||||
web2py_websocket = $.web2py.websocket;
|
web2py_websocket = jQuery.web2py.websocket;
|
||||||
web2py_ajax_page = $.web2py.ajax_page;
|
web2py_ajax_page = jQuery.web2py.ajax_page;
|
||||||
//needed for IS_STRONG(entropy)
|
//needed for IS_STRONG(entropy)
|
||||||
web2py_validate_entropy = $.web2py.validate_entropy;
|
web2py_validate_entropy = jQuery.web2py.validate_entropy;
|
||||||
//needed for crud.search and SQLFORM.grid's search
|
//needed for crud.search and SQLFORM.grid's search
|
||||||
web2py_ajax_fields = $.web2py.ajax_fields;
|
web2py_ajax_fields = jQuery.web2py.ajax_fields;
|
||||||
//used for LOAD(ajax=False)
|
//used for LOAD(ajax=False)
|
||||||
web2py_trap_form = $.web2py.trap_form;
|
web2py_trap_form = jQuery.web2py.trap_form;
|
||||||
|
|
||||||
/*undocumented - rare*/
|
/*undocumented - rare*/
|
||||||
popup = $.web2py.popup;
|
popup = jQuery.web2py.popup;
|
||||||
collapse = $.web2py.collapse;
|
collapse = jQuery.web2py.collapse;
|
||||||
fade = $.web2py.fade;
|
fade = jQuery.web2py.fade;
|
||||||
|
|
||||||
/* internals - shouldn't be needed
|
/* internals - shouldn't be needed
|
||||||
|
|
||||||
web2py_ajax_init = $.web2py.ajax_init;
|
web2py_ajax_init = jQuery.web2py.ajax_init;
|
||||||
web2py_event_handlers = $.web2py.event_handlers;
|
web2py_event_handlers = jQuery.web2py.event_handlers;
|
||||||
|
|
||||||
web2py_trap_link = $.web2py.trap_link;
|
web2py_trap_link = jQuery.web2py.trap_link;
|
||||||
web2py_calc_entropy = $.web2py.calc_entropy;
|
web2py_calc_entropy = jQuery.web2py.calc_entropy;
|
||||||
*/
|
*/
|
||||||
/* compatibility code - end*/
|
/* compatibility code - end*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
(function ($, undefined) {
|
(function (jQuery, undefined) {
|
||||||
/*
|
/*
|
||||||
* Unobtrusive scripting adapter for jQuery, largely taken from
|
* Unobtrusive scripting adapter for jQuery, largely taken from
|
||||||
* the wonderful https://github.com/rails/jquery-ujs
|
* the wonderful https://github.com/rails/jquery-ujs
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
};
|
};
|
||||||
var web2py;
|
var web2py;
|
||||||
|
|
||||||
$.web2py = web2py = {
|
jQuery.web2py = web2py = {
|
||||||
|
|
||||||
popup: function (url) {
|
popup: function (url) {
|
||||||
newwindow = window.open(url, 'name', 'height=400,width=600');
|
newwindow = window.open(url, 'name', 'height=400,width=600');
|
||||||
@@ -21,23 +21,23 @@
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
collapse: function (id) {
|
collapse: function (id) {
|
||||||
$('#' + id).slideToggle();
|
jQuery('#' + id).slideToggle();
|
||||||
},
|
},
|
||||||
fade: function (id, value) {
|
fade: function (id, value) {
|
||||||
if(value > 0) $('#' + id).hide().fadeIn('slow');
|
if(value > 0) jQuery('#' + id).hide().fadeIn('slow');
|
||||||
else $('#' + id).show().fadeOut('slow');
|
else jQuery('#' + id).show().fadeOut('slow');
|
||||||
},
|
},
|
||||||
ajax: function (u, s, t) {
|
ajax: function (u, s, t) {
|
||||||
query = '';
|
query = '';
|
||||||
if(typeof s == "string") {
|
if(typeof s == "string") {
|
||||||
d = $(s).serialize();
|
d = jQuery(s).serialize();
|
||||||
if(d) {
|
if(d) {
|
||||||
query = d;
|
query = d;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pcs = [];
|
pcs = [];
|
||||||
if(s != null && s != undefined) for(i = 0; i < s.length; i++) {
|
if(s != null && s != undefined) for(i = 0; i < s.length; i++) {
|
||||||
q = $("[name=" + s[i] + "]").serialize();
|
q = jQuery("[name=" + s[i] + "]").serialize();
|
||||||
if(q) {
|
if(q) {
|
||||||
pcs.push(q);
|
pcs.push(q);
|
||||||
}
|
}
|
||||||
@@ -46,14 +46,14 @@
|
|||||||
query = pcs.join("&");
|
query = pcs.join("&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.ajax({
|
jQuery.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: u,
|
url: u,
|
||||||
data: query,
|
data: query,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
if(t) {
|
if(t) {
|
||||||
if(t == ':eval') eval(msg);
|
if(t == ':eval') eval(msg);
|
||||||
else if(typeof t == 'string') $("#" + t).html(msg);
|
else if(typeof t == 'string') jQuery("#" + t).html(msg);
|
||||||
else t(msg);
|
else t(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,14 +66,14 @@
|
|||||||
*/
|
*/
|
||||||
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
|
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";
|
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
|
||||||
$("input.date", target).each(function () {
|
jQuery("input.date", target).each(function () {
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField: this,
|
inputField: this,
|
||||||
ifFormat: date_format,
|
ifFormat: date_format,
|
||||||
showsTime: false
|
showsTime: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("input.datetime", target).each(function () {
|
jQuery("input.datetime", target).each(function () {
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField: this,
|
inputField: this,
|
||||||
ifFormat: datetime_format,
|
ifFormat: datetime_format,
|
||||||
@@ -81,24 +81,24 @@
|
|||||||
timeFormat: "24"
|
timeFormat: "24"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("input.time", target).each(function () {
|
jQuery("input.time", target).each(function () {
|
||||||
$(this).timeEntry();
|
jQuery(this).timeEntry();
|
||||||
});
|
});
|
||||||
/*adds btn class to buttons*/
|
/*adds btn class to buttons*/
|
||||||
$('button', target).addClass('btn');
|
jQuery('button', target).addClass('btn');
|
||||||
$('form input[type="submit"], form input[type="button"]', target).addClass('btn');
|
jQuery('form input[type="submit"], form input[type="button"]', target).addClass('btn');
|
||||||
/*no more inline javascript for PasswordWidget*/
|
/*no more inline javascript for PasswordWidget*/
|
||||||
$('input[type=password][data-w2p_entropy]', target).each(function () {
|
jQuery('input[type=password][data-w2p_entropy]', target).each(function () {
|
||||||
web2py.validate_entropy($(this));
|
web2py.validate_entropy(jQuery(this));
|
||||||
});
|
});
|
||||||
/*no more inline javascript for ListWidget*/
|
/*no more inline javascript for ListWidget*/
|
||||||
$('ul.w2p_list', target).each(function () {
|
jQuery('ul.w2p_list', target).each(function () {
|
||||||
function pe(ul, e) {
|
function pe(ul, e) {
|
||||||
var new_line = ml(ul);
|
var new_line = ml(ul);
|
||||||
rel(ul);
|
rel(ul);
|
||||||
if($(e.target).parent().is(':visible')) {
|
if(jQuery(e.target).parent().is(':visible')) {
|
||||||
//make sure we didn't delete the element before we insert after
|
//make sure we didn't delete the element before we insert after
|
||||||
new_line.insertAfter($(e.target).parent());
|
new_line.insertAfter(jQuery(e.target).parent());
|
||||||
} else {
|
} else {
|
||||||
//the line we clicked on was deleted, just add to end of list
|
//the line we clicked on was deleted, just add to end of list
|
||||||
new_line.appendTo(ul);
|
new_line.appendTo(ul);
|
||||||
@@ -108,27 +108,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rl(ul, e) {
|
function rl(ul, e) {
|
||||||
if($(ul).children().length > 1) {
|
if(jQuery(ul).children().length > 1) {
|
||||||
//only remove if we have more than 1 item so the list is never empty
|
//only remove if we have more than 1 item so the list is never empty
|
||||||
$(e.target).parent().remove();
|
jQuery(e.target).parent().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ml(ul) {
|
function ml(ul) {
|
||||||
var line = $(ul).find("li:first").clone(true);
|
var line = jQuery(ul).find("li:first").clone(true);
|
||||||
line.find(':text').val('');
|
line.find(':text').val('');
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rel(ul) {
|
function rel(ul) {
|
||||||
$(ul).find("li").each(function () {
|
jQuery(ul).find("li").each(function () {
|
||||||
var trimmed = $.trim($(this.firstChild).val());
|
var trimmed = jQuery.trim(jQuery(this.firstChild).val());
|
||||||
if(trimmed == '') $(this).remove();
|
if(trimmed == '') jQuery(this).remove();
|
||||||
else $(this.firstChild).val(trimmed);
|
else jQuery(this.firstChild).val(trimmed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var ul = this;
|
var ul = this;
|
||||||
$(ul).find(":text").after('<a href="#">+</a> <a href="#">-</a>').keypress(function (e) {
|
jQuery(ul).find(":text").after('<a href="#">+</a> <a href="#">-</a>').keypress(function (e) {
|
||||||
return(e.which == 13) ? pe(ul, e) : true;
|
return(e.which == 13) ? pe(ul, e) : true;
|
||||||
}).next().click(function (e) {
|
}).next().click(function (e) {
|
||||||
pe(ul, e);
|
pe(ul, e);
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
ajax_init: function (target) {
|
ajax_init: function (target) {
|
||||||
$('.hidden', target).hide();
|
jQuery('.hidden', target).hide();
|
||||||
web2py.manage_errors(target);
|
web2py.manage_errors(target);
|
||||||
web2py.ajax_fields(target);
|
web2py.ajax_fields(target);
|
||||||
web2py.show_if_handler(target);
|
web2py.show_if_handler(target);
|
||||||
@@ -148,16 +148,16 @@
|
|||||||
},
|
},
|
||||||
//manage errors in forms
|
//manage errors in forms
|
||||||
manage_errors: function(target) {
|
manage_errors: function(target) {
|
||||||
$('.error', target).hide().slideDown('slow');
|
jQuery('.error', target).hide().slideDown('slow');
|
||||||
//$('.error', target).hide().fadeIn('slow');
|
//jQuery('.error', target).hide().fadeIn('slow');
|
||||||
},
|
},
|
||||||
event_handlers: function () {
|
event_handlers: function () {
|
||||||
/* This is called once for page
|
/* This is called once for page
|
||||||
* Ideally it should bound all the things that are needed
|
* Ideally it should bound all the things that are needed
|
||||||
*/
|
*/
|
||||||
var doc = $(document);
|
var doc = jQuery(document);
|
||||||
doc.on('click', '.flash', function (e) {
|
doc.on('click', '.flash', function (e) {
|
||||||
var t = $(this);
|
var t = jQuery(this);
|
||||||
if(t.css('top') == '0px') t.slideUp('slow');
|
if(t.css('top') == '0px') t.slideUp('slow');
|
||||||
else t.fadeOut();
|
else t.fadeOut();
|
||||||
//if I want to display a clickable something
|
//if I want to display a clickable something
|
||||||
@@ -203,8 +203,8 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
trap_form: function (action, target) {
|
trap_form: function (action, target) {
|
||||||
$('#' + target + ' form').each(function (i) {
|
jQuery('#' + target + ' form').each(function (i) {
|
||||||
var form = $(this);
|
var form = jQuery(this);
|
||||||
form.attr('data-w2p_target', target);
|
form.attr('data-w2p_target', target);
|
||||||
if(!form.hasClass('no_trap')) {
|
if(!form.hasClass('no_trap')) {
|
||||||
//should be there by default ?
|
//should be there by default ?
|
||||||
@@ -218,8 +218,8 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
trap_link: function (target) {
|
trap_link: function (target) {
|
||||||
$('#' + target + ' a.w2p_trap').each(function (i) {
|
jQuery('#' + target + ' a.w2p_trap').each(function (i) {
|
||||||
var link = $(this);
|
var link = jQuery(this);
|
||||||
link.click(function (e) {
|
link.click(function (e) {
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
web2py.ajax_page('get', link.attr('href'), [], target);
|
web2py.ajax_page('get', link.attr('href'), [], target);
|
||||||
@@ -229,9 +229,9 @@
|
|||||||
},
|
},
|
||||||
ajax_page: function (method, action, data, target, element) {
|
ajax_page: function (method, action, data, target, element) {
|
||||||
//element is a new parameter, but should be put be put in front
|
//element is a new parameter, but should be put be put in front
|
||||||
if(element == undefined) element = $(document);
|
if(element == undefined) element = jQuery(document);
|
||||||
if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false
|
if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false
|
||||||
$.ajax({
|
jQuery.ajax({
|
||||||
'type': method,
|
'type': method,
|
||||||
'url': action,
|
'url': action,
|
||||||
'data': data,
|
'data': data,
|
||||||
@@ -256,10 +256,10 @@
|
|||||||
element.trigger('ajax:error', [xhr, status, error]);
|
element.trigger('ajax:error', [xhr, status, error]);
|
||||||
},
|
},
|
||||||
'complete': function (xhr, status) {
|
'complete': function (xhr, status) {
|
||||||
element.trigger('ajax:complete', [xhr, status]);
|
element.trigger('ajax:complete', [xhr, status]);
|
||||||
var html = xhr.responseText;
|
var html = xhr.responseText;
|
||||||
var content = xhr.getResponseHeader('web2py-component-content');
|
var content = xhr.getResponseHeader('web2py-component-content');
|
||||||
var t = $('#' + target);
|
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 == 'append') t.append(html);
|
||||||
else if(content != 'hide') t.html(html);
|
else if(content != 'hide') t.html(html);
|
||||||
@@ -272,8 +272,8 @@
|
|||||||
},
|
},
|
||||||
component: function (action, target, timeout, times, el) {
|
component: function (action, target, timeout, times, el) {
|
||||||
//element is a new parameter, but should be put in front
|
//element is a new parameter, but should be put in front
|
||||||
$(function () {
|
jQuery(function () {
|
||||||
var jelement = $("#" + target);
|
var jelement = jQuery("#" + target);
|
||||||
var element = jelement.get(0);
|
var element = jelement.get(0);
|
||||||
var statement = "jQuery('#" + target + "').get(0).reload();";
|
var statement = "jQuery('#" + target + "').get(0).reload();";
|
||||||
element.reload = function () {
|
element.reload = function () {
|
||||||
@@ -405,13 +405,13 @@
|
|||||||
enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled',
|
enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled',
|
||||||
// Triggers an event on an element and returns false if the event result is false
|
// Triggers an event on an element and returns false if the event result is false
|
||||||
fire: function (obj, name, data) {
|
fire: function (obj, name, data) {
|
||||||
var event = $.Event(name);
|
var event = jQuery.Event(name);
|
||||||
obj.trigger(event, data);
|
obj.trigger(event, data);
|
||||||
return event.result !== false;
|
return event.result !== false;
|
||||||
},
|
},
|
||||||
// Helper function, needed to provide consistent behavior in IE
|
// Helper function, needed to provide consistent behavior in IE
|
||||||
stopEverything: function (e) {
|
stopEverything: function (e) {
|
||||||
$(e.target).trigger('w2p:everythingStopped');
|
jQuery(e.target).trigger('w2p:everythingStopped');
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
el.addClass('disabled');
|
el.addClass('disabled');
|
||||||
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
||||||
// store enabled state
|
// store enabled state
|
||||||
el.data('w2p:enable-with', el[method]);
|
el.data('w2p:enable-with', el[method]());
|
||||||
/* little addition by default*/
|
/* little addition by default*/
|
||||||
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
||||||
el.data('w2p_disable_with', 'Working...');
|
el.data('w2p_disable_with', 'Working...');
|
||||||
@@ -454,46 +454,46 @@
|
|||||||
},
|
},
|
||||||
//helper for flash messages
|
//helper for flash messages
|
||||||
flash: function(message, status) {
|
flash: function(message, status) {
|
||||||
var flash = $('.flash');
|
var flash = jQuery('.flash');
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
flash.html(message).addClass(status);
|
flash.html(message).addClass(status);
|
||||||
if(flash.html()) flash.append('<span id="closeflash"> × </span>').slideDown();
|
if(flash.html()) flash.append('<span id="closeflash"> × </span>').slideDown();
|
||||||
},
|
},
|
||||||
hide_flash: function() {
|
hide_flash: function() {
|
||||||
$('.flash').hide().html('');
|
jQuery('.flash').hide().html('');
|
||||||
},
|
},
|
||||||
show_if_handler: function(target) {
|
show_if_handler: function(target) {
|
||||||
var triggers = {};
|
var triggers = {};
|
||||||
var show_if = function () {
|
var show_if = function () {
|
||||||
var t = $(this);
|
var t = jQuery(this);
|
||||||
var id = t.attr('id');
|
var id = t.attr('id');
|
||||||
t.attr('value', t.val());
|
t.attr('value', t.val());
|
||||||
for(var k = 0; k < triggers[id].length; k++) {
|
for(var k = 0; k < triggers[id].length; k++) {
|
||||||
var dep = $('#' + triggers[id][k], target);
|
var dep = jQuery('#' + triggers[id][k], target);
|
||||||
var tr = $('#' + triggers[id][k] + '__row', target);
|
var tr = jQuery('#' + triggers[id][k] + '__row', target);
|
||||||
if(t.is(dep.attr('data-show-if'))) tr.slideDown();
|
if(t.is(dep.attr('data-show-if'))) tr.slideDown();
|
||||||
else tr.hide();
|
else tr.hide();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$('[data-show-trigger]', target).each(function () {
|
jQuery('[data-show-trigger]', target).each(function () {
|
||||||
var name = $(this).attr('data-show-trigger');
|
var name = jQuery(this).attr('data-show-trigger');
|
||||||
if(!triggers[name]) triggers[name] = [];
|
if(!triggers[name]) triggers[name] = [];
|
||||||
triggers[name].push($(this).attr('id'));
|
triggers[name].push(jQuery(this).attr('id'));
|
||||||
});
|
});
|
||||||
for(var name in triggers) {
|
for(var name in triggers) {
|
||||||
$('#' + name, target).change(show_if).keyup(show_if);
|
jQuery('#' + name, target).change(show_if).keyup(show_if);
|
||||||
show_if.call($('#' + name, target));
|
show_if.call(jQuery('#' + name, target));
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
component_handler : function (target) {
|
component_handler : function (target) {
|
||||||
$('div[data-w2p_remote]', target).each(function () {
|
jQuery('div[data-w2p_remote]', target).each(function () {
|
||||||
var remote, times, timeout, target;
|
var remote, times, timeout, target;
|
||||||
var el = $(this);
|
var el = jQuery(this);
|
||||||
remote = el.data('w2p_remote');
|
remote = el.data('w2p_remote');
|
||||||
times = el.data('w2p_times');
|
times = el.data('w2p_times');
|
||||||
timeout = el.data('w2p_timeout');
|
timeout = el.data('w2p_timeout');
|
||||||
target = el.attr('id');
|
target = el.attr('id');
|
||||||
web2py.component(remote, target, timeout, times, $(this));
|
web2py.component(remote, target, timeout, times, jQuery(this));
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -539,36 +539,36 @@
|
|||||||
toremove = el.closest(toremove);
|
toremove = el.closest(toremove);
|
||||||
if(!toremove.length) {
|
if(!toremove.length) {
|
||||||
//this enables removal of whatever selector if a closest is not found
|
//this enables removal of whatever selector if a closest is not found
|
||||||
toremove = $(toremove);
|
toremove = jQuery(toremove);
|
||||||
}
|
}
|
||||||
toremove.remove();
|
toremove.remove();
|
||||||
}
|
}
|
||||||
/* removal code moved to the ajax:success event - END */
|
/* removal code moved to the ajax:success event - END */
|
||||||
},
|
},
|
||||||
a_handlers: function () {
|
a_handlers: function () {
|
||||||
var el = $(document);
|
var el = jQuery(document);
|
||||||
el.on('click', 'a[data-w2p_method]', function (e) {
|
el.on('click', 'a[data-w2p_method]', function (e) {
|
||||||
web2py.a_handler($(this), e);
|
web2py.a_handler(jQuery(this), e);
|
||||||
});
|
});
|
||||||
/* removal of element should happen only on success */
|
/* removal of element should happen only on success */
|
||||||
el.on('ajax:success', 'a[data-w2p_method][data-w2p_remove]', function (e) {
|
el.on('ajax:success', 'a[data-w2p_method][data-w2p_remove]', function (e) {
|
||||||
var el = $(this);
|
var el = jQuery(this);
|
||||||
var toremove = el.data('w2p_remove');
|
var toremove = el.data('w2p_remove');
|
||||||
if(toremove != undefined) {
|
if(toremove != undefined) {
|
||||||
toremove = el.closest(toremove);
|
toremove = el.closest(toremove);
|
||||||
if(!toremove.length) {
|
if(!toremove.length) {
|
||||||
//this enables removal of whatever selector if a closest is not found
|
//this enables removal of whatever selector if a closest is not found
|
||||||
toremove = $(toremove);
|
toremove = jQuery(toremove);
|
||||||
}
|
}
|
||||||
toremove.remove();
|
toremove.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
el.on('ajax:beforeSend', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
el.on('ajax:beforeSend', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
||||||
web2py.disableElement($(this));
|
web2py.disableElement(jQuery(this));
|
||||||
});
|
});
|
||||||
/*re-enable click on completion*/
|
/*re-enable click on completion*/
|
||||||
el.on('ajax:complete', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
el.on('ajax:complete', 'a[data-w2p_method][data-w2p_disable_with]', function (e) {
|
||||||
web2py.enableElement($(this));
|
web2py.enableElement(jQuery(this));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Disables form elements:
|
/* Disables form elements:
|
||||||
@@ -578,7 +578,7 @@
|
|||||||
*/
|
*/
|
||||||
disableFormElements: function(form) {
|
disableFormElements: function(form) {
|
||||||
form.find(web2py.disableSelector).each(function() {
|
form.find(web2py.disableSelector).each(function() {
|
||||||
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
var element = jQuery(this), method = element.is('button') ? 'html' : 'val';
|
||||||
var disable_with = element.data('w2p_disable_with');
|
var disable_with = element.data('w2p_disable_with');
|
||||||
if (disable_with == undefined) {
|
if (disable_with == undefined) {
|
||||||
element.data('w2p_disable_with', element[method]())
|
element.data('w2p_disable_with', element[method]())
|
||||||
@@ -595,26 +595,26 @@
|
|||||||
*/
|
*/
|
||||||
enableFormElements: function(form) {
|
enableFormElements: function(form) {
|
||||||
form.find(web2py.enableSelector).each(function() {
|
form.find(web2py.enableSelector).each(function() {
|
||||||
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
var element = jQuery(this), method = element.is('button') ? 'html' : 'val';
|
||||||
if (element.data('w2p:enable-with')) element[method](element.data('w2p:enable-with'));
|
if (element.data('w2p:enable-with')) element[method](element.data('w2p:enable-with'));
|
||||||
element.prop('disabled', false);
|
element.prop('disabled', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
form_handlers: function() {
|
form_handlers: function() {
|
||||||
var el = $(document);
|
var el = jQuery(document);
|
||||||
el.on('ajax:beforeSend', 'form[data-w2p_target]', function (e) {
|
el.on('ajax:beforeSend', 'form[data-w2p_target]', function (e) {
|
||||||
web2py.disableFormElements($(this));
|
web2py.disableFormElements(jQuery(this));
|
||||||
});
|
});
|
||||||
el.on('ajax:complete', 'form[data-w2p_target]', function (e) {
|
el.on('ajax:complete', 'form[data-w2p_target]', function (e) {
|
||||||
web2py.enableFormElements($(this));
|
web2py.enableFormElements(jQuery(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//end of functions
|
//end of functions
|
||||||
//main hook
|
//main hook
|
||||||
$(function () {
|
jQuery(function () {
|
||||||
var flash = $('.flash');
|
var flash = jQuery('.flash');
|
||||||
flash.hide();
|
flash.hide();
|
||||||
if(flash.html()) web2py.flash(flash.html());
|
if(flash.html()) web2py.flash(flash.html());
|
||||||
web2py.ajax_init(document);
|
web2py.ajax_init(document);
|
||||||
@@ -626,28 +626,28 @@
|
|||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
/* compatibility code - start */
|
/* compatibility code - start */
|
||||||
ajax = $.web2py.ajax;
|
ajax = jQuery.web2py.ajax;
|
||||||
web2py_component = $.web2py.component;
|
web2py_component = jQuery.web2py.component;
|
||||||
web2py_websocket = $.web2py.websocket;
|
web2py_websocket = jQuery.web2py.websocket;
|
||||||
web2py_ajax_page = $.web2py.ajax_page;
|
web2py_ajax_page = jQuery.web2py.ajax_page;
|
||||||
//needed for IS_STRONG(entropy)
|
//needed for IS_STRONG(entropy)
|
||||||
web2py_validate_entropy = $.web2py.validate_entropy;
|
web2py_validate_entropy = jQuery.web2py.validate_entropy;
|
||||||
//needed for crud.search and SQLFORM.grid's search
|
//needed for crud.search and SQLFORM.grid's search
|
||||||
web2py_ajax_fields = $.web2py.ajax_fields;
|
web2py_ajax_fields = jQuery.web2py.ajax_fields;
|
||||||
//used for LOAD(ajax=False)
|
//used for LOAD(ajax=False)
|
||||||
web2py_trap_form = $.web2py.trap_form;
|
web2py_trap_form = jQuery.web2py.trap_form;
|
||||||
|
|
||||||
/*undocumented - rare*/
|
/*undocumented - rare*/
|
||||||
popup = $.web2py.popup;
|
popup = jQuery.web2py.popup;
|
||||||
collapse = $.web2py.collapse;
|
collapse = jQuery.web2py.collapse;
|
||||||
fade = $.web2py.fade;
|
fade = jQuery.web2py.fade;
|
||||||
|
|
||||||
/* internals - shouldn't be needed
|
/* internals - shouldn't be needed
|
||||||
|
|
||||||
web2py_ajax_init = $.web2py.ajax_init;
|
web2py_ajax_init = jQuery.web2py.ajax_init;
|
||||||
web2py_event_handlers = $.web2py.event_handlers;
|
web2py_event_handlers = jQuery.web2py.event_handlers;
|
||||||
|
|
||||||
web2py_trap_link = $.web2py.trap_link;
|
web2py_trap_link = jQuery.web2py.trap_link;
|
||||||
web2py_calc_entropy = $.web2py.calc_entropy;
|
web2py_calc_entropy = jQuery.web2py.calc_entropy;
|
||||||
*/
|
*/
|
||||||
/* compatibility code - end*/
|
/* compatibility code - end*/
|
||||||
|
|||||||
@@ -256,7 +256,7 @@
|
|||||||
element.trigger('ajax:error', [xhr, status, error]);
|
element.trigger('ajax:error', [xhr, status, error]);
|
||||||
},
|
},
|
||||||
'complete': function (xhr, status) {
|
'complete': function (xhr, status) {
|
||||||
// element.trigger('ajax:complete', [xhr, status]);
|
element.trigger('ajax:complete', [xhr, status]);
|
||||||
var html = xhr.responseText;
|
var html = xhr.responseText;
|
||||||
var content = xhr.getResponseHeader('web2py-component-content');
|
var content = xhr.getResponseHeader('web2py-component-content');
|
||||||
var t = jQuery('#' + target);
|
var t = jQuery('#' + target);
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
el.addClass('disabled');
|
el.addClass('disabled');
|
||||||
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
var method = el.prop('type') == 'submit' ? 'val' : 'html';
|
||||||
// store enabled state
|
// store enabled state
|
||||||
el.data('w2p:enable-with', el[method]);
|
el.data('w2p:enable-with', el[method]());
|
||||||
/* little addition by default*/
|
/* little addition by default*/
|
||||||
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
|
||||||
el.data('w2p_disable_with', 'Working...');
|
el.data('w2p_disable_with', 'Working...');
|
||||||
|
|||||||
Reference in New Issue
Block a user