| node_js: | ||
| - '0.10' | ||
| before_script: | ||
| - 'gem update --system' | ||
| - 'gem install compass oily_png' | ||
| - 'npm install -g bower grunt-cli' | ||
| script: "npm test" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| /** | ||
| * progressio [uncompressed] | ||
| * @fileoverview Beautiful & stylish asynchronous page loader. Makes a static website dynamic in a breeze. | ||
| * | ||
| * @version 1.0.0 | ||
| * @date 2016-01-20 | ||
| * @author Valérian Saliou https://valeriansaliou.name/ | ||
| * @license MPL-2.0 | ||
| * | ||
| * @url https://github.com/valeriansaliou/progressio | ||
| * @repository git+https://github.com/valeriansaliou/progressio.git | ||
| */ | ||
| /* | ||
| Progressio | ||
| URL: https://github.com/valeriansaliou/progressio | ||
| Author: Valérian Saliou | ||
| Copyright: 2014, Valérian Saliou | ||
| */ | ||
| (function() { | ||
| var is_progressio_applied, is_progressio_constructed, | ||
| __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
| is_progressio_constructed = false; | ||
| is_progressio_applied = false; | ||
| window.Progressio = (function() { | ||
| var ProgressioMisc, ProgressioPage, ProgressioRegistry; | ||
| function Progressio(options) { | ||
| var error; | ||
| try { | ||
| if (typeof options !== 'object') { | ||
| options = {}; | ||
| } | ||
| this._options = { | ||
| color: options.color || 'blue', | ||
| fixed: options.fixed || false, | ||
| location: options.location || 'top', | ||
| container: options.container || '#body', | ||
| load_bar: options.load_bar || 'body', | ||
| auto_hide: options.auto_hide || false, | ||
| callbacks: options.callbacks || -1, | ||
| console: options.console || -1 | ||
| }; | ||
| this._deps = { | ||
| 'jquery': jQuery, | ||
| 'jquery.timers': jQuery.timers | ||
| }; | ||
| this._jQuery = this._deps.jquery; | ||
| if (typeof this._options.console !== 'object') { | ||
| this._options.console = { | ||
| log: function() {}, | ||
| info: function() {}, | ||
| debug: function() {}, | ||
| warn: function() {}, | ||
| error: function() {}, | ||
| trace: function() {}, | ||
| timeEnd: function() {}, | ||
| time: function() {}, | ||
| group: function() {}, | ||
| groupCollapsed: function() {}, | ||
| groupEnd: function() {}, | ||
| dir: function() {}, | ||
| count: function() {} | ||
| }; | ||
| } | ||
| if (is_progressio_constructed === true) { | ||
| throw new Error("Cannot instanciate Progressio more than once!"); | ||
| } | ||
| this.ProgressioPage = new ProgressioPage(this, this._options, this._deps); | ||
| this.ProgressioRegistry = new ProgressioRegistry(this, this._options, this._deps); | ||
| this.ProgressioMisc = new ProgressioMisc(this, this._options, this._deps); | ||
| this.ProgressioPage.register(); | ||
| this.ProgressioMisc.register(); | ||
| this.ProgressioRegistry.events(); | ||
| is_progressio_constructed = true; | ||
| } catch (_error) { | ||
| error = _error; | ||
| this._options.console.error('Progressio.constructor', error); | ||
| } | ||
| } | ||
| Progressio.prototype.apply = function() { | ||
| var dep_name, dep_wrapper, error, _i, _len, _ref; | ||
| try { | ||
| this._options.console.info('Progressio.apply', 'Applying Progressio...'); | ||
| if (is_progressio_applied === true) { | ||
| throw new Error("Cannot apply Progressio DOM more than once!"); | ||
| } | ||
| _ref = this._deps; | ||
| for (dep_wrapper = _i = 0, _len = _ref.length; _i < _len; dep_wrapper = ++_i) { | ||
| dep_name = _ref[dep_wrapper]; | ||
| if (typeof dep_wrapper === 'undefined') { | ||
| throw new Error("Could not find dependency: " + dep_name + "! Library load aborted."); | ||
| } | ||
| } | ||
| this.color(this._options.color); | ||
| is_progressio_applied = true; | ||
| return this._options.console.info('Progressio.apply', 'Applied.'); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.apply', error); | ||
| } | ||
| }; | ||
| Progressio.prototype.color = function(to_color) { | ||
| var color, color_class, container_class, container_sel, do_create, error, self; | ||
| try { | ||
| self = this; | ||
| this._options.console.info('Progressio.color', "Changing bar color to " + to_color + "..."); | ||
| this._options.color = to_color || 'blue'; | ||
| do_create = true; | ||
| container_sel = this._jQuery('.progressio-container'); | ||
| container_class = 'progressio-container'; | ||
| if (this._options.fixed === true) { | ||
| container_class = "" + container_class + " progressio-position-fixed"; | ||
| if (this._options.location === 'bottom') { | ||
| container_class = "" + container_class + " progressio-location-bottom"; | ||
| } | ||
| } | ||
| if (this._options.auto_hide === true) { | ||
| container_class = "" + container_class + " progressio-visibility-hide"; | ||
| } else { | ||
| container_class = "" + container_class + " progressio-visibility-show"; | ||
| } | ||
| color = this._options.color || 'blue'; | ||
| color_class = "progressio-color-" + color; | ||
| if (container_sel.size()) { | ||
| if (container_sel.filter("." + color_class).size()) { | ||
| do_create = false; | ||
| } else { | ||
| container_sel.remove(); | ||
| } | ||
| } | ||
| if (do_create === true) { | ||
| this._loader_bar_sel = this._jQuery("<div class=\"progressio-bar\"></div>"); | ||
| this._loader_bar_container_sel = this._jQuery("<div class=\"" + container_class + " " + color_class + "\"></div>"); | ||
| this._loader_bar_container_sel.append(this._loader_bar_sel); | ||
| this._jQuery(this._options.load_bar).prepend(this._loader_bar_container_sel); | ||
| if (this._options.auto_hide === true) { | ||
| this.ProgressioPage._begin_progress_bar(null, (function() { | ||
| return self.ProgressioPage._end_progress_bar(); | ||
| })); | ||
| } | ||
| return this._options.console.info('Progressio.color', "Changed bar color to " + to_color + "."); | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.color', error); | ||
| } | ||
| }; | ||
| Progressio.prototype.update = function() { | ||
| var error; | ||
| try { | ||
| return this.ProgressioPage.fire_dom_updated(); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.update', error); | ||
| } | ||
| }; | ||
| Progressio.prototype.get_id = function() { | ||
| var error; | ||
| try { | ||
| return this.ProgressioPage.get_id(); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.get_id', error); | ||
| } | ||
| }; | ||
| Progressio.prototype.open = function(url) { | ||
| var error; | ||
| try { | ||
| return this.ProgressioPage.open_page(url); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.open', error); | ||
| } | ||
| }; | ||
| Progressio.prototype.register_event = function(namespace, fn_callback, fn_context, ignore_init) { | ||
| var error; | ||
| try { | ||
| return this.ProgressioRegistry.register_event(namespace, fn_callback, fn_context, ignore_init); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.register_event', error); | ||
| } | ||
| }; | ||
| ProgressioPage = (function() { | ||
| function ProgressioPage(parent, options, deps) { | ||
| var error; | ||
| try { | ||
| this.__ = parent; | ||
| this._options = options; | ||
| this._jQuery = deps.jquery; | ||
| this._window_sel = this._jQuery(window); | ||
| this._document_sel = this._jQuery(document); | ||
| this._head = this._jQuery('head'); | ||
| this._id_async = 0; | ||
| this._is_async_compatible = window.history && history.pushState && true; | ||
| this._http_protocol = document.location.protocol.replace(':', ''); | ||
| this._http_host = document.location.host; | ||
| this._state_url = document.location.pathname; | ||
| } catch (_error) { | ||
| error = _error; | ||
| this._options.console.error('Progressio.ProgressioPage.constructor', error); | ||
| } | ||
| } | ||
| ProgressioPage.prototype.register = function() { | ||
| var error; | ||
| try { | ||
| this.__.ProgressioRegistry.register_event('progressio:page:events_state_change', this.events_state_change, this); | ||
| return this.__.ProgressioRegistry.register_event('progressio:page:async_load', this.events_async_load, this); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.register', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.purge_global_events = function() { | ||
| var error; | ||
| try { | ||
| this._window_sel.off(); | ||
| return this._document_sel.off(); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.purge_global_events', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.open_page = function(url) { | ||
| var error; | ||
| try { | ||
| if (this._is_async_compatible) { | ||
| return this._run_async_load(url); | ||
| } else { | ||
| return document.location.href = url; | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.open_page', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.events_async_load = function(parent) { | ||
| var eligible_links, eligible_links_count, error, self; | ||
| try { | ||
| self = this; | ||
| if (this._is_async_compatible) { | ||
| eligible_links = this._eligible_links_async_load().hasParent(parent); | ||
| eligible_links_count = eligible_links.size(); | ||
| eligible_links.click(function(evt) { | ||
| var return_value, _error; | ||
| return_value = false; | ||
| try { | ||
| if (self.__.ProgressioMisc.key_event().ctrlKey || self.__.ProgressioMisc.key_event().metaKey) { | ||
| return return_value = true; | ||
| } else { | ||
| return self._run_async_load(self._jQuery(this).attr('href')); | ||
| } | ||
| } catch (_error) { | ||
| _error = _error; | ||
| return self._options.console.error('Progressio.ProgressioPage.events_async_load[async]', _error); | ||
| } finally { | ||
| return return_value; | ||
| } | ||
| }); | ||
| eligible_links.attr('data-progressio-async', 'active'); | ||
| if (eligible_links_count) { | ||
| return this._options.console.debug('Progressio.ProgressioPage.events_async_load', "Yay! " + eligible_links_count + " internal links ajax-ified."); | ||
| } | ||
| } else { | ||
| return this._options.console.error('Progressio.ProgressioPage.events_async_load', 'Woops, your browser is not compatible with asynchronous page load!'); | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.events_async_load', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.events_state_change = function() { | ||
| var error, self, state_cb; | ||
| try { | ||
| self = this; | ||
| state_cb = function(ev) { | ||
| var new_state; | ||
| new_state = document.location.pathname; | ||
| if (new_state !== self._state_url) { | ||
| self._state_url = new_state; | ||
| return self._run_async_load(self._state_url); | ||
| } | ||
| }; | ||
| this._window_sel.off('popstate'); | ||
| this._window_sel.off('pushstate'); | ||
| this._window_sel.on('popstate', state_cb); | ||
| return this._window_sel.on('pushstate', state_cb); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.events_state_change', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.fire_dom_updated = function() { | ||
| var error; | ||
| try { | ||
| return this.events_async_load('body'); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.fire_dom_updated', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype.get_id = function() { | ||
| var error; | ||
| try { | ||
| return this._id_async; | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage.get_id', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._eligible_links_async_load = function() { | ||
| var error, http_base, r_match, self; | ||
| try { | ||
| self = this; | ||
| http_base = "" + this._http_protocol + "://" + this._http_host + "/"; | ||
| r_match = new RegExp("^(" + http_base + "|(\.?/(?!https?://).*))", 'gi'); | ||
| return this._document_sel.find('a[href]:not([target="_blank"], ' + '[data-progressio-async="disabled"], ' + '[data-progressio-async="active"])').filter(function() { | ||
| return self._jQuery(this).attr('href').match(r_match); | ||
| }); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._eligible_links_async_load', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._run_async_load = function(url) { | ||
| var error, id, req_cb, self; | ||
| try { | ||
| self = this; | ||
| this._begin_progress_bar(); | ||
| this._hide_error_alert(); | ||
| id = ++this._id_async; | ||
| req_cb = function(data) { | ||
| return self._handle_async_load(id, url, data); | ||
| }; | ||
| this._jQuery.ajax({ | ||
| url: url, | ||
| headers: { | ||
| 'X-Requested-With': 'Progressio' | ||
| }, | ||
| type: 'GET', | ||
| success: req_cb, | ||
| error: req_cb | ||
| }); | ||
| return this._options.console.debug('Progressio.ProgressioPage._run_async_load', "Loading page: " + url); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._run_async_load', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._handle_async_load = function(id, url, data) { | ||
| var callback_counter, cb_cleanup_fn, cb_complete_fn, cb_post_display_fn, container_split, data_sel, error, load_list, new_dom, old_namespaced_script_sel, old_namespaced_stylesheet_sel, self, title; | ||
| try { | ||
| self = this; | ||
| if (typeof data === 'object' && data.hasOwnProperty('responseText')) { | ||
| data = data.responseText; | ||
| } | ||
| if (id === this._id_async) { | ||
| data_sel = this._jQuery(data); | ||
| new_dom = data_sel.filter("" + this._options.container + ":first"); | ||
| if (new_dom.size()) { | ||
| title = data_sel.filter('title:first'); | ||
| callback_counter = 0; | ||
| old_namespaced_script_sel = this._document_sel.find('script:not([data-progressio-scope="common"])'); | ||
| old_namespaced_stylesheet_sel = this._document_sel.find('link[rel="stylesheet"]:not([data-progressio-scope="common"])'); | ||
| cb_cleanup_fn = function() { | ||
| old_namespaced_script_sel.remove(); | ||
| old_namespaced_stylesheet_sel.remove(); | ||
| return self._options.console.debug('Progressio.ProgressioPage._handle_async_load', "Done cleanup of old DOM before page: " + url); | ||
| }; | ||
| cb_post_display_fn = function() { | ||
| var cb_after; | ||
| self._end_progress_bar(); | ||
| if (typeof self._options.callbacks === 'object' && typeof self._options.callbacks.post_display === 'object' && typeof self._options.callbacks.post_display.before === 'function' && self._options.callbacks.post_display.before() === true) { | ||
| self._scroll_top(); | ||
| cb_after = self._options.callbacks.post_display.after; | ||
| if (cb_after === 'function') { | ||
| self._options.callbacks.post_display.after(); | ||
| } | ||
| } | ||
| return self._options.console.debug('Progressio.ProgressioPage._handle_async_load', "Done post display actions for page: " + url); | ||
| }; | ||
| cb_complete_fn = function() { | ||
| return self._document_sel.oneTime(250, function() { | ||
| var cb_after, new_container, new_container_sel; | ||
| if (typeof self._options.callbacks === 'object' && typeof self._options.callbacks.on_complete === 'object' && typeof self._options.callbacks.on_complete.before === 'function' && self._options.callbacks.on_complete.before() === true) { | ||
| cb_after = self._options.callbacks.on_complete.after; | ||
| if (cb_after === 'function') { | ||
| self._options.callbacks.on_complete.after(); | ||
| } | ||
| } | ||
| cb_cleanup_fn(); | ||
| self._document_sel.find('title').replaceWith(title); | ||
| self._document_sel.find("" + self._options.container).remove(); | ||
| new_container_sel = self._document_sel.find("" + self._options.container + "_new"); | ||
| new_container = self.__.ProgressioMisc.split_selector_path(self._options.container); | ||
| new_container_sel.attr(new_container.attr, new_container.value).show(); | ||
| self.__.ProgressioRegistry.restore_events("" + self._options.container); | ||
| if (url !== self._state_url) { | ||
| self._state_url = url; | ||
| history.pushState(null, title, url); | ||
| } | ||
| cb_post_display_fn(); | ||
| return self._options.console.debug('Progressio.ProgressioPage._handle_async_load', "Loaded page: " + url); | ||
| }); | ||
| }; | ||
| this.purge_global_events(); | ||
| this.__.ProgressioRegistry.unload_bundles(); | ||
| this._document_sel.find("" + this._options.container + "_new").remove(); | ||
| container_split = this.__.ProgressioMisc.split_selector_path(this._options.container); | ||
| new_dom.attr(container_split.attr, "" + container_split.value + "_new"); | ||
| new_dom.hide(); | ||
| new_dom.insertBefore(this._document_sel.find("" + this._options.container)); | ||
| this._head.append(data_sel.filter('script:not([src])' + ':not([data-progressio-scope="common"])')); | ||
| this._head.append(data_sel.filter('link[rel="stylesheet"]:not([href])' + ':not([data-progressio-scope="common"])')); | ||
| load_list = { | ||
| js: [], | ||
| css: [] | ||
| }; | ||
| data_sel.filter('script[src]:not([data-progressio-scope="common"])').each(function() { | ||
| var script_src; | ||
| script_src = self._jQuery(this).attr('src'); | ||
| if (script_src) { | ||
| return load_list.js.push(script_src); | ||
| } | ||
| }); | ||
| data_sel.filter('link[href][rel="stylesheet"]' + ':not([data-progressio-scope="common"])').each(function() { | ||
| var stylesheet_href; | ||
| stylesheet_href = self._jQuery(this).attr('href'); | ||
| if (stylesheet_href) { | ||
| return load_list.css.push(stylesheet_href); | ||
| } | ||
| }); | ||
| if (load_list.js.length || load_list.css.length) { | ||
| if (load_list.js.length) { | ||
| callback_counter++; | ||
| this._options.console.info('Progressio.ProgressioPage._handle_async_load', 'Loading scripts...'); | ||
| LazyLoad.js(load_list.js, function() { | ||
| self._options.console.info('Progressio.ProgressioPage._handle_async_load[async]', 'Scripts fully loaded'); | ||
| if (--callback_counter === 0) { | ||
| return cb_complete_fn(); | ||
| } | ||
| }); | ||
| } | ||
| if (load_list.css.length) { | ||
| callback_counter++; | ||
| this._options.console.info('Progressio.ProgressioPage._handle_async_load', 'Loading stylesheets...'); | ||
| LazyLoad.css(load_list.css, function() { | ||
| self._options.console.info('Progressio.ProgressioPage._handle_async_load[async]', 'Stylesheets fully loaded'); | ||
| if (--callback_counter === 0) { | ||
| return cb_complete_fn(); | ||
| } | ||
| }); | ||
| } | ||
| return this._options.console.debug('Progressio.ProgressioPage._handle_async_load', "Delayed page load (waiting for sources to be loaded): " + url); | ||
| } else { | ||
| return cb_complete_fn(); | ||
| } | ||
| } else { | ||
| this._show_error_alert(10); | ||
| this._end_progress_bar(); | ||
| return this._options.console.error('Progressio.ProgressioPage._handle_async_load', "Got an abnormal or error response from: " + url); | ||
| } | ||
| } else { | ||
| return this._options.console.warn('Progressio.ProgressioPage._handle_async_load', "Dropped outpaced ID for page: " + url); | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._handle_async_load', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._begin_progress_bar = function(cb_start_fn, cb_finish_fn) { | ||
| var error; | ||
| try { | ||
| this.__._loader_bar_sel.stop(true); | ||
| this.__._loader_bar_sel.css({ | ||
| width: 0 | ||
| }); | ||
| if (this._options.auto_hide === true) { | ||
| this.__._loader_bar_container_sel.stop(true); | ||
| this.__._loader_bar_container_sel.fadeIn(250); | ||
| } | ||
| if (typeof cb_start_fn === 'function') { | ||
| cb_start_fn(); | ||
| } | ||
| this.__._loader_bar_sel.addClass('animated'); | ||
| return this.__._loader_bar_sel.animate({ | ||
| width: '50%' | ||
| }, 600, 'easeOutQuad', (function() { | ||
| if (typeof cb_finish_fn === 'function') { | ||
| return cb_finish_fn(); | ||
| } | ||
| })); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._begin_progress_bar', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._end_progress_bar = function(cb_start_fn, cb_finish_fn) { | ||
| var error, self; | ||
| try { | ||
| self = this; | ||
| if (typeof cb_start_fn === 'function') { | ||
| cb_start_fn(); | ||
| } | ||
| return this.__._loader_bar_sel.animate({ | ||
| width: '100%' | ||
| }, 300, 'linear', (function() { | ||
| self.__._loader_bar_sel.removeClass('animated'); | ||
| if (self._options.auto_hide === true) { | ||
| self.__._loader_bar_container_sel.stop(true); | ||
| self.__._loader_bar_container_sel.fadeOut(400); | ||
| } | ||
| if (typeof cb_finish_fn === 'function') { | ||
| return cb_finish_fn(); | ||
| } | ||
| })); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._end_progress_bar', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._get_error_alert = function() { | ||
| var error; | ||
| try { | ||
| return this._document_sel.find('.alerts .async-load-error'); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._get_error_alert', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._show_error_alert = function(seconds) { | ||
| var error, error_alert_sel; | ||
| if (seconds == null) { | ||
| seconds = 10; | ||
| } | ||
| try { | ||
| error_alert_sel = this._get_error_alert(); | ||
| error_alert_sel.stop(true).hide(); | ||
| return error_alert_sel.animate({ | ||
| height: 'toggle', | ||
| opacity: 'toggle' | ||
| }, 400, function() { | ||
| return this._jQuery(this).oneTime("" + seconds + "s", function() { | ||
| return this._jQuery(this).animate({ | ||
| height: 'toggle', | ||
| opacity: 'toggle' | ||
| }, 400); | ||
| }); | ||
| }); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._show_error_alert', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._hide_error_alert = function() { | ||
| var error, error_alert_visible_sel; | ||
| try { | ||
| error_alert_visible_sel = this._get_error_alert().filter(':visible'); | ||
| if (error_alert_visible_sel.size()) { | ||
| error_alert_visible_sel.stopTime(); | ||
| return error_alert_visible_sel.stop(true).animate({ | ||
| height: 'toggle', | ||
| opacity: 'toggle' | ||
| }, 250); | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._hide_error_alert', error); | ||
| } | ||
| }; | ||
| ProgressioPage.prototype._scroll_top = function() { | ||
| var error; | ||
| try { | ||
| return this._window_sel.scrollTop(0); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioPage._scroll_top', error); | ||
| } | ||
| }; | ||
| return ProgressioPage; | ||
| })(); | ||
| ProgressioRegistry = (function() { | ||
| function ProgressioRegistry(parent, options, deps) { | ||
| var error; | ||
| try { | ||
| this.__ = parent; | ||
| this._options = options; | ||
| this._jQuery = deps.jquery; | ||
| this._registry_events = {}; | ||
| this._registry_bundles = []; | ||
| } catch (_error) { | ||
| error = _error; | ||
| this._options.console.error('Progressio.ProgressioRegistry.constructor', error); | ||
| } | ||
| } | ||
| ProgressioRegistry.prototype.events = function() { | ||
| var error; | ||
| try { | ||
| return this._bind_events('body'); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.events', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype._bind_events = function(parent) { | ||
| var cur_registry, error, is_init, ns, _error, _ref, _results; | ||
| try { | ||
| parent = parent || 'body'; | ||
| is_init = parent === 'body'; | ||
| cur_registry = null; | ||
| _ref = this._registry_events; | ||
| _results = []; | ||
| for (ns in _ref) { | ||
| cur_registry = _ref[ns]; | ||
| try { | ||
| if (!(is_init && cur_registry[2])) { | ||
| (cur_registry[0].bind(cur_registry[1]))(parent); | ||
| } | ||
| _results.push(this._options.console.debug('Progressio.ProgressioRegistry._bind_events[loop]', "Bound callback function for " + ns)); | ||
| } catch (_error) { | ||
| _error = _error; | ||
| _results.push(this._options.console.error('Progressio.ProgressioRegistry._bind_events[loop]', "Registry callback function execution failed for " + ("" + ns + " with error message: " + _error))); | ||
| } | ||
| } | ||
| return _results; | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry._bind_events', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.register_event = function(namespace, fn_callback, fn_context, ignore_init) { | ||
| var error; | ||
| try { | ||
| ignore_init = false || ignore_init; | ||
| this._registry_events[namespace] = [fn_callback, fn_context, ignore_init]; | ||
| return this._options.console.info('Progressio.ProgressioRegistry.register_event', "Registered event: " + namespace); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.register_event', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.unregister_event = function(namespace) { | ||
| var error; | ||
| try { | ||
| if (__indexOf.call(this._registry_events, namespace) >= 0) { | ||
| delete this._registry_events[namespace]; | ||
| this._options.console.info('Progressio.ProgressioRegistry.unregister_event', "Unregistered event: " + namespace); | ||
| return true; | ||
| } | ||
| return false; | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.unregister_event', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.init_events = function() { | ||
| var error; | ||
| try { | ||
| return this._bind_events('body'); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.init_events', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.restore_events = function(parent) { | ||
| var error; | ||
| try { | ||
| return this._bind_events(parent); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.restore_events', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.register_bundle = function(bundle) { | ||
| var error; | ||
| try { | ||
| return this._registry_bundles.push(bundle); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.register_bundle', error); | ||
| } | ||
| }; | ||
| ProgressioRegistry.prototype.unload_bundles = function() { | ||
| var count_unload, cur_bundle, error, _i, _len, _ref; | ||
| try { | ||
| count_unload = 0; | ||
| _ref = this._registry_bundles; | ||
| for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
| cur_bundle = _ref[_i]; | ||
| if (this.hasOwnProperty(cur_bundle)) { | ||
| delete _[cur_bundle]; | ||
| count_unload++; | ||
| } | ||
| } | ||
| return this._options.console.info('Progressio.ProgressioRegistry.unload_bundles', "Unloaded " + count_unload + " bundles"); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioRegistry.unload_bundles', error); | ||
| } | ||
| }; | ||
| return ProgressioRegistry; | ||
| })(); | ||
| ProgressioMisc = (function() { | ||
| function ProgressioMisc(parent, options, deps) { | ||
| var error; | ||
| try { | ||
| this.__ = parent; | ||
| this._options = options; | ||
| this._jQuery = deps.jquery; | ||
| this._window_sel = this._jQuery(window); | ||
| this._key_event = {}; | ||
| } catch (_error) { | ||
| error = _error; | ||
| this._options.console.error('Progressio.ProgressioMisc.constructor', error); | ||
| } | ||
| } | ||
| ProgressioMisc.prototype.register = function() { | ||
| var error; | ||
| try { | ||
| return this.__.ProgressioRegistry.register_event('progressio:misc:events_key', this.events_key, this); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioMisc.register', error); | ||
| } | ||
| }; | ||
| ProgressioMisc.prototype.events_key = function() { | ||
| var error, self; | ||
| try { | ||
| self = this; | ||
| this._window_sel.keydown(function(evt) { | ||
| return self._key_event = evt; | ||
| }); | ||
| return this._window_sel.keyup(function() { | ||
| return self._key_event = {}; | ||
| }); | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioMisc.events_key', error); | ||
| } | ||
| }; | ||
| ProgressioMisc.prototype.key_event = function() { | ||
| var error; | ||
| try { | ||
| return this._key_event; | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioMisc.key_event', error); | ||
| } | ||
| }; | ||
| ProgressioMisc.prototype.split_selector_path = function(selector_path) { | ||
| var error, selector_path_arr, selector_path_type; | ||
| selector_path_arr = { | ||
| attr: 'data-selector', | ||
| value: null | ||
| }; | ||
| try { | ||
| selector_path_type = selector_path.substr(0, 1); | ||
| selector_path_arr.value = selector_path.substr(1, selector_path.length); | ||
| switch (selector_path_type) { | ||
| case '#': | ||
| selector_path_arr.attr = 'id'; | ||
| break; | ||
| case '.': | ||
| selector_path_arr.attr = 'class'; | ||
| break; | ||
| } | ||
| } catch (_error) { | ||
| error = _error; | ||
| return this._options.console.error('Progressio.ProgressioMisc.split_selector_path', error); | ||
| } finally { | ||
| return selector_path_arr; | ||
| } | ||
| }; | ||
| return ProgressioMisc; | ||
| })(); | ||
| return Progressio; | ||
| })(); | ||
| }).call(this); |
| (function(){var a,b,c=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b=!1,a=!1,window.Progressio=function(){function d(a){var c;try{if("object"!=typeof a&&(a={}),this._options={color:a.color||"blue",fixed:a.fixed||!1,location:a.location||"top",container:a.container||"#body",load_bar:a.load_bar||"body",auto_hide:a.auto_hide||!1,callbacks:a.callbacks||-1,console:a.console||-1},this._deps={jquery:jQuery,"jquery.timers":jQuery.timers},this._jQuery=this._deps.jquery,"object"!=typeof this._options.console&&(this._options.console={log:function(){},info:function(){},debug:function(){},warn:function(){},error:function(){},trace:function(){},timeEnd:function(){},time:function(){},group:function(){},groupCollapsed:function(){},groupEnd:function(){},dir:function(){},count:function(){}}),b===!0)throw new Error("Cannot instanciate Progressio more than once!");this.ProgressioPage=new f(this,this._options,this._deps),this.ProgressioRegistry=new g(this,this._options,this._deps),this.ProgressioMisc=new e(this,this._options,this._deps),this.ProgressioPage.register(),this.ProgressioMisc.register(),this.ProgressioRegistry.events(),b=!0}catch(d){c=d,this._options.console.error("Progressio.constructor",c)}}var e,f,g;return d.prototype.apply=function(){var b,c,d,e,f,g;try{if(this._options.console.info("Progressio.apply","Applying Progressio..."),a===!0)throw new Error("Cannot apply Progressio DOM more than once!");for(g=this._deps,c=e=0,f=g.length;f>e;c=++e)if(b=g[c],"undefined"==typeof c)throw new Error("Could not find dependency: "+b+"! Library load aborted.");return this.color(this._options.color),a=!0,this._options.console.info("Progressio.apply","Applied.")}catch(h){return d=h,this._options.console.error("Progressio.apply",d)}},d.prototype.color=function(a){var b,c,d,e,f,g,h;try{if(h=this,this._options.console.info("Progressio.color","Changing bar color to "+a+"..."),this._options.color=a||"blue",f=!0,e=this._jQuery(".progressio-container"),d="progressio-container",this._options.fixed===!0&&(d=""+d+" progressio-position-fixed","bottom"===this._options.location&&(d=""+d+" progressio-location-bottom")),d=this._options.auto_hide===!0?""+d+" progressio-visibility-hide":""+d+" progressio-visibility-show",b=this._options.color||"blue",c="progressio-color-"+b,e.size()&&(e.filter("."+c).size()?f=!1:e.remove()),f===!0)return this._loader_bar_sel=this._jQuery('<div class="progressio-bar"></div>'),this._loader_bar_container_sel=this._jQuery('<div class="'+d+" "+c+'"></div>'),this._loader_bar_container_sel.append(this._loader_bar_sel),this._jQuery(this._options.load_bar).prepend(this._loader_bar_container_sel),this._options.auto_hide===!0&&this.ProgressioPage._begin_progress_bar(null,function(){return h.ProgressioPage._end_progress_bar()}),this._options.console.info("Progressio.color","Changed bar color to "+a+".")}catch(i){return g=i,this._options.console.error("Progressio.color",g)}},d.prototype.update=function(){var a;try{return this.ProgressioPage.fire_dom_updated()}catch(b){return a=b,this._options.console.error("Progressio.update",a)}},d.prototype.get_id=function(){var a;try{return this.ProgressioPage.get_id()}catch(b){return a=b,this._options.console.error("Progressio.get_id",a)}},d.prototype.open=function(a){var b;try{return this.ProgressioPage.open_page(a)}catch(c){return b=c,this._options.console.error("Progressio.open",b)}},d.prototype.register_event=function(a,b,c,d){var e;try{return this.ProgressioRegistry.register_event(a,b,c,d)}catch(f){return e=f,this._options.console.error("Progressio.register_event",e)}},f=function(){function a(a,b,c){var d;try{this.__=a,this._options=b,this._jQuery=c.jquery,this._window_sel=this._jQuery(window),this._document_sel=this._jQuery(document),this._head=this._jQuery("head"),this._id_async=0,this._is_async_compatible=window.history&&history.pushState&&!0,this._http_protocol=document.location.protocol.replace(":",""),this._http_host=document.location.host,this._state_url=document.location.pathname}catch(e){d=e,this._options.console.error("Progressio.ProgressioPage.constructor",d)}}return a.prototype.register=function(){var a;try{return this.__.ProgressioRegistry.register_event("progressio:page:events_state_change",this.events_state_change,this),this.__.ProgressioRegistry.register_event("progressio:page:async_load",this.events_async_load,this)}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage.register",a)}},a.prototype.purge_global_events=function(){var a;try{return this._window_sel.off(),this._document_sel.off()}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage.purge_global_events",a)}},a.prototype.open_page=function(a){var b;try{return this._is_async_compatible?this._run_async_load(a):document.location.href=a}catch(c){return b=c,this._options.console.error("Progressio.ProgressioPage.open_page",b)}},a.prototype.events_async_load=function(a){var b,c,d,e;try{if(e=this,!this._is_async_compatible)return this._options.console.error("Progressio.ProgressioPage.events_async_load","Woops, your browser is not compatible with asynchronous page load!");if(b=this._eligible_links_async_load().hasParent(a),c=b.size(),b.click(function(a){var b,c;b=!1;try{return e.__.ProgressioMisc.key_event().ctrlKey||e.__.ProgressioMisc.key_event().metaKey?b=!0:e._run_async_load(e._jQuery(this).attr("href"))}catch(c){return c=c,e._options.console.error("Progressio.ProgressioPage.events_async_load[async]",c)}finally{return b}}),b.attr("data-progressio-async","active"),c)return this._options.console.debug("Progressio.ProgressioPage.events_async_load","Yay! "+c+" internal links ajax-ified.")}catch(f){return d=f,this._options.console.error("Progressio.ProgressioPage.events_async_load",d)}},a.prototype.events_state_change=function(){var a,b,c;try{return b=this,c=function(a){var c;return c=document.location.pathname,c!==b._state_url?(b._state_url=c,b._run_async_load(b._state_url)):void 0},this._window_sel.off("popstate"),this._window_sel.off("pushstate"),this._window_sel.on("popstate",c),this._window_sel.on("pushstate",c)}catch(d){return a=d,this._options.console.error("Progressio.ProgressioPage.events_state_change",a)}},a.prototype.fire_dom_updated=function(){var a;try{return this.events_async_load("body")}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage.fire_dom_updated",a)}},a.prototype.get_id=function(){var a;try{return this._id_async}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage.get_id",a)}},a.prototype._eligible_links_async_load=function(){var a,b,c,d;try{return d=this,b=""+this._http_protocol+"://"+this._http_host+"/",c=new RegExp("^("+b+"|(.?/(?!https?://).*))","gi"),this._document_sel.find('a[href]:not([target="_blank"], [data-progressio-async="disabled"], [data-progressio-async="active"])').filter(function(){return d._jQuery(this).attr("href").match(c)})}catch(e){return a=e,this._options.console.error("Progressio.ProgressioPage._eligible_links_async_load",a)}},a.prototype._run_async_load=function(a){var b,c,d,e;try{return e=this,this._begin_progress_bar(),this._hide_error_alert(),c=++this._id_async,d=function(b){return e._handle_async_load(c,a,b)},this._jQuery.ajax({url:a,headers:{"X-Requested-With":"Progressio"},type:"GET",success:d,error:d}),this._options.console.debug("Progressio.ProgressioPage._run_async_load","Loading page: "+a)}catch(f){return b=f,this._options.console.error("Progressio.ProgressioPage._run_async_load",b)}},a.prototype._handle_async_load=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;try{return o=this,"object"==typeof c&&c.hasOwnProperty("responseText")&&(c=c.responseText),a===this._id_async?(i=this._jQuery(c),l=i.filter(""+this._options.container+":first"),l.size()?(p=i.filter("title:first"),d=0,m=this._document_sel.find('script:not([data-progressio-scope="common"])'),n=this._document_sel.find('link[rel="stylesheet"]:not([data-progressio-scope="common"])'),e=function(){return m.remove(),n.remove(),o._options.console.debug("Progressio.ProgressioPage._handle_async_load","Done cleanup of old DOM before page: "+b)},g=function(){var a;return o._end_progress_bar(),"object"==typeof o._options.callbacks&&"object"==typeof o._options.callbacks.post_display&&"function"==typeof o._options.callbacks.post_display.before&&o._options.callbacks.post_display.before()===!0&&(o._scroll_top(),a=o._options.callbacks.post_display.after,"function"===a&&o._options.callbacks.post_display.after()),o._options.console.debug("Progressio.ProgressioPage._handle_async_load","Done post display actions for page: "+b)},f=function(){return o._document_sel.oneTime(250,function(){var a,c,d;return"object"==typeof o._options.callbacks&&"object"==typeof o._options.callbacks.on_complete&&"function"==typeof o._options.callbacks.on_complete.before&&o._options.callbacks.on_complete.before()===!0&&(a=o._options.callbacks.on_complete.after,"function"===a&&o._options.callbacks.on_complete.after()),e(),o._document_sel.find("title").replaceWith(p),o._document_sel.find(""+o._options.container).remove(),d=o._document_sel.find(""+o._options.container+"_new"),c=o.__.ProgressioMisc.split_selector_path(o._options.container),d.attr(c.attr,c.value).show(),o.__.ProgressioRegistry.restore_events(""+o._options.container),b!==o._state_url&&(o._state_url=b,history.pushState(null,p,b)),g(),o._options.console.debug("Progressio.ProgressioPage._handle_async_load","Loaded page: "+b)})},this.purge_global_events(),this.__.ProgressioRegistry.unload_bundles(),this._document_sel.find(""+this._options.container+"_new").remove(),h=this.__.ProgressioMisc.split_selector_path(this._options.container),l.attr(h.attr,""+h.value+"_new"),l.hide(),l.insertBefore(this._document_sel.find(""+this._options.container)),this._head.append(i.filter('script:not([src]):not([data-progressio-scope="common"])')),this._head.append(i.filter('link[rel="stylesheet"]:not([href]):not([data-progressio-scope="common"])')),k={js:[],css:[]},i.filter('script[src]:not([data-progressio-scope="common"])').each(function(){var a;return a=o._jQuery(this).attr("src"),a?k.js.push(a):void 0}),i.filter('link[href][rel="stylesheet"]:not([data-progressio-scope="common"])').each(function(){var a;return a=o._jQuery(this).attr("href"),a?k.css.push(a):void 0}),k.js.length||k.css.length?(k.js.length&&(d++,this._options.console.info("Progressio.ProgressioPage._handle_async_load","Loading scripts..."),LazyLoad.js(k.js,function(){return o._options.console.info("Progressio.ProgressioPage._handle_async_load[async]","Scripts fully loaded"),0===--d?f():void 0})),k.css.length&&(d++,this._options.console.info("Progressio.ProgressioPage._handle_async_load","Loading stylesheets..."),LazyLoad.css(k.css,function(){return o._options.console.info("Progressio.ProgressioPage._handle_async_load[async]","Stylesheets fully loaded"),0===--d?f():void 0})),this._options.console.debug("Progressio.ProgressioPage._handle_async_load","Delayed page load (waiting for sources to be loaded): "+b)):f()):(this._show_error_alert(10),this._end_progress_bar(),this._options.console.error("Progressio.ProgressioPage._handle_async_load","Got an abnormal or error response from: "+b))):this._options.console.warn("Progressio.ProgressioPage._handle_async_load","Dropped outpaced ID for page: "+b)}catch(q){return j=q,this._options.console.error("Progressio.ProgressioPage._handle_async_load",j)}},a.prototype._begin_progress_bar=function(a,b){var c;try{return this.__._loader_bar_sel.stop(!0),this.__._loader_bar_sel.css({width:0}),this._options.auto_hide===!0&&(this.__._loader_bar_container_sel.stop(!0),this.__._loader_bar_container_sel.fadeIn(250)),"function"==typeof a&&a(),this.__._loader_bar_sel.addClass("animated"),this.__._loader_bar_sel.animate({width:"50%"},600,"easeOutQuad",function(){return"function"==typeof b?b():void 0})}catch(d){return c=d,this._options.console.error("Progressio.ProgressioPage._begin_progress_bar",c)}},a.prototype._end_progress_bar=function(a,b){var c,d;try{return d=this,"function"==typeof a&&a(),this.__._loader_bar_sel.animate({width:"100%"},300,"linear",function(){return d.__._loader_bar_sel.removeClass("animated"),d._options.auto_hide===!0&&(d.__._loader_bar_container_sel.stop(!0),d.__._loader_bar_container_sel.fadeOut(400)),"function"==typeof b?b():void 0})}catch(e){return c=e,this._options.console.error("Progressio.ProgressioPage._end_progress_bar",c)}},a.prototype._get_error_alert=function(){var a;try{return this._document_sel.find(".alerts .async-load-error")}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage._get_error_alert",a)}},a.prototype._show_error_alert=function(a){var b,c;null==a&&(a=10);try{return c=this._get_error_alert(),c.stop(!0).hide(),c.animate({height:"toggle",opacity:"toggle"},400,function(){return this._jQuery(this).oneTime(""+a+"s",function(){return this._jQuery(this).animate({height:"toggle",opacity:"toggle"},400)})})}catch(d){return b=d,this._options.console.error("Progressio.ProgressioPage._show_error_alert",b)}},a.prototype._hide_error_alert=function(){var a,b;try{if(b=this._get_error_alert().filter(":visible"),b.size())return b.stopTime(),b.stop(!0).animate({height:"toggle",opacity:"toggle"},250)}catch(c){return a=c,this._options.console.error("Progressio.ProgressioPage._hide_error_alert",a)}},a.prototype._scroll_top=function(){var a;try{return this._window_sel.scrollTop(0)}catch(b){return a=b,this._options.console.error("Progressio.ProgressioPage._scroll_top",a)}},a}(),g=function(){function a(a,b,c){var d;try{this.__=a,this._options=b,this._jQuery=c.jquery,this._registry_events={},this._registry_bundles=[]}catch(e){d=e,this._options.console.error("Progressio.ProgressioRegistry.constructor",d)}}return a.prototype.events=function(){var a;try{return this._bind_events("body")}catch(b){return a=b,this._options.console.error("Progressio.ProgressioRegistry.events",a)}},a.prototype._bind_events=function(a){var b,c,d,e,f,g,h;try{a=a||"body",d="body"===a,b=null,g=this._registry_events,h=[];for(e in g){b=g[e];try{d&&b[2]||b[0].bind(b[1])(a),h.push(this._options.console.debug("Progressio.ProgressioRegistry._bind_events[loop]","Bound callback function for "+e))}catch(f){f=f,h.push(this._options.console.error("Progressio.ProgressioRegistry._bind_events[loop]","Registry callback function execution failed for "+(""+e+" with error message: "+f)))}}return h}catch(f){return c=f,this._options.console.error("Progressio.ProgressioRegistry._bind_events",c)}},a.prototype.register_event=function(a,b,c,d){var e;try{return d=d,this._registry_events[a]=[b,c,d],this._options.console.info("Progressio.ProgressioRegistry.register_event","Registered event: "+a)}catch(f){return e=f,this._options.console.error("Progressio.ProgressioRegistry.register_event",e)}},a.prototype.unregister_event=function(a){var b;try{return c.call(this._registry_events,a)>=0?(delete this._registry_events[a],this._options.console.info("Progressio.ProgressioRegistry.unregister_event","Unregistered event: "+a),!0):!1}catch(d){return b=d,this._options.console.error("Progressio.ProgressioRegistry.unregister_event",b)}},a.prototype.init_events=function(){var a;try{return this._bind_events("body")}catch(b){return a=b,this._options.console.error("Progressio.ProgressioRegistry.init_events",a)}},a.prototype.restore_events=function(a){var b;try{return this._bind_events(a)}catch(c){return b=c,this._options.console.error("Progressio.ProgressioRegistry.restore_events",b)}},a.prototype.register_bundle=function(a){var b;try{return this._registry_bundles.push(a)}catch(c){return b=c,this._options.console.error("Progressio.ProgressioRegistry.register_bundle",b)}},a.prototype.unload_bundles=function(){var a,b,c,d,e,f;try{for(a=0,f=this._registry_bundles,d=0,e=f.length;e>d;d++)b=f[d],this.hasOwnProperty(b)&&(delete _[b],a++);return this._options.console.info("Progressio.ProgressioRegistry.unload_bundles","Unloaded "+a+" bundles")}catch(g){return c=g,this._options.console.error("Progressio.ProgressioRegistry.unload_bundles",c)}},a}(),e=function(){function a(a,b,c){var d;try{this.__=a,this._options=b,this._jQuery=c.jquery,this._window_sel=this._jQuery(window),this._key_event={}}catch(e){d=e,this._options.console.error("Progressio.ProgressioMisc.constructor",d)}}return a.prototype.register=function(){var a;try{return this.__.ProgressioRegistry.register_event("progressio:misc:events_key",this.events_key,this)}catch(b){return a=b,this._options.console.error("Progressio.ProgressioMisc.register",a)}},a.prototype.events_key=function(){var a,b;try{return b=this,this._window_sel.keydown(function(a){return b._key_event=a}),this._window_sel.keyup(function(){return b._key_event={}})}catch(c){return a=c,this._options.console.error("Progressio.ProgressioMisc.events_key",a)}},a.prototype.key_event=function(){var a;try{return this._key_event}catch(b){return a=b,this._options.console.error("Progressio.ProgressioMisc.key_event",a)}},a.prototype.split_selector_path=function(a){var b,c,d;c={attr:"data-selector",value:null};try{switch(d=a.substr(0,1),c.value=a.substr(1,a.length),d){case"#":c.attr="id";break;case".":c.attr="class"}}catch(e){return b=e,this._options.console.error("Progressio.ProgressioMisc.split_selector_path",b)}finally{return c}},a}(),d}()}).call(this); |
| /** | ||
| * progressio [uncompressed] | ||
| * @fileoverview Beautiful & stylish asynchronous page loader. Makes a static website dynamic in a breeze. | ||
| * | ||
| * @version 1.0.0 | ||
| * @date 2016-01-20 | ||
| * @author Valérian Saliou https://valeriansaliou.name/ | ||
| * @license MPL-2.0 | ||
| * | ||
| * @url https://github.com/valeriansaliou/progressio | ||
| * @repository git+https://github.com/valeriansaliou/progressio.git | ||
| */ | ||
| /* line 17, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container { | ||
| height: 2px; | ||
| background: #dbe0de; | ||
| } | ||
| /* line 21, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container .progressio-bar { | ||
| position: relative; | ||
| height: 0; | ||
| border-top: 1px solid #00a7f8; | ||
| border-bottom: 1px solid #225b9d; | ||
| z-index: 999999999; | ||
| -moz-box-shadow: 0 0 0 0; | ||
| -webkit-box-shadow: 0 0 0 0; | ||
| box-shadow: 0 0 0 0; | ||
| -moz-transition-property: box-shadow; | ||
| -o-transition-property: box-shadow; | ||
| -webkit-transition-property: box-shadow; | ||
| transition-property: box-shadow; | ||
| -moz-transition-delay: 350ms; | ||
| -o-transition-delay: 350ms; | ||
| -webkit-transition-delay: 350ms; | ||
| transition-delay: 350ms; | ||
| } | ||
| /* line 31, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-visibility-hide { | ||
| display: none; | ||
| } | ||
| /* line 34, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-visibility-show { | ||
| display: block; | ||
| } | ||
| /* line 37, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-position-fixed { | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| z-index: 999999999; | ||
| } | ||
| /* line 44, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-position-fixed.progressio-location-bottom { | ||
| top: auto; | ||
| bottom: 0; | ||
| } | ||
| /* line 48, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-red { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 51, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-red .progressio-bar { | ||
| border-top-color: #f81700; | ||
| border-bottom-color: #9d0700; | ||
| } | ||
| /* line 55, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-green { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 58, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-green .progressio-bar { | ||
| border-top-color: #00f82e; | ||
| border-bottom-color: #009d1b; | ||
| } | ||
| /* line 62, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-yellow { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 65, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-yellow .progressio-bar { | ||
| border-top-color: #f8e200; | ||
| border-bottom-color: #9d9000; | ||
| } | ||
| /* line 69, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-orange { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 72, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-orange .progressio-bar { | ||
| border-top-color: #f89b00; | ||
| border-bottom-color: #9d6500; | ||
| } | ||
| /* line 76, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-black { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 79, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-black .progressio-bar { | ||
| border-top-color: #31302d; | ||
| border-bottom-color: #000000; | ||
| } | ||
| /* line 83, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-purple { | ||
| background: #dbe0de; | ||
| } | ||
| /* line 86, ../../src/stylesheets/progressio.sass */ | ||
| .progressio-container.progressio-color-purple .progressio-bar { | ||
| border-top-color: #c200f8; | ||
| border-bottom-color: #80009d; | ||
| } |
| .progressio-container{height:2px;background:#dbe0de}.progressio-container .progressio-bar{position:relative;height:0;border-top:1px solid #00a7f8;border-bottom:1px solid #225b9d;z-index:999999999;-moz-box-shadow:0 0;-webkit-box-shadow:0 0;box-shadow:0 0;-moz-transition-property:box-shadow;-o-transition-property:box-shadow;-webkit-transition-property:box-shadow;transition-property:box-shadow;-moz-transition-delay:350ms;-o-transition-delay:350ms;-webkit-transition-delay:350ms;transition-delay:350ms}.progressio-container.progressio-visibility-hide{display:none}.progressio-container.progressio-visibility-show{display:block}.progressio-container.progressio-position-fixed{position:fixed;top:0;left:0;right:0;z-index:999999999}.progressio-container.progressio-position-fixed.progressio-location-bottom{top:auto;bottom:0}.progressio-container.progressio-color-red{background:#dbe0de}.progressio-container.progressio-color-red .progressio-bar{border-top-color:#f81700;border-bottom-color:#9d0700}.progressio-container.progressio-color-green{background:#dbe0de}.progressio-container.progressio-color-green .progressio-bar{border-top-color:#00f82e;border-bottom-color:#009d1b}.progressio-container.progressio-color-yellow{background:#dbe0de}.progressio-container.progressio-color-yellow .progressio-bar{border-top-color:#f8e200;border-bottom-color:#9d9000}.progressio-container.progressio-color-orange{background:#dbe0de}.progressio-container.progressio-color-orange .progressio-bar{border-top-color:#f89b00;border-bottom-color:#9d6500}.progressio-container.progressio-color-black{background:#dbe0de}.progressio-container.progressio-color-black .progressio-bar{border-top-color:#31302d;border-bottom-color:#000}.progressio-container.progressio-color-purple{background:#dbe0de}.progressio-container.progressio-color-purple .progressio-bar{border-top-color:#c200f8;border-bottom-color:#80009d} |
Sorry, the diff of this file is not supported yet
| /* | ||
| * Console.js | ||
| * | ||
| * An interface to native console methods | ||
| * Avoids issues when browser does not have native support for console | ||
| * | ||
| * @license OS | ||
| * @author Valérian Saliou <valerian@valeriansaliou.name> | ||
| * @url https://github.com/valeriansaliou/console.js | ||
| */ | ||
| var Console = (function () { | ||
| var self = {}; | ||
| /* Variables */ | ||
| self._html_sel = document.getElementsByTagName('html')[0]; | ||
| self._environment = self._html_sel.getAttribute('data-environment'); | ||
| self._development = self._environment == 'development'; | ||
| self._available = typeof(window.console) != 'undefined'; | ||
| self._has = self._development && self._available; | ||
| self._console = self._available ? console : {}; | ||
| /* Adapters */ | ||
| self._adapter = function (level) { | ||
| if (!self._has) { | ||
| return function() {}; | ||
| } | ||
| var adapter = null; | ||
| try { | ||
| switch (level) { | ||
| case 0: | ||
| adapter = console.warn; break; | ||
| case 1: | ||
| adapter = console.error; break; | ||
| case 2: | ||
| adapter = console.info; break; | ||
| case 3: | ||
| adapter = console.log; break; | ||
| case 4: | ||
| adapter = console.debug; break; | ||
| } | ||
| } catch (e) { | ||
| adapter = function() {}; | ||
| } | ||
| return adapter.bind(self._console); | ||
| }; | ||
| /* Methods */ | ||
| self.warn = self._adapter(0); | ||
| self.error = self._adapter(1); | ||
| self.info = self._adapter(2); | ||
| self.log = self._adapter(3); | ||
| self.debug = self._adapter(4); | ||
| return self; | ||
| })(); |
| /* | ||
| * jQuery hasParent | ||
| * | ||
| * URL: https://github.com/valeriansaliou/jquery.hasparent | ||
| * Author: Valerian Saliou | ||
| * License: MIT | ||
| * | ||
| * Copyright 2014, Valerian Saliou | ||
| * | ||
| * Version: v1.0.0 | ||
| * Date: Fri Oct 16, 2014 | ||
| */ | ||
| jQuery.extend(jQuery.fn, { | ||
| hasParent: function(p) { | ||
| return this.filter(function() { | ||
| // Return truthy/falsey based on presence of parent in upward tree | ||
| return $(this).parents(p).size(); | ||
| }); | ||
| } | ||
| }); |
| /** | ||
| * jQuery.timers - Timer abstractions for jQuery | ||
| * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) | ||
| * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). | ||
| * Date: 2009/10/16 | ||
| * | ||
| * @author Blair Mitchelmore | ||
| * @version 1.2 | ||
| * | ||
| **/ | ||
| jQuery.fn.extend({ | ||
| everyTime: function(interval, label, fn, times) { | ||
| return this.each(function() { | ||
| jQuery.timer.add(this, interval, label, fn, times); | ||
| }); | ||
| }, | ||
| oneTime: function(interval, label, fn) { | ||
| return this.each(function() { | ||
| jQuery.timer.add(this, interval, label, fn, 1); | ||
| }); | ||
| }, | ||
| stopTime: function(label, fn) { | ||
| return this.each(function() { | ||
| jQuery.timer.remove(this, label, fn); | ||
| }); | ||
| } | ||
| }); | ||
| jQuery.extend({ | ||
| timer: { | ||
| global: [], | ||
| guid: 1, | ||
| dataKey: "jQuery.timer", | ||
| regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/, | ||
| powers: { | ||
| // Yeah this is major overkill... | ||
| 'ms': 1, | ||
| 'cs': 10, | ||
| 'ds': 100, | ||
| 's': 1000, | ||
| 'das': 10000, | ||
| 'hs': 100000, | ||
| 'ks': 1000000 | ||
| }, | ||
| timeParse: function(value) { | ||
| if (value == undefined || value == null) | ||
| return null; | ||
| var result = this.regex.exec(jQuery.trim(value.toString())); | ||
| if (result[2]) { | ||
| var num = parseFloat(result[1]); | ||
| var mult = this.powers[result[2]] || 1; | ||
| return num * mult; | ||
| } else { | ||
| return value; | ||
| } | ||
| }, | ||
| add: function(element, interval, label, fn, times) { | ||
| var counter = 0; | ||
| if (jQuery.isFunction(label)) { | ||
| if (!times) | ||
| times = fn; | ||
| fn = label; | ||
| label = interval; | ||
| } | ||
| interval = jQuery.timer.timeParse(interval); | ||
| if (typeof interval != 'number' || isNaN(interval) || interval < 0) | ||
| return; | ||
| if (typeof times != 'number' || isNaN(times) || times < 0) | ||
| times = 0; | ||
| times = times || 0; | ||
| var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {}); | ||
| if (!timers[label]) | ||
| timers[label] = {}; | ||
| fn.timerID = fn.timerID || this.guid++; | ||
| var handler = function() { | ||
| if ((++counter > times && times !== 0) || fn.call(element, counter) === false) | ||
| jQuery.timer.remove(element, label, fn); | ||
| }; | ||
| handler.timerID = fn.timerID; | ||
| if (!timers[label][fn.timerID]) | ||
| timers[label][fn.timerID] = window.setInterval(handler,interval); | ||
| this.global.push( element ); | ||
| }, | ||
| remove: function(element, label, fn) { | ||
| var timers = jQuery.data(element, this.dataKey), ret; | ||
| if ( timers ) { | ||
| if (!label) { | ||
| for ( label in timers ) | ||
| this.remove(element, label, fn); | ||
| } else if ( timers[label] ) { | ||
| if ( fn ) { | ||
| if ( fn.timerID ) { | ||
| window.clearInterval(timers[label][fn.timerID]); | ||
| delete timers[label][fn.timerID]; | ||
| } | ||
| } else { | ||
| for ( var fn in timers[label] ) { | ||
| window.clearInterval(timers[label][fn]); | ||
| delete timers[label][fn]; | ||
| } | ||
| } | ||
| for ( ret in timers[label] ) break; | ||
| if ( !ret ) { | ||
| ret = null; | ||
| delete timers[label]; | ||
| } | ||
| } | ||
| for ( ret in timers ) break; | ||
| if ( !ret ) | ||
| jQuery.removeData(element, this.dataKey); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| jQuery(window).bind("unload", function() { | ||
| jQuery.each(jQuery.timer.global, function(index, item) { | ||
| jQuery.timer.remove(item); | ||
| }); | ||
| }); |
| /*! | ||
| * jQuery UI Effects @VERSION | ||
| * http://jqueryui.com | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license. | ||
| * http://jquery.org/license | ||
| */ | ||
| //>>label: Effects Core | ||
| //>>group: Effects | ||
| //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects. | ||
| //>>docs: http://api.jqueryui.com/category/effects-core/ | ||
| //>>demos: http://jqueryui.com/effect/ | ||
| (function( factory ) { | ||
| if ( typeof define === "function" && define.amd ) { | ||
| // AMD. Register as an anonymous module. | ||
| define( [ "jquery" ], factory ); | ||
| } else { | ||
| // Browser globals | ||
| factory( jQuery ); | ||
| } | ||
| }(function( $ ) { | ||
| var dataSpace = "ui-effects-", | ||
| dataSpaceStyle = "ui-effects-style", | ||
| dataSpaceAnimated = "ui-effects-animated", | ||
| // Create a local jQuery because jQuery Color relies on it and the | ||
| // global may not exist with AMD and a custom build (#10199) | ||
| jQuery = $; | ||
| $.effects = { | ||
| effect: {} | ||
| }; | ||
| /*! | ||
| * jQuery Color Animations v2.1.2 | ||
| * https://github.com/jquery/jquery-color | ||
| * | ||
| * Copyright 2014 jQuery Foundation and other contributors | ||
| * Released under the MIT license. | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: Wed Jan 16 08:47:09 2013 -0600 | ||
| */ | ||
| (function( jQuery, undefined ) { | ||
| var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", | ||
| // plusequals test for += 100 -= 100 | ||
| rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, | ||
| // a set of RE's that can match strings and generate color tuples. | ||
| stringParsers = [ { | ||
| re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | ||
| parse: function( execResult ) { | ||
| return [ | ||
| execResult[ 1 ], | ||
| execResult[ 2 ], | ||
| execResult[ 3 ], | ||
| execResult[ 4 ] | ||
| ]; | ||
| } | ||
| }, { | ||
| re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | ||
| parse: function( execResult ) { | ||
| return [ | ||
| execResult[ 1 ] * 2.55, | ||
| execResult[ 2 ] * 2.55, | ||
| execResult[ 3 ] * 2.55, | ||
| execResult[ 4 ] | ||
| ]; | ||
| } | ||
| }, { | ||
| // this regex ignores A-F because it's compared against an already lowercased string | ||
| re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, | ||
| parse: function( execResult ) { | ||
| return [ | ||
| parseInt( execResult[ 1 ], 16 ), | ||
| parseInt( execResult[ 2 ], 16 ), | ||
| parseInt( execResult[ 3 ], 16 ) | ||
| ]; | ||
| } | ||
| }, { | ||
| // this regex ignores A-F because it's compared against an already lowercased string | ||
| re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, | ||
| parse: function( execResult ) { | ||
| return [ | ||
| parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), | ||
| parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), | ||
| parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) | ||
| ]; | ||
| } | ||
| }, { | ||
| re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | ||
| space: "hsla", | ||
| parse: function( execResult ) { | ||
| return [ | ||
| execResult[ 1 ], | ||
| execResult[ 2 ] / 100, | ||
| execResult[ 3 ] / 100, | ||
| execResult[ 4 ] | ||
| ]; | ||
| } | ||
| } ], | ||
| // jQuery.Color( ) | ||
| color = jQuery.Color = function( color, green, blue, alpha ) { | ||
| return new jQuery.Color.fn.parse( color, green, blue, alpha ); | ||
| }, | ||
| spaces = { | ||
| rgba: { | ||
| props: { | ||
| red: { | ||
| idx: 0, | ||
| type: "byte" | ||
| }, | ||
| green: { | ||
| idx: 1, | ||
| type: "byte" | ||
| }, | ||
| blue: { | ||
| idx: 2, | ||
| type: "byte" | ||
| } | ||
| } | ||
| }, | ||
| hsla: { | ||
| props: { | ||
| hue: { | ||
| idx: 0, | ||
| type: "degrees" | ||
| }, | ||
| saturation: { | ||
| idx: 1, | ||
| type: "percent" | ||
| }, | ||
| lightness: { | ||
| idx: 2, | ||
| type: "percent" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| propTypes = { | ||
| "byte": { | ||
| floor: true, | ||
| max: 255 | ||
| }, | ||
| "percent": { | ||
| max: 1 | ||
| }, | ||
| "degrees": { | ||
| mod: 360, | ||
| floor: true | ||
| } | ||
| }, | ||
| support = color.support = {}, | ||
| // element for support tests | ||
| supportElem = jQuery( "<p>" )[ 0 ], | ||
| // colors = jQuery.Color.names | ||
| colors, | ||
| // local aliases of functions called often | ||
| each = jQuery.each; | ||
| // determine rgba support immediately | ||
| supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; | ||
| support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; | ||
| // define cache name and alpha properties | ||
| // for rgba and hsla spaces | ||
| each( spaces, function( spaceName, space ) { | ||
| space.cache = "_" + spaceName; | ||
| space.props.alpha = { | ||
| idx: 3, | ||
| type: "percent", | ||
| def: 1 | ||
| }; | ||
| }); | ||
| function clamp( value, prop, allowEmpty ) { | ||
| var type = propTypes[ prop.type ] || {}; | ||
| if ( value == null ) { | ||
| return (allowEmpty || !prop.def) ? null : prop.def; | ||
| } | ||
| // ~~ is an short way of doing floor for positive numbers | ||
| value = type.floor ? ~~value : parseFloat( value ); | ||
| // IE will pass in empty strings as value for alpha, | ||
| // which will hit this case | ||
| if ( isNaN( value ) ) { | ||
| return prop.def; | ||
| } | ||
| if ( type.mod ) { | ||
| // we add mod before modding to make sure that negatives values | ||
| // get converted properly: -10 -> 350 | ||
| return (value + type.mod) % type.mod; | ||
| } | ||
| // for now all property types without mod have min and max | ||
| return 0 > value ? 0 : type.max < value ? type.max : value; | ||
| } | ||
| function stringParse( string ) { | ||
| var inst = color(), | ||
| rgba = inst._rgba = []; | ||
| string = string.toLowerCase(); | ||
| each( stringParsers, function( i, parser ) { | ||
| var parsed, | ||
| match = parser.re.exec( string ), | ||
| values = match && parser.parse( match ), | ||
| spaceName = parser.space || "rgba"; | ||
| if ( values ) { | ||
| parsed = inst[ spaceName ]( values ); | ||
| // if this was an rgba parse the assignment might happen twice | ||
| // oh well.... | ||
| inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; | ||
| rgba = inst._rgba = parsed._rgba; | ||
| // exit each( stringParsers ) here because we matched | ||
| return false; | ||
| } | ||
| }); | ||
| // Found a stringParser that handled it | ||
| if ( rgba.length ) { | ||
| // if this came from a parsed string, force "transparent" when alpha is 0 | ||
| // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) | ||
| if ( rgba.join() === "0,0,0,0" ) { | ||
| jQuery.extend( rgba, colors.transparent ); | ||
| } | ||
| return inst; | ||
| } | ||
| // named colors | ||
| return colors[ string ]; | ||
| } | ||
| color.fn = jQuery.extend( color.prototype, { | ||
| parse: function( red, green, blue, alpha ) { | ||
| if ( red === undefined ) { | ||
| this._rgba = [ null, null, null, null ]; | ||
| return this; | ||
| } | ||
| if ( red.jquery || red.nodeType ) { | ||
| red = jQuery( red ).css( green ); | ||
| green = undefined; | ||
| } | ||
| var inst = this, | ||
| type = jQuery.type( red ), | ||
| rgba = this._rgba = []; | ||
| // more than 1 argument specified - assume ( red, green, blue, alpha ) | ||
| if ( green !== undefined ) { | ||
| red = [ red, green, blue, alpha ]; | ||
| type = "array"; | ||
| } | ||
| if ( type === "string" ) { | ||
| return this.parse( stringParse( red ) || colors._default ); | ||
| } | ||
| if ( type === "array" ) { | ||
| each( spaces.rgba.props, function( key, prop ) { | ||
| rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); | ||
| }); | ||
| return this; | ||
| } | ||
| if ( type === "object" ) { | ||
| if ( red instanceof color ) { | ||
| each( spaces, function( spaceName, space ) { | ||
| if ( red[ space.cache ] ) { | ||
| inst[ space.cache ] = red[ space.cache ].slice(); | ||
| } | ||
| }); | ||
| } else { | ||
| each( spaces, function( spaceName, space ) { | ||
| var cache = space.cache; | ||
| each( space.props, function( key, prop ) { | ||
| // if the cache doesn't exist, and we know how to convert | ||
| if ( !inst[ cache ] && space.to ) { | ||
| // if the value was null, we don't need to copy it | ||
| // if the key was alpha, we don't need to copy it either | ||
| if ( key === "alpha" || red[ key ] == null ) { | ||
| return; | ||
| } | ||
| inst[ cache ] = space.to( inst._rgba ); | ||
| } | ||
| // this is the only case where we allow nulls for ALL properties. | ||
| // call clamp with alwaysAllowEmpty | ||
| inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); | ||
| }); | ||
| // everything defined but alpha? | ||
| if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { | ||
| // use the default of 1 | ||
| inst[ cache ][ 3 ] = 1; | ||
| if ( space.from ) { | ||
| inst._rgba = space.from( inst[ cache ] ); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| return this; | ||
| } | ||
| }, | ||
| is: function( compare ) { | ||
| var is = color( compare ), | ||
| same = true, | ||
| inst = this; | ||
| each( spaces, function( _, space ) { | ||
| var localCache, | ||
| isCache = is[ space.cache ]; | ||
| if (isCache) { | ||
| localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; | ||
| each( space.props, function( _, prop ) { | ||
| if ( isCache[ prop.idx ] != null ) { | ||
| same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); | ||
| return same; | ||
| } | ||
| }); | ||
| } | ||
| return same; | ||
| }); | ||
| return same; | ||
| }, | ||
| _space: function() { | ||
| var used = [], | ||
| inst = this; | ||
| each( spaces, function( spaceName, space ) { | ||
| if ( inst[ space.cache ] ) { | ||
| used.push( spaceName ); | ||
| } | ||
| }); | ||
| return used.pop(); | ||
| }, | ||
| transition: function( other, distance ) { | ||
| var end = color( other ), | ||
| spaceName = end._space(), | ||
| space = spaces[ spaceName ], | ||
| startColor = this.alpha() === 0 ? color( "transparent" ) : this, | ||
| start = startColor[ space.cache ] || space.to( startColor._rgba ), | ||
| result = start.slice(); | ||
| end = end[ space.cache ]; | ||
| each( space.props, function( key, prop ) { | ||
| var index = prop.idx, | ||
| startValue = start[ index ], | ||
| endValue = end[ index ], | ||
| type = propTypes[ prop.type ] || {}; | ||
| // if null, don't override start value | ||
| if ( endValue === null ) { | ||
| return; | ||
| } | ||
| // if null - use end | ||
| if ( startValue === null ) { | ||
| result[ index ] = endValue; | ||
| } else { | ||
| if ( type.mod ) { | ||
| if ( endValue - startValue > type.mod / 2 ) { | ||
| startValue += type.mod; | ||
| } else if ( startValue - endValue > type.mod / 2 ) { | ||
| startValue -= type.mod; | ||
| } | ||
| } | ||
| result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); | ||
| } | ||
| }); | ||
| return this[ spaceName ]( result ); | ||
| }, | ||
| blend: function( opaque ) { | ||
| // if we are already opaque - return ourself | ||
| if ( this._rgba[ 3 ] === 1 ) { | ||
| return this; | ||
| } | ||
| var rgb = this._rgba.slice(), | ||
| a = rgb.pop(), | ||
| blend = color( opaque )._rgba; | ||
| return color( jQuery.map( rgb, function( v, i ) { | ||
| return ( 1 - a ) * blend[ i ] + a * v; | ||
| })); | ||
| }, | ||
| toRgbaString: function() { | ||
| var prefix = "rgba(", | ||
| rgba = jQuery.map( this._rgba, function( v, i ) { | ||
| return v == null ? ( i > 2 ? 1 : 0 ) : v; | ||
| }); | ||
| if ( rgba[ 3 ] === 1 ) { | ||
| rgba.pop(); | ||
| prefix = "rgb("; | ||
| } | ||
| return prefix + rgba.join() + ")"; | ||
| }, | ||
| toHslaString: function() { | ||
| var prefix = "hsla(", | ||
| hsla = jQuery.map( this.hsla(), function( v, i ) { | ||
| if ( v == null ) { | ||
| v = i > 2 ? 1 : 0; | ||
| } | ||
| // catch 1 and 2 | ||
| if ( i && i < 3 ) { | ||
| v = Math.round( v * 100 ) + "%"; | ||
| } | ||
| return v; | ||
| }); | ||
| if ( hsla[ 3 ] === 1 ) { | ||
| hsla.pop(); | ||
| prefix = "hsl("; | ||
| } | ||
| return prefix + hsla.join() + ")"; | ||
| }, | ||
| toHexString: function( includeAlpha ) { | ||
| var rgba = this._rgba.slice(), | ||
| alpha = rgba.pop(); | ||
| if ( includeAlpha ) { | ||
| rgba.push( ~~( alpha * 255 ) ); | ||
| } | ||
| return "#" + jQuery.map( rgba, function( v ) { | ||
| // default to 0 when nulls exist | ||
| v = ( v || 0 ).toString( 16 ); | ||
| return v.length === 1 ? "0" + v : v; | ||
| }).join(""); | ||
| }, | ||
| toString: function() { | ||
| return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); | ||
| } | ||
| }); | ||
| color.fn.parse.prototype = color.fn; | ||
| // hsla conversions adapted from: | ||
| // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 | ||
| function hue2rgb( p, q, h ) { | ||
| h = ( h + 1 ) % 1; | ||
| if ( h * 6 < 1 ) { | ||
| return p + ( q - p ) * h * 6; | ||
| } | ||
| if ( h * 2 < 1) { | ||
| return q; | ||
| } | ||
| if ( h * 3 < 2 ) { | ||
| return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; | ||
| } | ||
| return p; | ||
| } | ||
| spaces.hsla.to = function( rgba ) { | ||
| if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { | ||
| return [ null, null, null, rgba[ 3 ] ]; | ||
| } | ||
| var r = rgba[ 0 ] / 255, | ||
| g = rgba[ 1 ] / 255, | ||
| b = rgba[ 2 ] / 255, | ||
| a = rgba[ 3 ], | ||
| max = Math.max( r, g, b ), | ||
| min = Math.min( r, g, b ), | ||
| diff = max - min, | ||
| add = max + min, | ||
| l = add * 0.5, | ||
| h, s; | ||
| if ( min === max ) { | ||
| h = 0; | ||
| } else if ( r === max ) { | ||
| h = ( 60 * ( g - b ) / diff ) + 360; | ||
| } else if ( g === max ) { | ||
| h = ( 60 * ( b - r ) / diff ) + 120; | ||
| } else { | ||
| h = ( 60 * ( r - g ) / diff ) + 240; | ||
| } | ||
| // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% | ||
| // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) | ||
| if ( diff === 0 ) { | ||
| s = 0; | ||
| } else if ( l <= 0.5 ) { | ||
| s = diff / add; | ||
| } else { | ||
| s = diff / ( 2 - add ); | ||
| } | ||
| return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; | ||
| }; | ||
| spaces.hsla.from = function( hsla ) { | ||
| if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { | ||
| return [ null, null, null, hsla[ 3 ] ]; | ||
| } | ||
| var h = hsla[ 0 ] / 360, | ||
| s = hsla[ 1 ], | ||
| l = hsla[ 2 ], | ||
| a = hsla[ 3 ], | ||
| q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, | ||
| p = 2 * l - q; | ||
| return [ | ||
| Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), | ||
| Math.round( hue2rgb( p, q, h ) * 255 ), | ||
| Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), | ||
| a | ||
| ]; | ||
| }; | ||
| each( spaces, function( spaceName, space ) { | ||
| var props = space.props, | ||
| cache = space.cache, | ||
| to = space.to, | ||
| from = space.from; | ||
| // makes rgba() and hsla() | ||
| color.fn[ spaceName ] = function( value ) { | ||
| // generate a cache for this space if it doesn't exist | ||
| if ( to && !this[ cache ] ) { | ||
| this[ cache ] = to( this._rgba ); | ||
| } | ||
| if ( value === undefined ) { | ||
| return this[ cache ].slice(); | ||
| } | ||
| var ret, | ||
| type = jQuery.type( value ), | ||
| arr = ( type === "array" || type === "object" ) ? value : arguments, | ||
| local = this[ cache ].slice(); | ||
| each( props, function( key, prop ) { | ||
| var val = arr[ type === "object" ? key : prop.idx ]; | ||
| if ( val == null ) { | ||
| val = local[ prop.idx ]; | ||
| } | ||
| local[ prop.idx ] = clamp( val, prop ); | ||
| }); | ||
| if ( from ) { | ||
| ret = color( from( local ) ); | ||
| ret[ cache ] = local; | ||
| return ret; | ||
| } else { | ||
| return color( local ); | ||
| } | ||
| }; | ||
| // makes red() green() blue() alpha() hue() saturation() lightness() | ||
| each( props, function( key, prop ) { | ||
| // alpha is included in more than one space | ||
| if ( color.fn[ key ] ) { | ||
| return; | ||
| } | ||
| color.fn[ key ] = function( value ) { | ||
| var vtype = jQuery.type( value ), | ||
| fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), | ||
| local = this[ fn ](), | ||
| cur = local[ prop.idx ], | ||
| match; | ||
| if ( vtype === "undefined" ) { | ||
| return cur; | ||
| } | ||
| if ( vtype === "function" ) { | ||
| value = value.call( this, cur ); | ||
| vtype = jQuery.type( value ); | ||
| } | ||
| if ( value == null && prop.empty ) { | ||
| return this; | ||
| } | ||
| if ( vtype === "string" ) { | ||
| match = rplusequals.exec( value ); | ||
| if ( match ) { | ||
| value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); | ||
| } | ||
| } | ||
| local[ prop.idx ] = value; | ||
| return this[ fn ]( local ); | ||
| }; | ||
| }); | ||
| }); | ||
| // add cssHook and .fx.step function for each named hook. | ||
| // accept a space separated string of properties | ||
| color.hook = function( hook ) { | ||
| var hooks = hook.split( " " ); | ||
| each( hooks, function( i, hook ) { | ||
| jQuery.cssHooks[ hook ] = { | ||
| set: function( elem, value ) { | ||
| var parsed, curElem, | ||
| backgroundColor = ""; | ||
| if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { | ||
| value = color( parsed || value ); | ||
| if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { | ||
| curElem = hook === "backgroundColor" ? elem.parentNode : elem; | ||
| while ( | ||
| (backgroundColor === "" || backgroundColor === "transparent") && | ||
| curElem && curElem.style | ||
| ) { | ||
| try { | ||
| backgroundColor = jQuery.css( curElem, "backgroundColor" ); | ||
| curElem = curElem.parentNode; | ||
| } catch ( e ) { | ||
| } | ||
| } | ||
| value = value.blend( backgroundColor && backgroundColor !== "transparent" ? | ||
| backgroundColor : | ||
| "_default" ); | ||
| } | ||
| value = value.toRgbaString(); | ||
| } | ||
| try { | ||
| elem.style[ hook ] = value; | ||
| } catch ( e ) { | ||
| // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' | ||
| } | ||
| } | ||
| }; | ||
| jQuery.fx.step[ hook ] = function( fx ) { | ||
| if ( !fx.colorInit ) { | ||
| fx.start = color( fx.elem, hook ); | ||
| fx.end = color( fx.end ); | ||
| fx.colorInit = true; | ||
| } | ||
| jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); | ||
| }; | ||
| }); | ||
| }; | ||
| color.hook( stepHooks ); | ||
| jQuery.cssHooks.borderColor = { | ||
| expand: function( value ) { | ||
| var expanded = {}; | ||
| each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { | ||
| expanded[ "border" + part + "Color" ] = value; | ||
| }); | ||
| return expanded; | ||
| } | ||
| }; | ||
| // Basic color names only. | ||
| // Usage of any of the other color names requires adding yourself or including | ||
| // jquery.color.svg-names.js. | ||
| colors = jQuery.Color.names = { | ||
| // 4.1. Basic color keywords | ||
| aqua: "#00ffff", | ||
| black: "#000000", | ||
| blue: "#0000ff", | ||
| fuchsia: "#ff00ff", | ||
| gray: "#808080", | ||
| green: "#008000", | ||
| lime: "#00ff00", | ||
| maroon: "#800000", | ||
| navy: "#000080", | ||
| olive: "#808000", | ||
| purple: "#800080", | ||
| red: "#ff0000", | ||
| silver: "#c0c0c0", | ||
| teal: "#008080", | ||
| white: "#ffffff", | ||
| yellow: "#ffff00", | ||
| // 4.2.3. "transparent" color keyword | ||
| transparent: [ null, null, null, 0 ], | ||
| _default: "#ffffff" | ||
| }; | ||
| })( jQuery ); | ||
| /******************************************************************************/ | ||
| /****************************** CLASS ANIMATIONS ******************************/ | ||
| /******************************************************************************/ | ||
| (function() { | ||
| var classAnimationActions = [ "add", "remove", "toggle" ], | ||
| shorthandStyles = { | ||
| border: 1, | ||
| borderBottom: 1, | ||
| borderColor: 1, | ||
| borderLeft: 1, | ||
| borderRight: 1, | ||
| borderTop: 1, | ||
| borderWidth: 1, | ||
| margin: 1, | ||
| padding: 1 | ||
| }; | ||
| $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { | ||
| $.fx.step[ prop ] = function( fx ) { | ||
| if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { | ||
| jQuery.style( fx.elem, prop, fx.end ); | ||
| fx.setAttr = true; | ||
| } | ||
| }; | ||
| }); | ||
| function getElementStyles( elem ) { | ||
| var key, len, | ||
| style = elem.ownerDocument.defaultView ? | ||
| elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : | ||
| elem.currentStyle, | ||
| styles = {}; | ||
| if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { | ||
| len = style.length; | ||
| while ( len-- ) { | ||
| key = style[ len ]; | ||
| if ( typeof style[ key ] === "string" ) { | ||
| styles[ $.camelCase( key ) ] = style[ key ]; | ||
| } | ||
| } | ||
| // support: Opera, IE <9 | ||
| } else { | ||
| for ( key in style ) { | ||
| if ( typeof style[ key ] === "string" ) { | ||
| styles[ key ] = style[ key ]; | ||
| } | ||
| } | ||
| } | ||
| return styles; | ||
| } | ||
| function styleDifference( oldStyle, newStyle ) { | ||
| var diff = {}, | ||
| name, value; | ||
| for ( name in newStyle ) { | ||
| value = newStyle[ name ]; | ||
| if ( oldStyle[ name ] !== value ) { | ||
| if ( !shorthandStyles[ name ] ) { | ||
| if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { | ||
| diff[ name ] = value; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return diff; | ||
| } | ||
| // support: jQuery <1.8 | ||
| if ( !$.fn.addBack ) { | ||
| $.fn.addBack = function( selector ) { | ||
| return this.add( selector == null ? | ||
| this.prevObject : this.prevObject.filter( selector ) | ||
| ); | ||
| }; | ||
| } | ||
| $.effects.animateClass = function( value, duration, easing, callback ) { | ||
| var o = $.speed( duration, easing, callback ); | ||
| return this.queue( function() { | ||
| var animated = $( this ), | ||
| baseClass = animated.attr( "class" ) || "", | ||
| applyClassChange, | ||
| allAnimations = o.children ? animated.find( "*" ).addBack() : animated; | ||
| // map the animated objects to store the original styles. | ||
| allAnimations = allAnimations.map(function() { | ||
| var el = $( this ); | ||
| return { | ||
| el: el, | ||
| start: getElementStyles( this ) | ||
| }; | ||
| }); | ||
| // apply class change | ||
| applyClassChange = function() { | ||
| $.each( classAnimationActions, function(i, action) { | ||
| if ( value[ action ] ) { | ||
| animated[ action + "Class" ]( value[ action ] ); | ||
| } | ||
| }); | ||
| }; | ||
| applyClassChange(); | ||
| // map all animated objects again - calculate new styles and diff | ||
| allAnimations = allAnimations.map(function() { | ||
| this.end = getElementStyles( this.el[ 0 ] ); | ||
| this.diff = styleDifference( this.start, this.end ); | ||
| return this; | ||
| }); | ||
| // apply original class | ||
| animated.attr( "class", baseClass ); | ||
| // map all animated objects again - this time collecting a promise | ||
| allAnimations = allAnimations.map(function() { | ||
| var styleInfo = this, | ||
| dfd = $.Deferred(), | ||
| opts = $.extend({}, o, { | ||
| queue: false, | ||
| complete: function() { | ||
| dfd.resolve( styleInfo ); | ||
| } | ||
| }); | ||
| this.el.animate( this.diff, opts ); | ||
| return dfd.promise(); | ||
| }); | ||
| // once all animations have completed: | ||
| $.when.apply( $, allAnimations.get() ).done(function() { | ||
| // set the final class | ||
| applyClassChange(); | ||
| // for each animated element, | ||
| // clear all css properties that were animated | ||
| $.each( arguments, function() { | ||
| var el = this.el; | ||
| $.each( this.diff, function(key) { | ||
| el.css( key, "" ); | ||
| }); | ||
| }); | ||
| // this is guarnteed to be there if you use jQuery.speed() | ||
| // it also handles dequeuing the next anim... | ||
| o.complete.call( animated[ 0 ] ); | ||
| }); | ||
| }); | ||
| }; | ||
| $.fn.extend({ | ||
| addClass: (function( orig ) { | ||
| return function( classNames, speed, easing, callback ) { | ||
| return speed ? | ||
| $.effects.animateClass.call( this, | ||
| { add: classNames }, speed, easing, callback ) : | ||
| orig.apply( this, arguments ); | ||
| }; | ||
| })( $.fn.addClass ), | ||
| removeClass: (function( orig ) { | ||
| return function( classNames, speed, easing, callback ) { | ||
| return arguments.length > 1 ? | ||
| $.effects.animateClass.call( this, | ||
| { remove: classNames }, speed, easing, callback ) : | ||
| orig.apply( this, arguments ); | ||
| }; | ||
| })( $.fn.removeClass ), | ||
| toggleClass: (function( orig ) { | ||
| return function( classNames, force, speed, easing, callback ) { | ||
| if ( typeof force === "boolean" || force === undefined ) { | ||
| if ( !speed ) { | ||
| // without speed parameter | ||
| return orig.apply( this, arguments ); | ||
| } else { | ||
| return $.effects.animateClass.call( this, | ||
| (force ? { add: classNames } : { remove: classNames }), | ||
| speed, easing, callback ); | ||
| } | ||
| } else { | ||
| // without force parameter | ||
| return $.effects.animateClass.call( this, | ||
| { toggle: classNames }, force, speed, easing ); | ||
| } | ||
| }; | ||
| })( $.fn.toggleClass ), | ||
| switchClass: function( remove, add, speed, easing, callback) { | ||
| return $.effects.animateClass.call( this, { | ||
| add: add, | ||
| remove: remove | ||
| }, speed, easing, callback ); | ||
| } | ||
| }); | ||
| })(); | ||
| /******************************************************************************/ | ||
| /*********************************** EFFECTS **********************************/ | ||
| /******************************************************************************/ | ||
| (function() { | ||
| if ( $.expr && $.expr.filters && $.expr.filters.animated ) { | ||
| $.expr.filters.animated = (function( orig ) { | ||
| return function( elem ) { | ||
| return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); | ||
| }; | ||
| })( $.expr.filters.animated ); | ||
| } | ||
| if ( $.uiBackCompat !== false ) { | ||
| $.extend( $.effects, { | ||
| // Saves a set of properties in a data storage | ||
| save: function( element, set ) { | ||
| var i = 0, length = set.length; | ||
| for ( ; i < length; i++ ) { | ||
| if ( set[ i ] !== null ) { | ||
| element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); | ||
| } | ||
| } | ||
| }, | ||
| // Restores a set of previously saved properties from a data storage | ||
| restore: function( element, set ) { | ||
| var val, i = 0, length = set.length; | ||
| for ( ; i < length; i++ ) { | ||
| if ( set[ i ] !== null ) { | ||
| val = element.data( dataSpace + set[ i ] ); | ||
| element.css( set[ i ], val ); | ||
| } | ||
| } | ||
| }, | ||
| setMode: function( el, mode ) { | ||
| if ( mode === "toggle" ) { | ||
| mode = el.is( ":hidden" ) ? "show" : "hide"; | ||
| } | ||
| return mode; | ||
| }, | ||
| // Wraps the element around a wrapper that copies position properties | ||
| createWrapper: function( element ) { | ||
| // if the element is already wrapped, return it | ||
| if ( element.parent().is( ".ui-effects-wrapper" ) ) { | ||
| return element.parent(); | ||
| } | ||
| // wrap the element | ||
| var props = { | ||
| width: element.outerWidth( true ), | ||
| height: element.outerHeight( true ), | ||
| "float": element.css( "float" ) | ||
| }, | ||
| wrapper = $( "<div></div>" ) | ||
| .addClass( "ui-effects-wrapper" ) | ||
| .css({ | ||
| fontSize: "100%", | ||
| background: "transparent", | ||
| border: "none", | ||
| margin: 0, | ||
| padding: 0 | ||
| }), | ||
| // Store the size in case width/height are defined in % - Fixes #5245 | ||
| size = { | ||
| width: element.width(), | ||
| height: element.height() | ||
| }, | ||
| active = document.activeElement; | ||
| // support: Firefox | ||
| // Firefox incorrectly exposes anonymous content | ||
| // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 | ||
| try { | ||
| active.id; | ||
| } catch ( e ) { | ||
| active = document.body; | ||
| } | ||
| element.wrap( wrapper ); | ||
| // Fixes #7595 - Elements lose focus when wrapped. | ||
| if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { | ||
| $( active ).trigger( "focus" ); | ||
| } | ||
| wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element | ||
| // transfer positioning properties to the wrapper | ||
| if ( element.css( "position" ) === "static" ) { | ||
| wrapper.css({ position: "relative" }); | ||
| element.css({ position: "relative" }); | ||
| } else { | ||
| $.extend( props, { | ||
| position: element.css( "position" ), | ||
| zIndex: element.css( "z-index" ) | ||
| }); | ||
| $.each([ "top", "left", "bottom", "right" ], function(i, pos) { | ||
| props[ pos ] = element.css( pos ); | ||
| if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { | ||
| props[ pos ] = "auto"; | ||
| } | ||
| }); | ||
| element.css({ | ||
| position: "relative", | ||
| top: 0, | ||
| left: 0, | ||
| right: "auto", | ||
| bottom: "auto" | ||
| }); | ||
| } | ||
| element.css(size); | ||
| return wrapper.css( props ).show(); | ||
| }, | ||
| removeWrapper: function( element ) { | ||
| var active = document.activeElement; | ||
| if ( element.parent().is( ".ui-effects-wrapper" ) ) { | ||
| element.parent().replaceWith( element ); | ||
| // Fixes #7595 - Elements lose focus when wrapped. | ||
| if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { | ||
| $( active ).trigger( "focus" ); | ||
| } | ||
| } | ||
| return element; | ||
| } | ||
| }); | ||
| } | ||
| $.extend( $.effects, { | ||
| version: "@VERSION", | ||
| define: function( name, mode, effect ) { | ||
| if ( !effect ) { | ||
| effect = mode; | ||
| mode = "effect"; | ||
| } | ||
| $.effects.effect[ name ] = effect; | ||
| $.effects.effect[ name ].mode = mode; | ||
| return effect; | ||
| }, | ||
| scaledDimensions: function( element, percent, direction ) { | ||
| if ( percent === 0 ) { | ||
| return { | ||
| height: 0, | ||
| width: 0, | ||
| outerHeight: 0, | ||
| outerWidth: 0 | ||
| }; | ||
| } | ||
| var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1, | ||
| y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1; | ||
| return { | ||
| height: element.height() * y, | ||
| width: element.width() * x, | ||
| outerHeight: element.outerHeight() * y, | ||
| outerWidth: element.outerWidth() * x | ||
| }; | ||
| }, | ||
| clipToBox: function( animation ) { | ||
| return { | ||
| width: animation.clip.right - animation.clip.left, | ||
| height: animation.clip.bottom - animation.clip.top, | ||
| left: animation.clip.left, | ||
| top: animation.clip.top | ||
| }; | ||
| }, | ||
| // Injects recently queued functions to be first in line (after "inprogress") | ||
| unshift: function( element, queueLength, count ) { | ||
| var queue = element.queue(); | ||
| if ( queueLength > 1 ) { | ||
| queue.splice.apply( queue, | ||
| [ 1, 0 ].concat( queue.splice( queueLength, count ) ) ); | ||
| } | ||
| element.dequeue(); | ||
| }, | ||
| saveStyle: function( element ) { | ||
| element.data( dataSpaceStyle, element[ 0 ].style.cssText ); | ||
| }, | ||
| restoreStyle: function( element ) { | ||
| element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || ""; | ||
| element.removeData( dataSpaceStyle ); | ||
| }, | ||
| mode: function( element, mode ) { | ||
| var hidden = element.is( ":hidden" ); | ||
| if ( mode === "toggle" ) { | ||
| mode = hidden ? "show" : "hide"; | ||
| } | ||
| if ( hidden ? mode === "hide" : mode === "show" ) { | ||
| mode = "none"; | ||
| } | ||
| return mode; | ||
| }, | ||
| // Translates a [top,left] array into a baseline value | ||
| getBaseline: function( origin, original ) { | ||
| var y, x; | ||
| switch ( origin[ 0 ] ) { | ||
| case "top": | ||
| y = 0; | ||
| break; | ||
| case "middle": | ||
| y = 0.5; | ||
| break; | ||
| case "bottom": | ||
| y = 1; | ||
| break; | ||
| default: | ||
| y = origin[ 0 ] / original.height; | ||
| } | ||
| switch ( origin[ 1 ] ) { | ||
| case "left": | ||
| x = 0; | ||
| break; | ||
| case "center": | ||
| x = 0.5; | ||
| break; | ||
| case "right": | ||
| x = 1; | ||
| break; | ||
| default: | ||
| x = origin[ 1 ] / original.width; | ||
| } | ||
| return { | ||
| x: x, | ||
| y: y | ||
| }; | ||
| }, | ||
| // Creates a placeholder element so that the original element can be made absolute | ||
| createPlaceholder: function( element ) { | ||
| var placeholder, | ||
| cssPosition = element.css( "position" ), | ||
| position = element.position(); | ||
| // Lock in margins first to account for form elements, which | ||
| // will change margin if you explicitly set height | ||
| // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380 | ||
| // Support: Safari | ||
| element.css({ | ||
| marginTop: element.css( "marginTop" ), | ||
| marginBottom: element.css( "marginBottom" ), | ||
| marginLeft: element.css( "marginLeft" ), | ||
| marginRight: element.css( "marginRight" ) | ||
| }) | ||
| .outerWidth( element.outerWidth() ) | ||
| .outerHeight( element.outerHeight() ); | ||
| if ( /^(static|relative)/.test( cssPosition ) ) { | ||
| cssPosition = "absolute"; | ||
| placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css({ | ||
| // Convert inline to inline block to account for inline elements | ||
| // that turn to inline block based on content (like img) | ||
| display: /^(inline|ruby)/.test( element.css( "display" ) ) ? "inline-block" : "block", | ||
| visibility: "hidden", | ||
| // Margins need to be set to account for margin collapse | ||
| marginTop: element.css( "marginTop" ), | ||
| marginBottom: element.css( "marginBottom" ), | ||
| marginLeft: element.css( "marginLeft" ), | ||
| marginRight: element.css( "marginRight" ), | ||
| "float": element.css( "float" ) | ||
| }) | ||
| .outerWidth( element.outerWidth() ) | ||
| .outerHeight( element.outerHeight() ) | ||
| .addClass( "ui-effects-placeholder" ); | ||
| element.data( dataSpace + "placeholder", placeholder ); | ||
| } | ||
| element.css({ | ||
| position: cssPosition, | ||
| left: position.left, | ||
| top: position.top | ||
| }); | ||
| return placeholder; | ||
| }, | ||
| removePlaceholder: function( element ) { | ||
| var dataKey = dataSpace + "placeholder", | ||
| placeholder = element.data( dataKey ); | ||
| if ( placeholder ) { | ||
| placeholder.remove(); | ||
| element.removeData( dataKey ); | ||
| } | ||
| }, | ||
| // Removes a placeholder if it exists and restores | ||
| // properties that were modified during placeholder creation | ||
| cleanUp: function( element ) { | ||
| $.effects.restoreStyle( element ); | ||
| $.effects.removePlaceholder( element ); | ||
| }, | ||
| setTransition: function( element, list, factor, value ) { | ||
| value = value || {}; | ||
| $.each( list, function( i, x ) { | ||
| var unit = element.cssUnit( x ); | ||
| if ( unit[ 0 ] > 0 ) { | ||
| value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; | ||
| } | ||
| }); | ||
| return value; | ||
| } | ||
| }); | ||
| // return an effect options object for the given parameters: | ||
| function _normalizeArguments( effect, options, speed, callback ) { | ||
| // allow passing all options as the first parameter | ||
| if ( $.isPlainObject( effect ) ) { | ||
| options = effect; | ||
| effect = effect.effect; | ||
| } | ||
| // convert to an object | ||
| effect = { effect: effect }; | ||
| // catch (effect, null, ...) | ||
| if ( options == null ) { | ||
| options = {}; | ||
| } | ||
| // catch (effect, callback) | ||
| if ( $.isFunction( options ) ) { | ||
| callback = options; | ||
| speed = null; | ||
| options = {}; | ||
| } | ||
| // catch (effect, speed, ?) | ||
| if ( typeof options === "number" || $.fx.speeds[ options ] ) { | ||
| callback = speed; | ||
| speed = options; | ||
| options = {}; | ||
| } | ||
| // catch (effect, options, callback) | ||
| if ( $.isFunction( speed ) ) { | ||
| callback = speed; | ||
| speed = null; | ||
| } | ||
| // add options to effect | ||
| if ( options ) { | ||
| $.extend( effect, options ); | ||
| } | ||
| speed = speed || options.duration; | ||
| effect.duration = $.fx.off ? 0 : | ||
| typeof speed === "number" ? speed : | ||
| speed in $.fx.speeds ? $.fx.speeds[ speed ] : | ||
| $.fx.speeds._default; | ||
| effect.complete = callback || options.complete; | ||
| return effect; | ||
| } | ||
| function standardAnimationOption( option ) { | ||
| // Valid standard speeds (nothing, number, named speed) | ||
| if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { | ||
| return true; | ||
| } | ||
| // Invalid strings - treat as "normal" speed | ||
| if ( typeof option === "string" && !$.effects.effect[ option ] ) { | ||
| return true; | ||
| } | ||
| // Complete callback | ||
| if ( $.isFunction( option ) ) { | ||
| return true; | ||
| } | ||
| // Options hash (but not naming an effect) | ||
| if ( typeof option === "object" && !option.effect ) { | ||
| return true; | ||
| } | ||
| // Didn't match any standard API | ||
| return false; | ||
| } | ||
| $.fn.extend({ | ||
| effect: function( /* effect, options, speed, callback */ ) { | ||
| var args = _normalizeArguments.apply( this, arguments ), | ||
| effectMethod = $.effects.effect[ args.effect ], | ||
| defaultMode = effectMethod.mode, | ||
| queue = args.queue, | ||
| queueName = queue || "fx", | ||
| complete = args.complete, | ||
| mode = args.mode, | ||
| modes = [], | ||
| prefilter = function( next ) { | ||
| var el = $( this ), | ||
| normalizedMode = $.effects.mode( el, mode ) || defaultMode; | ||
| // Sentinel for duck-punching the :animated psuedo-selector | ||
| el.data( dataSpaceAnimated, true ); | ||
| // Save effect mode for later use, | ||
| // we can't just call $.effects.mode again later, | ||
| // as the .show() below destroys the initial state | ||
| modes.push( normalizedMode ); | ||
| // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13 | ||
| if ( defaultMode && ( normalizedMode === "show" || | ||
| ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) { | ||
| el.show(); | ||
| } | ||
| if ( !defaultMode || normalizedMode !== "none" ) { | ||
| $.effects.saveStyle( el ); | ||
| } | ||
| if ( $.isFunction( next ) ) { | ||
| next(); | ||
| } | ||
| }; | ||
| if ( $.fx.off || !effectMethod ) { | ||
| // delegate to the original method (e.g., .show()) if possible | ||
| if ( mode ) { | ||
| return this[ mode ]( args.duration, complete ); | ||
| } else { | ||
| return this.each( function() { | ||
| if ( complete ) { | ||
| complete.call( this ); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| function run( next ) { | ||
| var elem = $( this ); | ||
| function cleanup() { | ||
| elem.removeData( dataSpaceAnimated ); | ||
| $.effects.cleanUp( elem ); | ||
| if ( args.mode === "hide" ) { | ||
| elem.hide(); | ||
| } | ||
| done(); | ||
| } | ||
| function done() { | ||
| if ( $.isFunction( complete ) ) { | ||
| complete.call( elem[ 0 ] ); | ||
| } | ||
| if ( $.isFunction( next ) ) { | ||
| next(); | ||
| } | ||
| } | ||
| // Override mode option on a per element basis, | ||
| // as toggle can be either show or hide depending on element state | ||
| args.mode = modes.shift(); | ||
| if ( $.uiBackCompat !== false && !defaultMode ) { | ||
| if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { | ||
| // Call the core method to track "olddisplay" properly | ||
| elem[ mode ](); | ||
| done(); | ||
| } else { | ||
| effectMethod.call( elem[ 0 ], args, done ); | ||
| } | ||
| } else { | ||
| if ( args.mode === "none" ) { | ||
| // Call the core method to track "olddisplay" properly | ||
| elem[ mode ](); | ||
| done(); | ||
| } else { | ||
| effectMethod.call( elem[ 0 ], args, cleanup ); | ||
| } | ||
| } | ||
| } | ||
| // Run prefilter on all elements first to ensure that | ||
| // any showing or hiding happens before placeholder creation, | ||
| // which ensures that any layout changes are correctly captured. | ||
| return queue === false ? | ||
| this.each( prefilter ).each( run ) : | ||
| this.queue( queueName, prefilter ).queue( queueName, run ); | ||
| }, | ||
| show: (function( orig ) { | ||
| return function( option ) { | ||
| if ( standardAnimationOption( option ) ) { | ||
| return orig.apply( this, arguments ); | ||
| } else { | ||
| var args = _normalizeArguments.apply( this, arguments ); | ||
| args.mode = "show"; | ||
| return this.effect.call( this, args ); | ||
| } | ||
| }; | ||
| })( $.fn.show ), | ||
| hide: (function( orig ) { | ||
| return function( option ) { | ||
| if ( standardAnimationOption( option ) ) { | ||
| return orig.apply( this, arguments ); | ||
| } else { | ||
| var args = _normalizeArguments.apply( this, arguments ); | ||
| args.mode = "hide"; | ||
| return this.effect.call( this, args ); | ||
| } | ||
| }; | ||
| })( $.fn.hide ), | ||
| toggle: (function( orig ) { | ||
| return function( option ) { | ||
| if ( standardAnimationOption( option ) || typeof option === "boolean" ) { | ||
| return orig.apply( this, arguments ); | ||
| } else { | ||
| var args = _normalizeArguments.apply( this, arguments ); | ||
| args.mode = "toggle"; | ||
| return this.effect.call( this, args ); | ||
| } | ||
| }; | ||
| })( $.fn.toggle ), | ||
| cssUnit: function(key) { | ||
| var style = this.css( key ), | ||
| val = []; | ||
| $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { | ||
| if ( style.indexOf( unit ) > 0 ) { | ||
| val = [ parseFloat( style ), unit ]; | ||
| } | ||
| }); | ||
| return val; | ||
| }, | ||
| cssClip: function( clipObj ) { | ||
| return clipObj ? | ||
| this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + clipObj.bottom + "px " + clipObj.left + "px)" ) : | ||
| parseClip( this.css("clip"), this ); | ||
| }, | ||
| transfer: function( options, done ) { | ||
| var element = $( this ), | ||
| target = $( options.to ), | ||
| targetFixed = target.css( "position" ) === "fixed", | ||
| body = $( "body" ), | ||
| fixTop = targetFixed ? body.scrollTop() : 0, | ||
| fixLeft = targetFixed ? body.scrollLeft() : 0, | ||
| endPosition = target.offset(), | ||
| animation = { | ||
| top: endPosition.top - fixTop, | ||
| left: endPosition.left - fixLeft, | ||
| height: target.innerHeight(), | ||
| width: target.innerWidth() | ||
| }, | ||
| startPosition = element.offset(), | ||
| transfer = $( "<div class='ui-effects-transfer'></div>" ) | ||
| .appendTo( "body" ) | ||
| .addClass( options.className ) | ||
| .css({ | ||
| top: startPosition.top - fixTop, | ||
| left: startPosition.left - fixLeft, | ||
| height: element.innerHeight(), | ||
| width: element.innerWidth(), | ||
| position: targetFixed ? "fixed" : "absolute" | ||
| }) | ||
| .animate( animation, options.duration, options.easing, function() { | ||
| transfer.remove(); | ||
| if ( $.isFunction( done ) ) { | ||
| done(); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| function parseClip( str, element ) { | ||
| var outerWidth = element.outerWidth(), | ||
| outerHeight = element.outerHeight(), | ||
| clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, | ||
| values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ]; | ||
| return { | ||
| top: parseFloat( values[ 1 ] ) || 0, | ||
| right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ), | ||
| bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ), | ||
| left: parseFloat( values[ 4 ] ) || 0 | ||
| }; | ||
| } | ||
| $.fx.step.clip = function( fx ) { | ||
| if ( !fx.clipInit ) { | ||
| fx.start = $( fx.elem ).cssClip(); | ||
| if ( typeof fx.end === "string" ) { | ||
| fx.end = parseClip( fx.end, fx.elem ); | ||
| } | ||
| fx.clipInit = true; | ||
| } | ||
| $( fx.elem ).cssClip({ | ||
| top: fx.pos * (fx.end.top - fx.start.top) + fx.start.top, | ||
| right: fx.pos * (fx.end.right - fx.start.right) + fx.start.right, | ||
| bottom: fx.pos * (fx.end.bottom - fx.start.bottom) + fx.start.bottom, | ||
| left: fx.pos * (fx.end.left - fx.start.left) + fx.start.left | ||
| }); | ||
| }; | ||
| })(); | ||
| /******************************************************************************/ | ||
| /*********************************** EASING ***********************************/ | ||
| /******************************************************************************/ | ||
| (function() { | ||
| // based on easing equations from Robert Penner (http://www.robertpenner.com/easing) | ||
| var baseEasings = {}; | ||
| $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { | ||
| baseEasings[ name ] = function( p ) { | ||
| return Math.pow( p, i + 2 ); | ||
| }; | ||
| }); | ||
| $.extend( baseEasings, { | ||
| Sine: function( p ) { | ||
| return 1 - Math.cos( p * Math.PI / 2 ); | ||
| }, | ||
| Circ: function( p ) { | ||
| return 1 - Math.sqrt( 1 - p * p ); | ||
| }, | ||
| Elastic: function( p ) { | ||
| return p === 0 || p === 1 ? p : | ||
| -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); | ||
| }, | ||
| Back: function( p ) { | ||
| return p * p * ( 3 * p - 2 ); | ||
| }, | ||
| Bounce: function( p ) { | ||
| var pow2, | ||
| bounce = 4; | ||
| while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} | ||
| return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); | ||
| } | ||
| }); | ||
| $.each( baseEasings, function( name, easeIn ) { | ||
| $.easing[ "easeIn" + name ] = easeIn; | ||
| $.easing[ "easeOut" + name ] = function( p ) { | ||
| return 1 - easeIn( 1 - p ); | ||
| }; | ||
| $.easing[ "easeInOut" + name ] = function( p ) { | ||
| return p < 0.5 ? | ||
| easeIn( p * 2 ) / 2 : | ||
| 1 - easeIn( p * -2 + 2 ) / 2; | ||
| }; | ||
| }); | ||
| })(); | ||
| return $.effects; | ||
| })); |
Sorry, the diff of this file is too big to display
| /*jslint browser: true, eqeqeq: true, bitwise: true, newcap: true, immed: true, regexp: false */ | ||
| /** | ||
| LazyLoad makes it easy and painless to lazily load one or more external | ||
| JavaScript or CSS files on demand either during or after the rendering of a web | ||
| page. | ||
| Supported browsers include Firefox 2+, IE6+, Safari 3+ (including Mobile | ||
| Safari), Google Chrome, and Opera 9+. Other browsers may or may not work and | ||
| are not officially supported. | ||
| Visit https://github.com/rgrove/lazyload/ for more info. | ||
| Copyright (c) 2011 Ryan Grove <ryan@wonko.com> | ||
| All rights reserved. | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the 'Software'), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| @module lazyload | ||
| @class LazyLoad | ||
| @static | ||
| */ | ||
| LazyLoad = (function (doc) { | ||
| // -- Private Variables ------------------------------------------------------ | ||
| // User agent and feature test information. | ||
| var env, | ||
| // Reference to the <head> element (populated lazily). | ||
| head, | ||
| // Requests currently in progress, if any. | ||
| pending = {}, | ||
| // Number of times we've polled to check whether a pending stylesheet has | ||
| // finished loading. If this gets too high, we're probably stalled. | ||
| pollCount = 0, | ||
| // Queued requests. | ||
| queue = {css: [], js: []}, | ||
| // Reference to the browser's list of stylesheets. | ||
| styleSheets = doc.styleSheets; | ||
| // -- Private Methods -------------------------------------------------------- | ||
| /** | ||
| Creates and returns an HTML element with the specified name and attributes. | ||
| @method createNode | ||
| @param {String} name element name | ||
| @param {Object} attrs name/value mapping of element attributes | ||
| @return {HTMLElement} | ||
| @private | ||
| */ | ||
| function createNode(name, attrs) { | ||
| var node = doc.createElement(name), attr; | ||
| for (attr in attrs) { | ||
| if (attrs.hasOwnProperty(attr)) { | ||
| node.setAttribute(attr, attrs[attr]); | ||
| } | ||
| } | ||
| return node; | ||
| } | ||
| /** | ||
| Called when the current pending resource of the specified type has finished | ||
| loading. Executes the associated callback (if any) and loads the next | ||
| resource in the queue. | ||
| @method finish | ||
| @param {String} type resource type ('css' or 'js') | ||
| @private | ||
| */ | ||
| function finish(type) { | ||
| var p = pending[type], | ||
| callback, | ||
| urls; | ||
| if (p) { | ||
| callback = p.callback; | ||
| urls = p.urls; | ||
| urls.shift(); | ||
| pollCount = 0; | ||
| // If this is the last of the pending URLs, execute the callback and | ||
| // start the next request in the queue (if any). | ||
| if (!urls.length) { | ||
| callback && callback.call(p.context, p.obj); | ||
| pending[type] = null; | ||
| queue[type].length && load(type); | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| Populates the <code>env</code> variable with user agent and feature test | ||
| information. | ||
| @method getEnv | ||
| @private | ||
| */ | ||
| function getEnv() { | ||
| var ua = navigator.userAgent; | ||
| env = { | ||
| // True if this browser supports disabling async mode on dynamically | ||
| // created script nodes. See | ||
| // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order | ||
| async: doc.createElement('script').async === true | ||
| }; | ||
| (env.webkit = /AppleWebKit\//.test(ua)) | ||
| || (env.ie = /MSIE|Trident/.test(ua)) | ||
| || (env.opera = /Opera/.test(ua)) | ||
| || (env.gecko = /Gecko\//.test(ua)) | ||
| || (env.unknown = true); | ||
| } | ||
| /** | ||
| Loads the specified resources, or the next resource of the specified type | ||
| in the queue if no resources are specified. If a resource of the specified | ||
| type is already being loaded, the new request will be queued until the | ||
| first request has been finished. | ||
| When an array of resource URLs is specified, those URLs will be loaded in | ||
| parallel if it is possible to do so while preserving execution order. All | ||
| browsers support parallel loading of CSS, but only Firefox and Opera | ||
| support parallel loading of scripts. In other browsers, scripts will be | ||
| queued and loaded one at a time to ensure correct execution order. | ||
| @method load | ||
| @param {String} type resource type ('css' or 'js') | ||
| @param {String|Array} urls (optional) URL or array of URLs to load | ||
| @param {Function} callback (optional) callback function to execute when the | ||
| resource is loaded | ||
| @param {Object} obj (optional) object to pass to the callback function | ||
| @param {Object} context (optional) if provided, the callback function will | ||
| be executed in this object's context | ||
| @private | ||
| */ | ||
| function load(type, urls, callback, obj, context) { | ||
| var _finish = function () { finish(type); }, | ||
| isCSS = type === 'css', | ||
| nodes = [], | ||
| i, len, node, p, pendingUrls, url; | ||
| env || getEnv(); | ||
| if (urls) { | ||
| // If urls is a string, wrap it in an array. Otherwise assume it's an | ||
| // array and create a copy of it so modifications won't be made to the | ||
| // original. | ||
| urls = typeof urls === 'string' ? [urls] : urls.concat(); | ||
| // Create a request object for each URL. If multiple URLs are specified, | ||
| // the callback will only be executed after all URLs have been loaded. | ||
| // | ||
| // Sadly, Firefox and Opera are the only browsers capable of loading | ||
| // scripts in parallel while preserving execution order. In all other | ||
| // browsers, scripts must be loaded sequentially. | ||
| // | ||
| // All browsers respect CSS specificity based on the order of the link | ||
| // elements in the DOM, regardless of the order in which the stylesheets | ||
| // are actually downloaded. | ||
| if (isCSS || env.async || env.gecko || env.opera) { | ||
| // Load in parallel. | ||
| queue[type].push({ | ||
| urls : urls, | ||
| callback: callback, | ||
| obj : obj, | ||
| context : context | ||
| }); | ||
| } else { | ||
| // Load sequentially. | ||
| for (i = 0, len = urls.length; i < len; ++i) { | ||
| queue[type].push({ | ||
| urls : [urls[i]], | ||
| callback: i === len - 1 ? callback : null, // callback is only added to the last URL | ||
| obj : obj, | ||
| context : context | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| // If a previous load request of this type is currently in progress, we'll | ||
| // wait our turn. Otherwise, grab the next item in the queue. | ||
| if (pending[type] || !(p = pending[type] = queue[type].shift())) { | ||
| return; | ||
| } | ||
| head || (head = doc.head || doc.getElementsByTagName('head')[0]); | ||
| pendingUrls = p.urls.concat(); | ||
| for (i = 0, len = pendingUrls.length; i < len; ++i) { | ||
| url = pendingUrls[i]; | ||
| if (isCSS) { | ||
| node = env.gecko ? createNode('style') : createNode('link', { | ||
| href: url, | ||
| rel : 'stylesheet' | ||
| }); | ||
| } else { | ||
| node = createNode('script', {src: url}); | ||
| node.async = false; | ||
| } | ||
| node.className = 'lazyload'; | ||
| node.setAttribute('charset', 'utf-8'); | ||
| if (env.ie && !isCSS && 'onreadystatechange' in node && !('draggable' in node)) { | ||
| node.onreadystatechange = function () { | ||
| if (/loaded|complete/.test(node.readyState)) { | ||
| node.onreadystatechange = null; | ||
| _finish(); | ||
| } | ||
| }; | ||
| } else if (isCSS && (env.gecko || env.webkit)) { | ||
| // Gecko and WebKit don't support the onload event on link nodes. | ||
| if (env.webkit) { | ||
| // In WebKit, we can poll for changes to document.styleSheets to | ||
| // figure out when stylesheets have loaded. | ||
| p.urls[i] = node.href; // resolve relative URLs (or polling won't work) | ||
| pollWebKit(); | ||
| } else { | ||
| // In Gecko, we can import the requested URL into a <style> node and | ||
| // poll for the existence of node.sheet.cssRules. Props to Zach | ||
| // Leatherman for calling my attention to this technique. | ||
| node.innerHTML = '@import "' + url + '";'; | ||
| pollGecko(node); | ||
| } | ||
| } else { | ||
| node.onload = node.onerror = _finish; | ||
| } | ||
| nodes.push(node); | ||
| } | ||
| for (i = 0, len = nodes.length; i < len; ++i) { | ||
| head.appendChild(nodes[i]); | ||
| } | ||
| } | ||
| /** | ||
| Begins polling to determine when the specified stylesheet has finished loading | ||
| in Gecko. Polling stops when all pending stylesheets have loaded or after 10 | ||
| seconds (to prevent stalls). | ||
| Thanks to Zach Leatherman for calling my attention to the @import-based | ||
| cross-domain technique used here, and to Oleg Slobodskoi for an earlier | ||
| same-domain implementation. See Zach's blog for more details: | ||
| http://www.zachleat.com/web/2010/07/29/load-css-dynamically/ | ||
| @method pollGecko | ||
| @param {HTMLElement} node Style node to poll. | ||
| @private | ||
| */ | ||
| function pollGecko(node) { | ||
| var hasRules; | ||
| try { | ||
| // We don't really need to store this value or ever refer to it again, but | ||
| // if we don't store it, Closure Compiler assumes the code is useless and | ||
| // removes it. | ||
| hasRules = !!node.sheet.cssRules; | ||
| } catch (ex) { | ||
| // An exception means the stylesheet is still loading. | ||
| pollCount += 1; | ||
| if (pollCount < 200) { | ||
| setTimeout(function () { pollGecko(node); }, 50); | ||
| } else { | ||
| // We've been polling for 10 seconds and nothing's happened. Stop | ||
| // polling and finish the pending requests to avoid blocking further | ||
| // requests. | ||
| hasRules && finish('css'); | ||
| } | ||
| return; | ||
| } | ||
| // If we get here, the stylesheet has loaded. | ||
| finish('css'); | ||
| } | ||
| /** | ||
| Begins polling to determine when pending stylesheets have finished loading | ||
| in WebKit. Polling stops when all pending stylesheets have loaded or after 10 | ||
| seconds (to prevent stalls). | ||
| @method pollWebKit | ||
| @private | ||
| */ | ||
| function pollWebKit() { | ||
| var css = pending.css, i; | ||
| if (css) { | ||
| i = styleSheets.length; | ||
| // Look for a stylesheet matching the pending URL. | ||
| while (--i >= 0) { | ||
| if (styleSheets[i].href === css.urls[0]) { | ||
| finish('css'); | ||
| break; | ||
| } | ||
| } | ||
| pollCount += 1; | ||
| if (css) { | ||
| if (pollCount < 200) { | ||
| setTimeout(pollWebKit, 50); | ||
| } else { | ||
| // We've been polling for 10 seconds and nothing's happened, which may | ||
| // indicate that the stylesheet has been removed from the document | ||
| // before it had a chance to load. Stop polling and finish the pending | ||
| // request to prevent blocking further requests. | ||
| finish('css'); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return { | ||
| /** | ||
| Requests the specified CSS URL or URLs and executes the specified | ||
| callback (if any) when they have finished loading. If an array of URLs is | ||
| specified, the stylesheets will be loaded in parallel and the callback | ||
| will be executed after all stylesheets have finished loading. | ||
| @method css | ||
| @param {String|Array} urls CSS URL or array of CSS URLs to load | ||
| @param {Function} callback (optional) callback function to execute when | ||
| the specified stylesheets are loaded | ||
| @param {Object} obj (optional) object to pass to the callback function | ||
| @param {Object} context (optional) if provided, the callback function | ||
| will be executed in this object's context | ||
| @static | ||
| */ | ||
| css: function (urls, callback, obj, context) { | ||
| load('css', urls, callback, obj, context); | ||
| }, | ||
| /** | ||
| Requests the specified JavaScript URL or URLs and executes the specified | ||
| callback (if any) when they have finished loading. If an array of URLs is | ||
| specified and the browser supports it, the scripts will be loaded in | ||
| parallel and the callback will be executed after all scripts have | ||
| finished loading. | ||
| Currently, only Firefox and Opera support parallel loading of scripts while | ||
| preserving execution order. In other browsers, scripts will be | ||
| queued and loaded one at a time to ensure correct execution order. | ||
| @method js | ||
| @param {String|Array} urls JS URL or array of JS URLs to load | ||
| @param {Function} callback (optional) callback function to execute when | ||
| the specified scripts are loaded | ||
| @param {Object} obj (optional) object to pass to the callback function | ||
| @param {Object} context (optional) if provided, the callback function | ||
| will be executed in this object's context | ||
| @static | ||
| */ | ||
| js: function (urls, callback, obj, context) { | ||
| load('js', urls, callback, obj, context); | ||
| } | ||
| }; | ||
| })(this.document); |
+6
-6
@@ -5,8 +5,8 @@ { | ||
| "dependencies" : { | ||
| "jquery": "latest", | ||
| "jquery.timers": "patryk/jquery.timers", | ||
| "jquery.hasparent": "valeriansaliou/jquery.hasparent", | ||
| "jquery.ui": "latest", | ||
| "lazyload": "rgrove/lazyload", | ||
| "console": "valeriansaliou/console.js" | ||
| "jquery": "http://code.jquery.com/jquery-2.1.4.js", | ||
| "jquery.timers": "https://raw.githubusercontent.com/patryk/jquery.timers/3d21ef5c71579cff5d71914458ee6717b7c31a1c/jquery.timers.js", | ||
| "jquery.hasparent": "https://raw.githubusercontent.com/valeriansaliou/jquery.hasparent/c4fb344f5f07f3a321313c325fcda219fe9b4253/jquery.hasparent.js", | ||
| "jquery.ui-effect": "https://raw.githubusercontent.com/jquery/jquery-ui/f7ee8524b3371663b2484299036c5e14363d5b71/ui/effect.js", | ||
| "lazyload": "https://raw.githubusercontent.com/rgrove/lazyload/df0c1c32096ff247de931dd1bf53d8a014636d7f/lazyload.js", | ||
| "console": "https://raw.githubusercontent.com/valeriansaliou/console.js/3b3cb748550c052424bc963c6ee7465c3e2117cd/console.js" | ||
| }, | ||
@@ -13,0 +13,0 @@ |
@@ -13,9 +13,19 @@ /* | ||
| var fn_change_event = function() { | ||
| var color_select_sel = $('select[name="progressio_color"]'); | ||
| color_select_sel.change(function() { | ||
| PROGRESSIO_INSTANCE.color( | ||
| color_select_sel.val() | ||
| ); | ||
| }); | ||
| }; | ||
| // Launch Progressio | ||
| $(document).ready(function() { | ||
| var color_select_sel = $('select[name="progressio_color"]'); | ||
| // Apply Progressio | ||
| PROGRESSIO_INSTANCE = (new Progressio({ | ||
| color: color_select_sel.val(), | ||
| color: $('select[name="progressio_color"]').val(), | ||
@@ -46,7 +56,8 @@ fixed: true, | ||
| // Change Progressio bar color | ||
| color_select_sel.change(function() { | ||
| PROGRESSIO_INSTANCE.color( | ||
| color_select_sel.val() | ||
| ); | ||
| }); | ||
| fn_change_event(); | ||
| // Register change event restore | ||
| PROGRESSIO_INSTANCE.register_event( | ||
| "simple:fn_change_event", fn_change_event, this, true | ||
| ); | ||
| }); |
+6
-20
@@ -24,3 +24,2 @@ /* | ||
| var GRUNT_TASKS_BUILD_COMMON = [ | ||
| 'shell', | ||
| 'coffee', | ||
@@ -105,8 +104,8 @@ 'compass', | ||
| var GRUNT_LIBRARY_FILES = [ | ||
| ENV_PATHS.libraries + '/jquery/jquery.js', | ||
| ENV_PATHS.libraries + '/jquery.timers/jquery.timers.js', | ||
| ENV_PATHS.libraries + '/jquery.hasparent/jquery.hasparent.js', | ||
| ENV_PATHS.libraries + '/jquery.ui/dist/jquery-ui.js', | ||
| ENV_PATHS.libraries + '/lazyload/lazyload.js', | ||
| ENV_PATHS.libraries + '/console/console.js', | ||
| ENV_PATHS.libraries + '/jquery/index.js', | ||
| ENV_PATHS.libraries + '/jquery.timers/index.js', | ||
| ENV_PATHS.libraries + '/jquery.hasparent/index.js', | ||
| ENV_PATHS.libraries + '/jquery.ui-effect/index.js', | ||
| ENV_PATHS.libraries + '/lazyload/index.js', | ||
| ENV_PATHS.libraries + '/console/index.js', | ||
| ]; | ||
@@ -522,14 +521,2 @@ | ||
| // Task: Shell | ||
| shell: { | ||
| make_jqueryui: { | ||
| options: { | ||
| stderr: false | ||
| }, | ||
| command: ('cd ' + ENV_PATHS.libraries + '/jquery.ui && npm install && grunt concat') | ||
| } | ||
| }, | ||
| // Task: Banner | ||
@@ -622,3 +609,2 @@ usebanner: { | ||
| grunt.loadNpmTasks('grunt-banner'); | ||
| grunt.loadNpmTasks('grunt-shell'); | ||
| grunt.loadNpmTasks('grunt-contrib-cssmin'); | ||
@@ -625,0 +611,0 @@ grunt.loadNpmTasks('grunt-contrib-uglify'); |
+1
-2
| { | ||
| "name": "progressio", | ||
| "description": "Beautiful & stylish asynchronous page loader. Makes a static website dynamic in a breeze.", | ||
| "version": "0.3.1", | ||
| "version": "1.0.0", | ||
| "homepage": "https://github.com/valeriansaliou/progressio", | ||
@@ -43,3 +43,2 @@ "license": "MPL-2.0", | ||
| "grunt-banner": "0.2.3", | ||
| "grunt-shell": "1.1.1", | ||
| "grunt-contrib-cssmin": "0.10.0", | ||
@@ -46,0 +45,0 @@ "grunt-contrib-uglify": "0.6.0" |
+5
-6
| Progressio | ||
| ========== | ||
| [](https://gitter.im/valeriansaliou/progressio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
| [](https://travis-ci.org/valeriansaliou/progressio) [](https://gitter.im/valeriansaliou/progressio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
@@ -12,12 +12,10 @@ Progressio transforms your static website to a dynamic environment. Pages are loaded asynchronously, with the use of the browser history JavaScript API and a beautiful overlay progress bar. | ||
| [](https://ci.hakuma.holdings/projects/57?ref=master) | ||
| ## Testing Progressio | ||
| ## Demo | ||
| You can test Progressio by opening page: `./examples/simple_1.html`. | ||
| You can test our [online demo of Progressio there](https://demo.hakuma.holdings/valerian.saliou/progressio/examples/simple_1.html). | ||
| **Note: You first need to build Progressio, please refer to the Installation Notes section of this document.** | ||
| _This online demo is the replica of what you can find in the ./examples folder._ | ||
| ## Installation Notes | ||
@@ -30,2 +28,3 @@ | ||
| * [jQuery](https://github.com/jquery/jquery) | ||
| * [jQuery UI Effects](https://github.com/jquery/jquery-ui/blob/master/ui/effect.js) | ||
| * [jQuery Timers](https://github.com/patryk/jquery.timers) | ||
@@ -32,0 +31,0 @@ * [jQuery hasParent](https://github.com/valeriansaliou/jquery.hasparent) |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
849786
1025.86%13
-7.14%33
83.33%21061
3038.75%2
100%148
-0.67%78
Infinity%7
Infinity%