mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-21 06:18:45 +02:00
@@ -20,6 +20,11 @@ function get_static_url(value) {
|
||||
return static_url + value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a modal box and load its content using an AJAX request.
|
||||
*
|
||||
* @param {Object} e - event object
|
||||
*/
|
||||
function modalbox(e, css, defhref, defcb, defclosecb) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
@@ -39,7 +44,8 @@ function modalbox(e, css, defhref, defcb, defclosecb) {
|
||||
url: href
|
||||
}).done(function(data) {
|
||||
var $div = $('<div />', {
|
||||
id: "modalbox", 'class': "modal fade", html: data
|
||||
id: "modalbox", 'class': "modal fade", role: "modal",
|
||||
html: data, 'aria-hidden': true
|
||||
});
|
||||
|
||||
$div.modal({show: false});
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* Creates an instance of InfiniteScroll.
|
||||
*
|
||||
* @constructor
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
* @param {object} element
|
||||
* @param {dictionary} options - instance options
|
||||
*/
|
||||
@@ -33,7 +33,7 @@
|
||||
/**
|
||||
* Scroll event handler.
|
||||
*
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
*/
|
||||
on_scroll: function() {
|
||||
var bottom = this.$options.calculate_bottom(this.$element);
|
||||
@@ -49,7 +49,7 @@
|
||||
* Load the previous page from the server.
|
||||
*
|
||||
* @private
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
*/
|
||||
load_previous_page: function() {
|
||||
var $this = this;
|
||||
@@ -74,7 +74,7 @@
|
||||
/**
|
||||
* Load the next page from the server.
|
||||
*
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
*/
|
||||
load_next_page: function() {
|
||||
var $this = this;
|
||||
@@ -95,7 +95,7 @@
|
||||
* Load a page's content.
|
||||
*
|
||||
* @private
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
* @param {string} direction - direction of the scroll (up or down)
|
||||
*/
|
||||
load_page: function(direction) {
|
||||
@@ -117,7 +117,6 @@
|
||||
}
|
||||
$this.executing = false;
|
||||
$this.loaded_pages.push($this.current_page);
|
||||
console.log("page", $this.current_page, "loaded successfuly");
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -125,18 +124,19 @@
|
||||
/**
|
||||
* Reset the loaded pages cache.
|
||||
*
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
* @param {Array} current_page - the new current_page
|
||||
*/
|
||||
reset_loaded_pages: function(current_page) {
|
||||
this.current_page = current_page;
|
||||
this.loaded_pages = [this.current_page];
|
||||
this.end_of_results = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Suspend the "infinite scroll" mode.
|
||||
*
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
*/
|
||||
pause: function() {
|
||||
this.$element.unbind("scroll");
|
||||
@@ -145,7 +145,7 @@
|
||||
/**
|
||||
* Resume the "infinite scroll" mode.
|
||||
*
|
||||
* @this {InfiniteScroll}
|
||||
* @this InfiniteScroll
|
||||
*/
|
||||
resume: function() {
|
||||
this.$element.scroll($.proxy(this.on_scroll, this));
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* Return an instance of SearchBar.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} element -
|
||||
* @param {Object} options - instance options
|
||||
*/
|
||||
var SearchBar = function(element, options) {
|
||||
this.initialize(element, options);
|
||||
};
|
||||
@@ -16,24 +24,30 @@
|
||||
});
|
||||
this.$element.blur(function(e) {
|
||||
var $this = $(this);
|
||||
if ($this.val() == "") {
|
||||
if ($this.val() === "") {
|
||||
$this.val(gettext("Search..."));
|
||||
}
|
||||
});
|
||||
if (this.options.navobj.params.pattern != undefined) {
|
||||
if (this.options.navobj.params.pattern !== undefined) {
|
||||
this.$element.val(this.options.navobj.getparam("pattern"));
|
||||
}
|
||||
if (this.options.navobj.params.criteria != undefined) {
|
||||
if (this.options.navobj.params.criteria !== undefined) {
|
||||
$("#crit_" + this.options.navobj.params.criteria).attr("checked", "checked");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Change event: apply search criterion.
|
||||
*
|
||||
* @this SearchBar
|
||||
* @param {Object} e - event object
|
||||
*/
|
||||
pattern_change: function(e) {
|
||||
var $input = $(e.target);
|
||||
var criteria = $("input[name=scriteria]:checked").val();
|
||||
var pattern = $input.val();
|
||||
|
||||
if (pattern != "") {
|
||||
if (pattern !== "") {
|
||||
this.options.navobj.setparams({
|
||||
pattern: pattern,
|
||||
criteria: criteria
|
||||
@@ -43,6 +57,9 @@
|
||||
this.options.navobj.delparam("criteria");
|
||||
this.options.navobj.delparam("page");
|
||||
}
|
||||
if (this.options.pattern_changed) {
|
||||
this.options.pattern_changed(this.options.navobj);
|
||||
}
|
||||
this.options.navobj.update();
|
||||
}
|
||||
};
|
||||
@@ -63,6 +80,7 @@
|
||||
};
|
||||
|
||||
$.fn.searchbar.defaults = {
|
||||
navobj: null
|
||||
navobj: null,
|
||||
pattern_changed: null
|
||||
};
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user