From 337fbf1be951ca3f7bc57355fd2f68cdb1c22bd8 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 17 Dec 2019 14:34:03 +0000 Subject: [PATCH 1/6] Remove unused JS dependency timeago, we use momentjs now --- .../javascripts/shared/jquery.timeago.js | 202 ------------------ config/ng-test.conf.js | 1 - 2 files changed, 203 deletions(-) delete mode 100644 app/assets/javascripts/shared/jquery.timeago.js diff --git a/app/assets/javascripts/shared/jquery.timeago.js b/app/assets/javascripts/shared/jquery.timeago.js deleted file mode 100644 index cecfaeb87d..0000000000 --- a/app/assets/javascripts/shared/jquery.timeago.js +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Timeago is a jQuery plugin that makes it easy to support automatically - * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). - * - * @name timeago - * @version 1.3.1 - * @requires jQuery v1.2.3+ - * @author Ryan McGeary - * @license MIT License - http://www.opensource.org/licenses/mit-license.php - * - * For usage and examples, visit: - * http://timeago.yarp.com/ - * - * Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org) - */ - -(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else { - // Browser globals - factory(jQuery); - } -}(function ($) { - $.timeago = function(timestamp) { - if (timestamp instanceof Date) { - return inWords(timestamp); - } else if (typeof timestamp === "string") { - return inWords($.timeago.parse(timestamp)); - } else if (typeof timestamp === "number") { - return inWords(new Date(timestamp)); - } else { - return inWords($.timeago.datetime(timestamp)); - } - }; - var $t = $.timeago; - - $.extend($.timeago, { - settings: { - refreshMillis: 60000, - allowFuture: false, - localeTitle: false, - cutoff: 0, - strings: { - prefixAgo: null, - prefixFromNow: null, - suffixAgo: "ago", - suffixFromNow: "from now", - seconds: "less than a minute", - minute: "about a minute", - minutes: "%d minutes", - hour: "about an hour", - hours: "about %d hours", - day: "a day", - days: "%d days", - month: "about a month", - months: "%d months", - year: "about a year", - years: "%d years", - wordSeparator: " ", - numbers: [] - } - }, - inWords: function(distanceMillis) { - var $l = this.settings.strings; - var prefix = $l.prefixAgo; - var suffix = $l.suffixAgo; - if (this.settings.allowFuture) { - if (distanceMillis < 0) { - prefix = $l.prefixFromNow; - suffix = $l.suffixFromNow; - } - } - - var seconds = Math.abs(distanceMillis) / 1000; - var minutes = seconds / 60; - var hours = minutes / 60; - var days = hours / 24; - var years = days / 365; - - function substitute(stringOrFunction, number) { - var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; - var value = ($l.numbers && $l.numbers[number]) || number; - return string.replace(/%d/i, value); - } - - var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || - seconds < 90 && substitute($l.minute, 1) || - minutes < 45 && substitute($l.minutes, Math.round(minutes)) || - minutes < 90 && substitute($l.hour, 1) || - hours < 24 && substitute($l.hours, Math.round(hours)) || - hours < 42 && substitute($l.day, 1) || - days < 30 && substitute($l.days, Math.round(days)) || - days < 45 && substitute($l.month, 1) || - days < 365 && substitute($l.months, Math.round(days / 30)) || - years < 1.5 && substitute($l.year, 1) || - substitute($l.years, Math.round(years)); - - var separator = $l.wordSeparator || ""; - if ($l.wordSeparator === undefined) { separator = " "; } - return $.trim([prefix, words, suffix].join(separator)); - }, - parse: function(iso8601) { - var s = $.trim(iso8601); - s = s.replace(/\.\d+/,""); // remove milliseconds - s = s.replace(/-/,"/").replace(/-/,"/"); - s = s.replace(/T/," ").replace(/Z/," UTC"); - s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400 - s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900 - return new Date(s); - }, - datetime: function(elem) { - var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title"); - return $t.parse(iso8601); - }, - isTime: function(elem) { - // jQuery's `is()` doesn't play well with HTML5 in IE - return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time"); - } - }); - - // functions that can be called via $(el).timeago('action') - // init is default when no action is given - // functions are called with context of a single element - var functions = { - init: function(){ - var refresh_el = $.proxy(refresh, this); - refresh_el(); - var $s = $t.settings; - if ($s.refreshMillis > 0) { - this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis); - } - }, - update: function(time){ - var parsedTime = $t.parse(time); - $(this).data('timeago', { datetime: parsedTime }); - if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString()); - refresh.apply(this); - }, - updateFromDOM: function(){ - $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) }); - refresh.apply(this); - }, - dispose: function () { - if (this._timeagoInterval) { - window.clearInterval(this._timeagoInterval); - this._timeagoInterval = null; - } - } - }; - - $.fn.timeago = function(action, options) { - var fn = action ? functions[action] : functions.init; - if(!fn){ - throw new Error("Unknown function name '"+ action +"' for timeago"); - } - // each over objects here and call the requested function - this.each(function(){ - fn.call(this, options); - }); - return this; - }; - - function refresh() { - var data = prepareData(this); - var $s = $t.settings; - - if (!isNaN(data.datetime)) { - if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) { - $(this).text(inWords(data.datetime)); - } - } - return this; - } - - function prepareData(element) { - element = $(element); - if (!element.data("timeago")) { - element.data("timeago", { datetime: $t.datetime(element) }); - var text = $.trim(element.text()); - if ($t.settings.localeTitle) { - element.attr("title", element.data('timeago').datetime.toLocaleString()); - } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) { - element.attr("title", text); - } - } - return element.data("timeago"); - } - - function inWords(date) { - return $t.inWords(distance(date)); - } - - function distance(date) { - return (new Date().getTime() - date.getTime()); - } - - // fix for IE6 suckage - document.createElement("abbr"); - document.createElement("time"); -})); diff --git a/config/ng-test.conf.js b/config/ng-test.conf.js index 13dc997ebd..9309ed4188 100644 --- a/config/ng-test.conf.js +++ b/config/ng-test.conf.js @@ -7,7 +7,6 @@ module.exports = function(config) { files: [ APPLICATION_SPEC, 'app/assets/javascripts/shared/jquery-1.8.0.js', // TODO: Can we link to Rails' jquery? - 'app/assets/javascripts/shared/jquery.timeago.js', 'app/assets/javascripts/shared/angular-local-storage.js', 'app/assets/javascripts/shared/ng-infinite-scroll.min.js', 'app/assets/javascripts/shared/angular-slideables.js', From 2c59b522defb646a663088a8bf10370ae351b920 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 18 Dec 2019 12:59:50 +0000 Subject: [PATCH 2/6] Reorganize admin/all.js in meaningful groups --- app/assets/javascripts/admin/all.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index d5600915d7..4e53a1b1d0 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -5,6 +5,7 @@ // the compiled file. // +// jquery and angular //= require jquery //= require jquery-migrate-min //= require jquery_ujs @@ -14,12 +15,16 @@ //= require angular-resource //= require angular-animate //= require angular-sanitize -//= require admin/spree_backend -//= require admin/spree_paypal_express +//= require angularjs-file-upload //= require ../shared/ng-infinite-scroll.min.js //= require ../shared/ng-tags-input.min.js -//= require moment //= require angular-rails-templates + +// spree +//= require admin/spree_backend +//= require admin/spree_paypal_express + +// OFN specific //= require_tree ../templates/admin //= require ./admin_ofn //= require ./customers/customers @@ -45,6 +50,8 @@ //= require ./utils/utils //= require ./users/users //= require ./variant_overrides/variant_overrides + +// text, dates and translations //= require textAngular-rangy.min.js //= require textAngular-sanitize.min.js //= require textAngular.min.js @@ -60,7 +67,9 @@ //= require moment/pt-br.js //= require moment/pt.js //= require moment/sv.js -//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js -//= require angularjs-file-upload +// foundation +//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js + +// requires the rest of the JS code in this folder //= require_tree . From c59afd49512ea620d8477742c530953d9f9d9187 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 18 Dec 2019 13:06:11 +0000 Subject: [PATCH 3/6] Remove jquery-migrate-1.0.0, we already have jquery-migrate 1.2.1 (jquery-migrate-min) through gemfile jquery-migrate-rails --- .../javascripts/jquery-migrate-1.0.0.js | 498 ------------------ 1 file changed, 498 deletions(-) delete mode 100644 app/assets/javascripts/jquery-migrate-1.0.0.js diff --git a/app/assets/javascripts/jquery-migrate-1.0.0.js b/app/assets/javascripts/jquery-migrate-1.0.0.js deleted file mode 100644 index c374e6ba16..0000000000 --- a/app/assets/javascripts/jquery-migrate-1.0.0.js +++ /dev/null @@ -1,498 +0,0 @@ -/*! - * jQuery Migrate - v1.0.0 - 2013-01-14 - * https://github.com/jquery/jquery-migrate - * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT - */ -(function( jQuery, window, undefined ) { -"use strict"; - - -var warnedAbout = {}; - -// List of warnings already given; public read only -jQuery.migrateWarnings = []; - -// Set to true to prevent console output; migrateWarnings still maintained -jQuery.migrateMute = true; - -// Forget any warnings we've already given; public -jQuery.migrateReset = function() { - warnedAbout = {}; - jQuery.migrateWarnings.length = 0; -}; - -function migrateWarn( msg) { - if ( !warnedAbout[ msg ] ) { - warnedAbout[ msg ] = true; - jQuery.migrateWarnings.push( msg ); - if ( window.console && console.warn && !jQuery.migrateMute ) { - console.warn( "JQMIGRATE: " + msg ); - } - } -} - -function migrateWarnProp( obj, prop, value, msg ) { - if ( Object.defineProperty ) { - // On ES5 browsers (non-oldIE), warn if the code tries to get prop; - // allow property to be overwritten in case some other plugin wants it - try { - Object.defineProperty( obj, prop, { - configurable: true, - enumerable: true, - get: function() { - migrateWarn( msg ); - return value; - }, - set: function( newValue ) { - migrateWarn( msg ); - value = newValue; - } - }); - return; - } catch( err ) { - // IE8 is a dope about Object.defineProperty, can't warn there - } - } - - // Non-ES5 (or broken) browser; just set the property - jQuery._definePropertyBroken = true; - obj[ prop ] = value; -} - -if ( document.compatMode === "BackCompat" ) { - // jQuery has never supported or tested Quirks Mode - migrateWarn( "jQuery is not compatible with Quirks Mode" ); -} - - -var attrFn = {}, - attr = jQuery.attr, - valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || - function() { return null; }, - valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || - function() { return undefined; }, - rnoType = /^(?:input|button)$/i, - rnoAttrNodeType = /^[238]$/, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - ruseDefault = /^(?:checked|selected)$/i; - -// jQuery.attrFn -migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" ); - -jQuery.attr = function( elem, name, value, pass ) { - var lowerName = name.toLowerCase(), - nType = elem && elem.nodeType; - - if ( pass ) { - migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); - if ( elem && !rnoAttrNodeType.test( nType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) { - return jQuery( elem )[ name ]( value ); - } - } - - // Warn if user tries to set `type` since it breaks on IE 6/7/8 - if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) { - migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8"); - } - - // Restore boolHook for boolean property/attribute synchronization - if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) { - jQuery.attrHooks[ lowerName ] = { - get: function( elem, name ) { - // Align boolean attributes with corresponding properties - // Fall back to attribute presence where some booleans are not supported - var attrNode, - property = jQuery.prop( elem, name ); - return property === true || typeof property !== "boolean" && - ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? - - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - var propName; - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if ( propName in elem ) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = true; - } - - elem.setAttribute( name, name.toLowerCase() ); - } - return name; - } - }; - - // Warn only for attributes that can remain distinct from their properties post-1.9 - if ( ruseDefault.test( lowerName ) ) { - migrateWarn( "jQuery.fn.attr(" + lowerName + ") may use property instead of attribute" ); - } - } - - return attr.call( jQuery, elem, name, value ); -}; - -// attrHooks: value -jQuery.attrHooks.value = { - get: function( elem, name ) { - var nodeName = ( elem.nodeName || "" ).toLowerCase(); - if ( nodeName === "button" ) { - return valueAttrGet.apply( this, arguments ); - } - if ( nodeName !== "input" && nodeName !== "option" ) { - migrateWarn("property-based jQuery.fn.attr('value') is deprecated"); - } - return name in elem ? - elem.value : - null; - }, - set: function( elem, value ) { - var nodeName = ( elem.nodeName || "" ).toLowerCase(); - if ( nodeName === "button" ) { - return valueAttrSet.apply( this, arguments ); - } - if ( nodeName !== "input" && nodeName !== "option" ) { - migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated"); - } - // Does not return so that setAttribute is also used - elem.value = value; - } -}; - - -var matched, browser, - oldInit = jQuery.fn.init, - // Note this does NOT include the # XSS fix from 1.7! - rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/; - -// $(html) "looks like html" rule change -jQuery.fn.init = function( selector, context, rootjQuery ) { - var match; - - if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) && - (match = rquickExpr.exec( selector )) && match[1] ) { - // This is an HTML string according to the "old" rules; is it still? - if ( selector.charAt( 0 ) !== "<" ) { - migrateWarn("$(html) HTML strings must start with '<' character"); - } - // Now process using loose rules; let pre-1.8 play too - if ( context && context.context ) { - // jQuery object as context; parseHTML expects a DOM object - context = context.context; - } - if ( jQuery.parseHTML ) { - return oldInit.call( this, jQuery.parseHTML( jQuery.trim(selector), context, true ), - context, rootjQuery ); - } - } - return oldInit.apply( this, arguments ); -}; -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.uaMatch = function( ua ) { - ua = ua.toLowerCase(); - - var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || - /(webkit)[ \/]([\w.]+)/.exec( ua ) || - /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || - /(msie) ([\w.]+)/.exec( ua ) || - ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || - []; - - return { - browser: match[ 1 ] || "", - version: match[ 2 ] || "0" - }; -}; - -matched = jQuery.uaMatch( navigator.userAgent ); -browser = {}; - -if ( matched.browser ) { - browser[ matched.browser ] = true; - browser.version = matched.version; -} - -// Chrome is Webkit, but Webkit is also Safari. -if ( browser.chrome ) { - browser.webkit = true; -} else if ( browser.webkit ) { - browser.safari = true; -} - -jQuery.browser = browser; - -// Warn if the code tries to get jQuery.browser -migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" ); - -jQuery.sub = function() { - function jQuerySub( selector, context ) { - return new jQuerySub.fn.init( selector, context ); - } - jQuery.extend( true, jQuerySub, this ); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { - context = jQuerySub( context ); - } - - return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - migrateWarn( "jQuery.sub() is deprecated" ); - return jQuerySub; -}; - - -var oldFnData = jQuery.fn.data; - -jQuery.fn.data = function( name ) { - var ret, evt, - elem = this[0]; - - // Handles 1.7 which has this behavior and 1.8 which doesn't - if ( elem && name === "events" && arguments.length === 1 ) { - ret = jQuery.data( elem, name ); - evt = jQuery._data( elem, name ); - if ( ( ret === undefined || ret === evt ) && evt !== undefined ) { - migrateWarn("Use of jQuery.fn.data('events') is deprecated"); - return evt; - } - } - return oldFnData.apply( this, arguments ); -}; - - -var rscriptType = /\/(java|ecma)script/i, - oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack, - oldFragment = jQuery.buildFragment; - -jQuery.fn.andSelf = function() { - migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"); - return oldSelf.apply( this, arguments ); -}; - -// Since jQuery.clean is used internally on older versions, we only shim if it's missing -if ( !jQuery.clean ) { - jQuery.clean = function( elems, context, fragment, scripts ) { - // Set context per 1.8 logic - context = context || document; - context = !context.nodeType && context[0] || context; - context = context.ownerDocument || context; - - migrateWarn("jQuery.clean() is deprecated"); - - var i, elem, handleScript, jsTags, - ret = []; - - jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes ); - - // Complex logic lifted directly from jQuery 1.8 - if ( fragment ) { - // Special handling of each script element - handleScript = function( elem ) { - // Check if we consider it executable - if ( !elem.type || rscriptType.test( elem.type ) ) { - // Detach the script and store it in the scripts array (if provided) or the fragment - // Return truthy to indicate that it has been handled - return scripts ? - scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : - fragment.appendChild( elem ); - } - }; - - for ( i = 0; (elem = ret[i]) != null; i++ ) { - // Check if we're done after handling an executable script - if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { - // Append to fragment and handle embedded scripts - fragment.appendChild( elem ); - if ( typeof elem.getElementsByTagName !== "undefined" ) { - // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration - jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); - - // Splice the scripts into ret after their former ancestor and advance our index beyond them - ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); - i += jsTags.length; - } - } - } - } - - return ret; - }; -} - -jQuery.buildFragment = function( elems, context, scripts, selection ) { - var ret, - warning = "jQuery.buildFragment() is deprecated"; - - // Set context per 1.8 logic - context = context || document; - context = !context.nodeType && context[0] || context; - context = context.ownerDocument || context; - - try { - ret = oldFragment.call( jQuery, elems, context, scripts, selection ); - - // jQuery < 1.8 required arrayish context; jQuery 1.9 fails on it - } catch( x ) { - ret = oldFragment.call( jQuery, elems, context.nodeType ? [ context ] : context[ 0 ], scripts, selection ); - - // Success from tweaking context means buildFragment was called by the user - migrateWarn( warning ); - } - - // jQuery < 1.9 returned an object instead of the fragment itself - if ( !ret.fragment ) { - migrateWarnProp( ret, "fragment", ret, warning ); - migrateWarnProp( ret, "cacheable", false, warning ); - } - - return ret; -}; - -var eventAdd = jQuery.event.add, - eventRemove = jQuery.event.remove, - eventTrigger = jQuery.event.trigger, - oldToggle = jQuery.fn.toggle, - oldLive = jQuery.fn.live, - oldDie = jQuery.fn.die, - ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess", - rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ), - rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, - hoverHack = function( events ) { - if ( typeof( events ) != "string" || jQuery.event.special.hover ) { - return events; - } - if ( rhoverHack.test( events ) ) { - migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"); - } - return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); - }; - -// Event props removed in 1.9, put them back if needed; no practical way to warn them -if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) { - jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" ); -} - -// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7 -migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" ); - -// Support for 'hover' pseudo-event and ajax event warnings -jQuery.event.add = function( elem, types, handler, data, selector ){ - if ( elem !== document && rajaxEvent.test( types ) ) { - migrateWarn( "AJAX events should be attached to document: " + types ); - } - eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector ); -}; -jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){ - eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes ); -}; - -jQuery.fn.error = function() { - var args = Array.prototype.slice.call( arguments, 0); - migrateWarn("jQuery.fn.error() is deprecated"); - args.splice( 0, 0, "error" ); - if ( arguments.length ) { - return this.bind.apply( this, args ); - } - // error event should not bubble to window, although it does pre-1.7 - this.triggerHandler.apply( this, args ); - return this; -}; - -jQuery.fn.toggle = function( fn, fn2 ) { - - // Don't mess with animation or css toggles - if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { - return oldToggle.apply( this, arguments ); - } - migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated"); - - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; - - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while ( i < args.length ) { - args[ i++ ].guid = guid; - } - - return this.click( toggler ); -}; - -jQuery.fn.live = function( types, data, fn ) { - migrateWarn("jQuery.fn.live() is deprecated"); - if ( oldLive ) { - return oldLive.apply( this, arguments ); - } - jQuery( this.context ).on( types, this.selector, data, fn ); - return this; -}; - -jQuery.fn.die = function( types, fn ) { - migrateWarn("jQuery.fn.die() is deprecated"); - if ( oldDie ) { - return oldDie.apply( this, arguments ); - } - jQuery( this.context ).off( types, this.selector || "**", fn ); - return this; -}; - -// Turn global events into document-triggered events -jQuery.event.trigger = function( event, data, elem, onlyHandlers ){ - if ( !elem & !rajaxEvent.test( event ) ) { - migrateWarn( "Global events are undocumented and deprecated" ); - } - return eventTrigger.call( this, event, data, elem || document, onlyHandlers ); -}; -jQuery.each( ajaxEvents.split("|"), - function( _, name ) { - jQuery.event.special[ name ] = { - setup: function() { - var elem = this; - - // The document needs no shimming; must be !== for oldIE - if ( elem !== document ) { - jQuery.event.add( document, name + "." + jQuery.guid, function() { - jQuery.event.trigger( name, null, elem, true ); - }); - jQuery._data( this, name, jQuery.guid++ ); - } - return false; - }, - teardown: function() { - if ( this !== document ) { - jQuery.event.remove( document, name + "." + jQuery._data( this, name ) ); - } - return false; - } - }; - } -); - - -})( jQuery, window ); From 0ec39106b1da1ce8eb2800ff733eee841ebbd6ec Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 18 Dec 2019 13:10:00 +0000 Subject: [PATCH 4/6] Bring modernizr from spree_backend --- app/assets/javascripts/admin/all.js | 1 + vendor/assets/javascripts/modernizr.js | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 vendor/assets/javascripts/modernizr.js diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index 4e53a1b1d0..aa0de19dc0 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -22,6 +22,7 @@ // spree //= require admin/spree_backend +//= require modernizr //= require admin/spree_paypal_express // OFN specific diff --git a/vendor/assets/javascripts/modernizr.js b/vendor/assets/javascripts/modernizr.js new file mode 100644 index 0000000000..cc9e511682 --- /dev/null +++ b/vendor/assets/javascripts/modernizr.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.1 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-touch-shiv-teststyles-prefixes-load + */ +;window.Modernizr=function(a,b,c){function v(a){i.cssText=a}function w(a,b){return v(l.join(a+";")+(b||""))}function x(a,b){return typeof a===b}function y(a,b){return!!~(""+a).indexOf(b)}function z(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:x(f,"function")?f.bind(d||b):f}return!1}var d="2.6.1",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l=" -webkit- -moz- -o- -ms- ".split(" "),m={},n={},o={},p=[],q=p.slice,r,s=function(a,c,d,e){var h,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:g+(d+1),k.appendChild(j);return h=["­",'"].join(""),k.id=g,(l?k:m).innerHTML+=h,m.appendChild(k),l||(m.style.background="",f.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},t={}.hasOwnProperty,u;!x(t,"undefined")&&!x(t.call,"undefined")?u=function(a,b){return t.call(a,b)}:u=function(a,b){return b in a&&x(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=q.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(q.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(q.call(arguments)))};return e}),m.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:s(["@media (",l.join("touch-enabled),("),g,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c};for(var A in m)u(m,A)&&(r=A.toLowerCase(),e[r]=m[A](),p.push((e[r]?"":"no-")+r));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)u(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},v(""),h=j=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=l,e.testStyles=s,e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f Date: Wed, 18 Dec 2019 13:12:11 +0000 Subject: [PATCH 5/6] Bring css_browser_selector_dev from spree_backend and respective hacks --- app/assets/javascripts/admin/all.js | 1 + app/assets/stylesheets/admin/all.scss | 6 + .../stylesheets/admin/globals/variables.scss | 148 +++++++++++++++++ app/assets/stylesheets/admin/hacks/ie.scss | 73 ++++++++ .../stylesheets/admin/hacks/mozilla.scss | 32 ++++ app/assets/stylesheets/admin/hacks/opera.scss | 17 ++ .../javascripts/css_browser_selector_dev.js | 156 ++++++++++++++++++ 7 files changed, 433 insertions(+) create mode 100644 app/assets/stylesheets/admin/globals/variables.scss create mode 100644 app/assets/stylesheets/admin/hacks/ie.scss create mode 100644 app/assets/stylesheets/admin/hacks/mozilla.scss create mode 100644 app/assets/stylesheets/admin/hacks/opera.scss create mode 100644 vendor/assets/javascripts/css_browser_selector_dev.js diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index aa0de19dc0..0132f807cc 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -23,6 +23,7 @@ // spree //= require admin/spree_backend //= require modernizr +//= require css_browser_selector_dev //= require admin/spree_paypal_express // OFN specific diff --git a/app/assets/stylesheets/admin/all.scss b/app/assets/stylesheets/admin/all.scss index 757be97cfe..5e42010fab 100644 --- a/app/assets/stylesheets/admin/all.scss +++ b/app/assets/stylesheets/admin/all.scss @@ -13,6 +13,12 @@ *= require_self */ +@import 'globals/variables'; + +@import 'hacks/mozilla'; +@import 'hacks/opera'; +@import 'hacks/ie'; + @import 'variables'; @import 'components/*'; @import 'pages/*'; diff --git a/app/assets/stylesheets/admin/globals/variables.scss b/app/assets/stylesheets/admin/globals/variables.scss new file mode 100644 index 0000000000..d5316cbd26 --- /dev/null +++ b/app/assets/stylesheets/admin/globals/variables.scss @@ -0,0 +1,148 @@ +// ------------------------------------------------------------- +// Variables used in all other files +//-------------------------------------------------------------- + +// Fonts +//-------------------------------------------------------------- +$base-font-family: "Open Sans", "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + +// Colors +//-------------------------------------------------------------- + +// Basic color palette for admin +$color-1: #FFFFFF !default; // White +$color-2: #9FC820 !default; // Green +$color-3: #5498DA !default; // Light Blue +$color-4: #6788A2 !default; // Dark Blue +$color-5: #C60F13 !default; // Red +$color-6: #FF9300 !default; // Yellow + +// Body base colors +$color-body-bg: $color-1 !default; +$color-body-text: $color-4 !default; +$color-headers: $color-4 !default; +$color-link: $color-3 !default; +$color-link-hover: $color-2 !default; +$color-link-active: $color-2 !default; +$color-link-focus: $color-2 !default; +$color-link-visited: $color-3 !default; +$color-border: very-light($color-3, 12) !default; + +// Basic flash colors +$color-success: $color-2 !default; +$color-notice: $color-6 !default; +$color-error: $color-5 !default; + +// Table colors +$color-tbl-odd: $color-1 !default; +$color-tbl-even: very-light($color-3, 4) !default; +$color-tbl-thead: very-light($color-3, 4) !default; + +// Button colors +$color-btn-bg: $color-3 !default; +$color-btn-text: $color-1 !default; +$color-btn-hover-bg: $color-2 !default; +$color-btn-hover-text: $color-1 !default; + +// Actions colors +$color-action-edit-bg: very-light($color-success, 5 ) !default; +$color-action-edit-brd: very-light($color-success, 20 ) !default; +$color-action-clone-bg: very-light($color-notice, 5 ) !default; +$color-action-clone-brd: very-light($color-notice, 15 ) !default; +$color-action-remove-bg: very-light($color-error, 5 ) !default; +$color-action-remove-brd: very-light($color-error, 10 ) !default; +$color-action-void-bg: very-light($color-error, 10 ) !default; +$color-action-void-brd: very-light($color-error, 20 ) !default; +$color-action-cancel-bg: very-light($color-notice, 10 ) !default; +$color-action-cancel-brd: very-light($color-notice, 20 ) !default; +$color-action-capture-bg: very-light($color-success, 5 ) !default; +$color-action-capture-brd: very-light($color-success, 20 ) !default; +$color-action-save-bg: very-light($color-success, 5 ) !default; +$color-action-save-brd: very-light($color-success, 20 ) !default; +$color-action-mail-bg: very-light($color-success, 5 ) !default; +$color-action-mail-brd: very-light($color-success, 20 ) !default; + +// Select2 select field colors +$color-sel-bg: $color-3 !default; +$color-sel-text: $color-1 !default; +$color-sel-hover-bg: $color-2 !default; +$color-sel-hover-text: $color-1 !default; + +// Text inputs colors +$color-txt-brd: $color-border !default; +$color-txt-text: $color-3 !default; +$color-txt-hover-brd: $color-2 !default; + +// States label colors +$color-ste-complete-bg: $color-success !default; +$color-ste-complete-text: $color-1 !default; +$color-ste-completed-bg: $color-success !default; +$color-ste-completed-text: $color-1 !default; +$color-ste-sold-bg: $color-success !default; +$color-ste-sold-text: $color-1 !default; +$color-ste-pending-bg: $color-notice !default; +$color-ste-pending-text: $color-1 !default; +$color-ste-awaiting_return-bg: $color-notice !default; +$color-ste-awaiting_return-text: $color-1 !default; +$color-ste-returned-bg: $color-notice !default; +$color-ste-returned-text: $color-1 !default; +$color-ste-credit_owed-bg: $color-notice !default; +$color-ste-credit_owed-text: $color-1 !default; +$color-ste-paid-bg: $color-success !default; +$color-ste-paid-text: $color-1 !default; +$color-ste-shipped-bg: $color-success !default; +$color-ste-shipped-text: $color-1 !default; +$color-ste-balance_due-bg: $color-notice !default; +$color-ste-balance_due-text: $color-1 !default; +$color-ste-backorder-bg: $color-notice !default; +$color-ste-backorder-text: $color-1 !default; +$color-ste-none-bg: $color-error !default; +$color-ste-none-text: $color-1 !default; +$color-ste-ready-bg: $color-success !default; +$color-ste-ready-text: $color-1 !default; +$color-ste-void-bg: $color-error !default; +$color-ste-void-text: $color-1 !default; +$color-ste-canceled-bg: $color-error !default; +$color-ste-canceled-text: $color-1 !default; +$color-ste-address-bg: $color-error !default; +$color-ste-address-text: $color-1 !default; +$color-ste-checkout-bg: $color-notice !default; +$color-ste-checkout-text: $color-1 !default; +$color-ste-cart-bg: $color-notice !default; +$color-ste-cart-text: $color-1 !default; +$color-ste-payment-bg: $color-error !default; +$color-ste-payment-text: $color-1 !default; +$color-ste-delivery-bg: $color-success !default; +$color-ste-delivery-text: $color-1 !default; +$color-ste-confirm-bg: $color-error !default; +$color-ste-confirm-text: $color-1 !default; +$color-ste-active-bg: $color-success !default; +$color-ste-active-text: $color-1 !default; +$color-ste-inactive-bg: $color-notice !default; +$color-ste-inactive-text: $color-1 !default; + +// Available states +$states: completed, complete, sold, pending, awaiting_return, returned, credit_owed, paid, shipped, balance_due, backorder, checkout, cart, address, delivery, payment, confirm, canceled, ready, void, active, inactive !default; +$states-bg-colors: $color-ste-completed-bg, $color-ste-complete-bg, $color-ste-sold-bg, $color-ste-pending-bg, $color-ste-awaiting_return-bg, $color-ste-returned-bg, $color-ste-credit_owed-bg, $color-ste-paid-bg, $color-ste-shipped-bg, $color-ste-balance_due-bg, $color-ste-backorder-bg, $color-ste-checkout-bg, $color-ste-cart-bg, $color-ste-address-bg, $color-ste-delivery-bg, $color-ste-payment-bg, $color-ste-confirm-bg, $color-ste-canceled-bg, $color-ste-ready-bg, $color-ste-void-bg, $color-ste-active-bg, $color-ste-inactive-bg !default; +$states-text-colors: $color-ste-completed-text, $color-ste-complete-text, $color-ste-sold-text, $color-ste-pending-text, $color-ste-awaiting_return-text, $color-ste-returned-text, $color-ste-credit_owed-text, $color-ste-paid-text, $color-ste-shipped-text, $color-ste-balance_due-text, $color-ste-backorder-text, $color-ste-checkout-text, $color-ste-cart-text, $color-ste-address-text, $color-ste-delivery-text, $color-ste-payment-text, $color-ste-confirm-text, $color-ste-canceled-text, $color-ste-ready-text, $color-ste-void-text, $color-ste-active-text, $color-ste-inactive-text !default; + +// Available actions +$actions: edit, clone, remove, void, capture, save, cancel, mail !default; +$actions-bg-colors: $color-action-edit-bg, $color-action-clone-bg, $color-action-remove-bg, $color-action-void-bg, $color-action-capture-bg, $color-action-save-bg, $color-action-cancel-bg, $color-action-mail-bg !default; +$actions-brd-colors: $color-action-edit-brd, $color-action-clone-brd, $color-action-remove-brd, $color-action-void-brd, $color-action-capture-brd, $color-action-save-brd, $color-action-cancel-brd, $color-action-mail-brd !default; + +// Sizes +//-------------------------------------------------------------- +$body-font-size: 13px !default; + +$h6-size: $body-font-size + 2 !default; +$h5-size: $h6-size + 2 !default; +$h4-size: $h5-size + 2 !default; +$h3-size: $h4-size + 2 !default; +$h2-size: $h3-size + 2 !default; +$h1-size: $h2-size + 2 !default; + +$border-radius: 3px !default; + +$font-weight-bold: 600 !default; +$font-weight-normal: 400 !default; diff --git a/app/assets/stylesheets/admin/hacks/ie.scss b/app/assets/stylesheets/admin/hacks/ie.scss new file mode 100644 index 0000000000..15fc1f2601 --- /dev/null +++ b/app/assets/stylesheets/admin/hacks/ie.scss @@ -0,0 +1,73 @@ +// IE general hacks +html.ie { + + // Properly align icons in circle + table td.actions .no-text.icon-edit { + padding-top: 3px !important; + } + table td.actions .no-text.icon-envelope-alt { + padding-top: 4px !important; + } + + // Fix select2 background gradient. (It uses filter gradients for IE) + .select2-choice, .select2-choice div, + .select2-container-multi .select2-search-choice, + .select2-container:hover .select2-choice, + .select2-container.select2-container-active .select2-choice { + filter: none; + } + .select2-search { + &:before { + position: relative; + z-index: 10000; + content: '\f002' !important; + } + input { + position: relative; + z-index: 0; + } + } + + // Fix margin-top for destroy paperclip styles background + .destroy_new_attachment_styles { + margin-top: 17px !important; + } +} + +// IE8 Hacks +html.ie8 { + + // Fix italic font + body { + font-style: normal; + } + + // Fix white border around filter-actions + .filter-actions { + margin-bottom: -45px; + + button, .button, input[type="submit"], input[type="button"], span.or { + border: 15px solid $color-1; + } + span.or { + border-width: 5px; + margin-left: -10px; + margin-right: -10px; + } + } + + // Fix legend align center + legend { + display: table; + } + + // Sidebar align with fieldsets + #sidebar { + margin-top: 27px; + + .sidebar-title span { + margin-left: 7px; + } + } + +} \ No newline at end of file diff --git a/app/assets/stylesheets/admin/hacks/mozilla.scss b/app/assets/stylesheets/admin/hacks/mozilla.scss new file mode 100644 index 0000000000..a3e37cfacc --- /dev/null +++ b/app/assets/stylesheets/admin/hacks/mozilla.scss @@ -0,0 +1,32 @@ +html.firefox { + + // Fix sidebar margin + #sidebar { + margin-top: 18px; + } + + // Properly align icons in circle + table td.actions .no-text.icon-edit { + padding-left: 1px; + } + + // Fix select2 tag input size + input.select2-input { + padding: 0px 10px !important; + } + + // Fix select2 tag input container padding + .select2-container-multi .select2-choices { + padding-bottom: 0 !important; + } + + // Fix select2 search input left padding to not overlap search icon + .select2-search input.select2-input { + padding-left: 25px !important; + } + + // Fix image file upload width + input#image_attachment { + width: 80%; + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/admin/hacks/opera.scss b/app/assets/stylesheets/admin/hacks/opera.scss new file mode 100644 index 0000000000..af8c878ec2 --- /dev/null +++ b/app/assets/stylesheets/admin/hacks/opera.scss @@ -0,0 +1,17 @@ +html.opera { + + // Fix legend center align + legend { + margin: 0 auto; + } + + // Properly align icons in circle + table td.actions .no-text.icon-edit { + padding-left: 1px; + } + + // Fix sidebar margin + #sidebar { + margin-top: 18px; + } +} \ No newline at end of file diff --git a/vendor/assets/javascripts/css_browser_selector_dev.js b/vendor/assets/javascripts/css_browser_selector_dev.js new file mode 100644 index 0000000000..3fddee52fe --- /dev/null +++ b/vendor/assets/javascripts/css_browser_selector_dev.js @@ -0,0 +1,156 @@ +/* +CSS Browser Selector 0.6.1 +Originally written by Rafael Lima (http://rafael.adm.br) +http://rafael.adm.br/css_browser_selector +License: http://creativecommons.org/licenses/by/2.5/ + +Co-maintained by: +https://github.com/verbatim/css_browser_selector + +*/ + +showLog=true; +function log(m) {if ( window.console && showLog ) {console.log(m); } } + +function css_browser_selector(u) + { + var uaInfo = {}, + screens = [320, 480, 640, 768, 1024, 1152, 1280, 1440, 1680, 1920, 2560], + allScreens = screens.length, + ua=u.toLowerCase(), + is=function(t) { return RegExp(t,"i").test(ua); }, + version = function(p,n) + { + n=n.replace(".","_"); var i = n.indexOf('_'), ver=""; + while (i>0) {ver += " "+ p+n.substring(0,i);i = n.indexOf('_', i+1);} + ver += " "+p+n; return ver; + }, + g='gecko', + w='webkit', + c='chrome', + f='firefox', + s='safari', + o='opera', + m='mobile', + a='android', + bb='blackberry', + lang='lang_', + dv='device_', + html=document.documentElement, + b= [ + + // browser + (!(/opera|webtv/i.test(ua))&&/msie\s(\d+)/.test(ua))?('ie ie'+(/trident\/4\.0/.test(ua) ? '8' : RegExp.$1)) + :is('firefox/')?g+ " " + f+(/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+f+RegExp.$2 + ' '+f+RegExp.$2+"_"+RegExp.$4:'') + :is('gecko/')?g + :is('opera')?o+(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+o+RegExp.$2 + ' '+o+RegExp.$2+"_"+RegExp.$4 : (/opera(\s|\/)(\d+)\.(\d+)/.test(ua)?' '+o+RegExp.$2+" "+o+RegExp.$2+"_"+RegExp.$3:'')) + :is('konqueror')?'konqueror' + + :is('blackberry') ? + ( bb + + ( /Version\/(\d+)(\.(\d+)+)/i.test(ua) + ? " " + bb+ RegExp.$1 + " "+bb+ RegExp.$1+RegExp.$2.replace('.','_') + : (/Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua) + ? ' ' +bb+RegExp.$2 + (RegExp.$3?' ' +bb+RegExp.$2+RegExp.$3:'') + : '') + ) + ) // blackberry + + :is('android') ? + ( a + + ( /Version\/(\d+)(\.(\d+))+/i.test(ua) + ? " " + a+ RegExp.$1 + " "+a+ RegExp.$1+RegExp.$2.replace('.','_') + : '') + + (/Android (.+); (.+) Build/i.test(ua) + ? ' '+dv+( (RegExp.$2).replace(/ /g,"_") ).replace(/-/g,"_") + :'' ) + ) //android + + :is('chrome')?w+ ' '+c+(/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+c+RegExp.$2 +((RegExp.$4>0) ? ' '+c+RegExp.$2+"_"+RegExp.$4:''):'') + + :is('iron')?w+' iron' + + :is('applewebkit/') ? + ( w+ ' '+ s + + ( /version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) + ? ' '+ s +RegExp.$2 + " "+s+ RegExp.$2+RegExp.$3.replace('.','_') + : ( / Safari\/(\d+)/i.test(ua) + ? + ( (RegExp.$1=="419" || RegExp.$1=="417" || RegExp.$1=="416" || RegExp.$1=="412" ) ? ' '+ s + '2_0' + : RegExp.$1=="312" ? ' '+ s + '1_3' + : RegExp.$1=="125" ? ' '+ s + '1_2' + : RegExp.$1=="85" ? ' '+ s + '1_0' + : '' ) + :'') + ) + ) //applewebkit + + :is('mozilla/')?g + :'' + + // mobile + ,is("android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk")?m:'' + + // os/platform + ,is('j2me')?'j2me' + :is('ipad|ipod|iphone')? + ( + ( + /CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? + 'ios' + version('ios',RegExp.$2) : '' + ) + ' ' + ( /(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : "" ) + ) //'iphone' + //:is('ipod')?'ipod' + //:is('ipad')?'ipad' + :is('playbook')?'playbook' + :is('kindle|silk')?'kindle' + :is('playbook')?'playbook' + :is('mac')?'mac'+ (/mac os x ((\d+)[.|_](\d+))/.test(ua) ? ( ' mac' + (RegExp.$2) + ' mac' + (RegExp.$1).replace('.',"_") ) : '' ) + :is('win')?'win'+ + (is('windows nt 6.2')?' win8' + :is('windows nt 6.1')?' win7' + :is('windows nt 6.0')?' vista' + :is('windows nt 5.2') || is('windows nt 5.1') ? ' win_xp' + :is('windows nt 5.0')?' win_2k' + :is('windows nt 4.0') || is('WinNT4.0') ?' win_nt' + : '' + ) + :is('freebsd')?'freebsd' + :(is('x11|linux'))?'linux' + :'' + + // user agent language + ,(/[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua))?(lang+RegExp.$2).replace("-","_")+(RegExp.$3!=''?(' '+lang+RegExp.$1).replace("-","_"):''):'' + + // beta: test if running iPad app + ,( is('ipad|iphone|ipod') && !is('safari') ) ? 'ipad_app' : '' + + + ]; // b + + function screenSize() + { + var w = window.outerWidth || html.clientWidth; + var h = window.outerHeight || html.clientHeight; + uaInfo.orientation = ((w=0;i--) { if (w >= screens[i] ) { uaInfo.maxw = screens[i]; break; }} + widthClasses=""; + for (var info in uaInfo) { widthClasses+=" "+info+"_"+ uaInfo[info] }; + html.className = ( html.className +widthClasses ); + return widthClasses; + } // screenSize + + window.onresize = screenSize; + screenSize(); + + var cssbs = (b.join(' ')) + " js "; + html.className = ( cssbs + html.className.replace(/\b(no[-|_]?)?js\b/g,"") ).replace(/^ /, "").replace(/ +/g," "); + + return cssbs; + } + +css_browser_selector(navigator.userAgent); + + From 904c85c5be86310868511fe2f269bd268305a9cd Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 23 Jan 2020 19:01:52 +0000 Subject: [PATCH 6/6] Move css import to ie hacks file where it's needed --- app/assets/stylesheets/admin/all.scss | 2 -- app/assets/stylesheets/admin/hacks/ie.scss | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/admin/all.scss b/app/assets/stylesheets/admin/all.scss index 5e42010fab..6a683a6ec1 100644 --- a/app/assets/stylesheets/admin/all.scss +++ b/app/assets/stylesheets/admin/all.scss @@ -13,8 +13,6 @@ *= require_self */ -@import 'globals/variables'; - @import 'hacks/mozilla'; @import 'hacks/opera'; @import 'hacks/ie'; diff --git a/app/assets/stylesheets/admin/hacks/ie.scss b/app/assets/stylesheets/admin/hacks/ie.scss index 15fc1f2601..ba5cd61501 100644 --- a/app/assets/stylesheets/admin/hacks/ie.scss +++ b/app/assets/stylesheets/admin/hacks/ie.scss @@ -1,3 +1,5 @@ +@import 'admin/globals/variables'; + // IE general hacks html.ie {