PHP Classes

File: modules/system/assets/ui/js/loader.cursor.js

Recommend this page to a friend!
  Packages of Luke Towers   Winter   modules/system/assets/ui/js/loader.cursor.js   Download  
File: modules/system/assets/ui/js/loader.cursor.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Winter
Content management system that uses MVC
Author: By
Last change:
Date: 7 months ago
Size: 2,496 bytes
 

Contents

Class file image Download
/* * The loading indicator for the mouse cursor. * * Displays the animated loading indicator following the mouse cursor. * * JavaScript API: * $.wn.cursorLoadIndicator.show(event) * $.wn.cursorLoadIndicator.hide() * * By default if the show() method has been called several times, the hide() method should be * called the same number of times in order to hide the cursor. Use hide(true) to hide the * indicator forcibly. * * The event parameter in the show() method is optional. If it is passed, the initial cursor position * will be loaded from it. * * Require: * - modernizr/modernizr */ +function ($) { "use strict"; if ($.wn === undefined) $.wn = {} if ($.oc === undefined) $.oc = $.wn var CursorLoadIndicator = function () { if (Modernizr.touchevents) return this.counter = 0 this.indicator = $('<div/>').addClass('cursor-loading-indicator').addClass('hide') $(document.body).append(this.indicator) } CursorLoadIndicator.prototype.show = function(event) { if (Modernizr.touchevents) return this.counter++ if (this.counter > 1) return var self = this; if (event !== undefined && event.clientY !== undefined) { self.indicator.css({ left: event.clientX + 15, top: event.clientY + 15 }) } this.indicator.removeClass('hide') $(window).on('mousemove.cursorLoadIndicator', function(e){ self.indicator.css({ left: e.clientX + 15, top: e.clientY + 15, }) }) } CursorLoadIndicator.prototype.hide = function(force) { if (Modernizr.touchevents) return this.counter-- if (force !== undefined && force) this.counter = 0 if (this.counter <= 0) { this.indicator.addClass('hide') $(window).off('.cursorLoadIndicator'); } } $(document).ready(function() { $.wn.cursorLoadIndicator = new CursorLoadIndicator(); }) // CURSORLOADINDICATOR DATA-API // ============== $(document) .on('ajaxPromise', '[data-cursor-load-indicator]', function() { $.wn.cursorLoadIndicator.show() }).on('ajaxFail ajaxDone ajaxRedirected', '[data-cursor-load-indicator]', function() { $.wn.cursorLoadIndicator.hide() }) }(window.jQuery);