mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
@@ -146,7 +146,9 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
// If this is a navigation controller, e.g. pager.
|
// If this is a navigation controller, e.g. pager.
|
||||||
nav: $element.attr('data-nav-inc'),
|
nav: $element.attr('data-nav-inc'),
|
||||||
// Old way - href='myscript.php#id-to-target.
|
// Old way - href='myscript.php#id-to-target.
|
||||||
href: $element.attr("href")
|
href: $element.attr("href"),
|
||||||
|
// Wait for final event. Useful for keyUp, keyDown... etc.
|
||||||
|
wait: $element.attr('data-event-wait')
|
||||||
};
|
};
|
||||||
|
|
||||||
// If this is a navigation controller, e.g. pager.
|
// If this is a navigation controller, e.g. pager.
|
||||||
@@ -160,7 +162,16 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
ajaxOptions.type = 'GET';
|
ajaxOptions.type = 'GET';
|
||||||
}
|
}
|
||||||
|
|
||||||
e107.callbacks.ajaxRequestHandler($element, ajaxOptions);
|
if(ajaxOptions.wait != null)
|
||||||
|
{
|
||||||
|
e107.callbacks.waitForFinalEvent(function(){
|
||||||
|
e107.callbacks.ajaxRequestHandler($element, ajaxOptions);
|
||||||
|
}, parseInt(ajaxOptions.wait), event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e107.callbacks.ajaxRequestHandler($element, ajaxOptions);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -622,6 +633,39 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
e107.attachBehaviors();
|
e107.attachBehaviors();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for final event. Useful when you need to call an event callback
|
||||||
|
* only once, but event is fired multiple times. For example:
|
||||||
|
* - resizing window manually
|
||||||
|
* - wait for User to stop typing
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
* @code
|
||||||
|
* $(window).resize(function () {
|
||||||
|
* waitForFinalEvent(function(){
|
||||||
|
* alert('Resize...');
|
||||||
|
* //...
|
||||||
|
* }, 500, "some unique string");
|
||||||
|
* });
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
e107.callbacks.waitForFinalEvent = (function ()
|
||||||
|
{
|
||||||
|
var timers = {};
|
||||||
|
return function (callback, ms, uniqueId)
|
||||||
|
{
|
||||||
|
if(!uniqueId)
|
||||||
|
{
|
||||||
|
uniqueId = "Don't call this twice without a uniqueId";
|
||||||
|
}
|
||||||
|
if(timers[uniqueId])
|
||||||
|
{
|
||||||
|
clearTimeout(timers[uniqueId]);
|
||||||
|
}
|
||||||
|
timers[uniqueId] = setTimeout(callback, ms);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
|
Reference in New Issue
Block a user