View | Details | Raw Unified | Return to bug 35638
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-1 / +1 lines)
Lines 1024-1030 Link Here
1024
1024
1025
                        <h2>Enquire.js</h2>
1025
                        <h2>Enquire.js</h2>
1026
                        <p>
1026
                        <p>
1027
                            <a href="https://wicky.nillia.ms/enquire.js">Enquire.js v2.0.1</a>:  <a href="https://github.com/WickyNilliams/enquire.js/blob/master/LICENSE">MIT License</a>
1027
                            <a href="https://wicky.nillia.ms/enquire.js">Enquire.js v2.1.6</a>:  <a href="https://github.com/WickyNilliams/enquire.js/blob/v2.1.6/LICENSE">MIT License</a>
1028
                        </p>
1028
                        </p>
1029
1029
1030
                        <h2>FamFamFam icons</h2>
1030
                        <h2>FamFamFam icons</h2>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-1 / +1 lines)
Lines 138-144 Link Here
138
[% Asset.js("lib/jquery/jquery-migrate-3.3.2.min.js") | $raw %]
138
[% Asset.js("lib/jquery/jquery-migrate-3.3.2.min.js") | $raw %]
139
[% Asset.js("lib/bootstrap/js/bootstrap.bundle.min.js") | $raw %]
139
[% Asset.js("lib/bootstrap/js/bootstrap.bundle.min.js") | $raw %]
140
[% Asset.js("lib/fontfaceobserver.min.js") | $raw %]
140
[% Asset.js("lib/fontfaceobserver.min.js") | $raw %]
141
[% Asset.js("lib/enquire.min.js") | $raw %]
141
[% Asset.js("lib/enquire/enquire.min.js") | $raw %]
142
<script>
142
<script>
143
    let logged_in_user_id = "[% logged_in_user.borrowernumber | html %]";
143
    let logged_in_user_id = "[% logged_in_user.borrowernumber | html %]";
144
</script>
144
</script>
(-)a/koha-tmpl/opac-tmpl/lib/enquire.js (-279 lines)
Lines 1-279 Link Here
1
// enquire.js v2.0.1 - Awesome Media Queries in JavaScript
2
// Copyright (c) 2013 Nick Williams - http://wicky.nillia.ms/enquire.js
3
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
4
5
;(function(global) {
6
7
    'use strict';
8
9
    var matchMedia = global.matchMedia;
10
    /*jshint -W098 */
11
    /**
12
     * Helper function for iterating over a collection
13
     *
14
     * @param collection
15
     * @param fn
16
     */
17
    function each(collection, fn) {
18
        var i      = 0,
19
            length = collection.length,
20
            cont;
21
22
        for(i; i < length; i++) {
23
            cont = fn(collection[i], i);
24
            if(cont === false) {
25
                break; //allow early exit
26
            }
27
        }
28
    }
29
30
    /**
31
     * Helper function for determining whether target object is an array
32
     *
33
     * @param target the object under test
34
     * @return {Boolean} true if array, false otherwise
35
     */
36
    function isArray(target) {
37
        return Object.prototype.toString.apply(target) === '[object Array]';
38
    }
39
40
    /**
41
     * Helper function for determining whether target object is a function
42
     *
43
     * @param target the object under test
44
     * @return {Boolean} true if function, false otherwise
45
     */
46
    function isFunction(target) {
47
        return typeof target === 'function';
48
    }
49
50
    /**
51
     * Delegate to handle a media query being matched and unmatched.
52
     *
53
     * @param {object} options
54
     * @param {function} options.match callback for when the media query is matched
55
     * @param {function} [options.unmatch] callback for when the media query is unmatched
56
     * @param {function} [options.setup] one-time callback triggered the first time a query is matched
57
     * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched?
58
     * @constructor
59
     */
60
    function QueryHandler(options) {
61
        this.options = options;
62
        !options.deferSetup && this.setup();
63
    }
64
    QueryHandler.prototype = {
65
66
        /**
67
         * coordinates setup of the handler
68
         *
69
         * @function
70
         */
71
        setup : function() {
72
            if(this.options.setup) {
73
                this.options.setup();
74
            }
75
            this.initialised = true;
76
        },
77
78
        /**
79
         * coordinates setup and triggering of the handler
80
         *
81
         * @function
82
         */
83
        on : function() {
84
            !this.initialised && this.setup();
85
            this.options.match && this.options.match();
86
        },
87
88
        /**
89
         * coordinates the unmatch event for the handler
90
         *
91
         * @function
92
         */
93
        off : function() {
94
            this.options.unmatch && this.options.unmatch();
95
        },
96
97
        /**
98
         * called when a handler is to be destroyed.
99
         * delegates to the destroy or unmatch callbacks, depending on availability.
100
         *
101
         * @function
102
         */
103
        destroy : function() {
104
            this.options.destroy ? this.options.destroy() : this.off();
105
        },
106
107
        /**
108
         * determines equality by reference.
109
         * if object is supplied compare options, if function, compare match callback
110
         *
111
         * @function
112
         * @param {object || function} [target] the target for comparison
113
         */
114
        equals : function(target) {
115
            return this.options === target || this.options.match === target;
116
        }
117
118
    };
119
/**
120
 * Represents a single media query, manages it's state and registered handlers for this query
121
 *
122
 * @constructor
123
 * @param {string} query the media query string
124
 * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design
125
 */
126
function MediaQuery(query, isUnconditional) {
127
    this.query = query;
128
    this.isUnconditional = isUnconditional;
129
    this.handlers = [];
130
    this.mql = matchMedia(query);
131
132
    var self = this;
133
    this.listener = function(mql) {
134
        self.mql = mql;
135
        self.assess();
136
    };
137
    this.mql.addListener(this.listener);
138
}
139
MediaQuery.prototype = {
140
141
    /**
142
     * add a handler for this query, triggering if already active
143
     *
144
     * @param {object} handler
145
     * @param {function} handler.match callback for when query is activated
146
     * @param {function} [handler.unmatch] callback for when query is deactivated
147
     * @param {function} [handler.setup] callback for immediate execution when a query handler is registered
148
     * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?
149
     */
150
    addHandler : function(handler) {
151
        var qh = new QueryHandler(handler);
152
        this.handlers.push(qh);
153
154
        this.matches() && qh.on();
155
    },
156
157
    /**
158
     * removes the given handler from the collection, and calls it's destroy methods
159
     *
160
     * @param {object || function} handler the handler to remove
161
     */
162
    removeHandler : function(handler) {
163
        var handlers = this.handlers;
164
        each(handlers, function(h, i) {
165
            if(h.equals(handler)) {
166
                h.destroy();
167
                return !handlers.splice(i,1); //remove from array and exit each early
168
            }
169
        });
170
    },
171
172
    /**
173
     * Determine whether the media query should be considered a match
174
     *
175
     * @return {Boolean} true if media query can be considered a match, false otherwise
176
     */
177
    matches : function() {
178
        return this.mql.matches || this.isUnconditional;
179
    },
180
181
    /**
182
     * Clears all handlers and unbinds events
183
     */
184
    clear : function() {
185
        each(this.handlers, function(handler) {
186
            handler.destroy();
187
        });
188
        this.mql.removeListener(this.listener);
189
        this.handlers.length = 0; //clear array
190
    },
191
192
    /*
193
     * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match
194
     */
195
    assess : function() {
196
        var action = this.matches() ? 'on' : 'off';
197
198
        each(this.handlers, function(handler) {
199
            handler[action]();
200
        });
201
    }
202
};
203
    /**
204
     * Allows for registration of query handlers.
205
     * Manages the query handler's state and is responsible for wiring up browser events
206
     *
207
     * @constructor
208
     */
209
    function MediaQueryDispatch () {
210
        if(!matchMedia) {
211
            throw new Error('matchMedia not present, legacy browsers require a polyfill');
212
        }
213
214
        this.queries = {};
215
        this.browserIsIncapable = !matchMedia('only all').matches;
216
    }
217
218
    MediaQueryDispatch.prototype = {
219
220
        /**
221
         * Registers a handler for the given media query
222
         *
223
         * @param {string} q the media query
224
         * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers
225
         * @param {function} options.match fired when query matched
226
         * @param {function} [options.unmatch] fired when a query is no longer matched
227
         * @param {function} [options.setup] fired when handler first triggered
228
         * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched
229
         * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers
230
         */
231
        register : function(q, options, shouldDegrade) {
232
            var queries         = this.queries,
233
                isUnconditional = shouldDegrade && this.browserIsIncapable;
234
235
            if(!queries[q]) {
236
                queries[q] = new MediaQuery(q, isUnconditional);
237
            }
238
239
            //normalise to object in an array
240
            if(isFunction(options)) {
241
                options = { match : options };
242
            }
243
            if(!isArray(options)) {
244
                options = [options];
245
            }
246
            each(options, function(handler) {
247
                queries[q].addHandler(handler);
248
            });
249
250
            return this;
251
        },
252
253
        /**
254
         * unregisters a query and all it's handlers, or a specific handler for a query
255
         *
256
         * @param {string} q the media query to target
257
         * @param {object || function} [handler] specific handler to unregister
258
         */
259
        unregister : function(q, handler) {
260
            var query = this.queries[q];
261
262
            if(query) {
263
                if(handler) {
264
                    query.removeHandler(handler);
265
                }
266
                else {
267
                    query.clear();
268
                    delete this.queries[q];
269
                }
270
            }
271
272
            return this;
273
        }
274
    };
275
276
277
    global.enquire = global.enquire || new MediaQueryDispatch();
278
279
}(this));
(-)a/koha-tmpl/opac-tmpl/lib/enquire.min.js (-5 lines)
Lines 1-5 Link Here
1
// enquire.js v2.0.1 - Awesome Media Queries in JavaScript
2
// Copyright (c) 2013 Nick Williams - http://wicky.nillia.ms/enquire.js
3
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
4
5
(function(t){"use strict";function i(t,i){var s,n=0,e=t.length;for(n;e>n&&(s=i(t[n],n),s!==!1);n++);}function s(t){return"[object Array]"===Object.prototype.toString.apply(t)}function n(t){return"function"==typeof t}function e(t){this.options=t,!t.deferSetup&&this.setup()}function o(t,i){this.query=t,this.isUnconditional=i,this.handlers=[],this.mql=h(t);var s=this;this.listener=function(t){s.mql=t,s.assess()},this.mql.addListener(this.listener)}function r(){if(!h)throw Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!h("only all").matches}var h=t.matchMedia;e.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(t){return this.options===t||this.options.match===t}},o.prototype={addHandler:function(t){var i=new e(t);this.handlers.push(i),this.matches()&&i.on()},removeHandler:function(t){var s=this.handlers;i(s,function(i,n){return i.equals(t)?(i.destroy(),!s.splice(n,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){i(this.handlers,function(t){t.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var t=this.matches()?"on":"off";i(this.handlers,function(i){i[t]()})}},r.prototype={register:function(t,e,r){var h=this.queries,a=r&&this.browserIsIncapable;return h[t]||(h[t]=new o(t,a)),n(e)&&(e={match:e}),s(e)||(e=[e]),i(e,function(i){h[t].addHandler(i)}),this},unregister:function(t,i){var s=this.queries[t];return s&&(i?s.removeHandler(i):(s.clear(),delete this.queries[t])),this}},t.enquire=t.enquire||new r})(this);
(-)a/koha-tmpl/opac-tmpl/lib/enquire/enquire.min.js (+6 lines)
Line 0 Link Here
1
/*!
2
 * enquire.js v2.1.6 - Awesome Media Queries in JavaScript
3
 * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/enquire.js
4
 * License: MIT */
5
6
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.enquire=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b){this.query=a,this.isUnconditional=b,this.handlers=[],this.mql=window.matchMedia(a);var c=this;this.listener=function(a){c.mql=a.currentTarget||a,c.assess()},this.mql.addListener(this.listener)}var e=a(3),f=a(4).each;d.prototype={constuctor:d,addHandler:function(a){var b=new e(a);this.handlers.push(b),this.matches()&&b.on()},removeHandler:function(a){var b=this.handlers;f(b,function(c,d){if(c.equals(a))return c.destroy(),!b.splice(d,1)})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){f(this.handlers,function(a){a.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var a=this.matches()?"on":"off";f(this.handlers,function(b){b[a]()})}},b.exports=d},{3:3,4:4}],2:[function(a,b,c){function d(){if(!window.matchMedia)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!window.matchMedia("only all").matches}var e=a(1),f=a(4),g=f.each,h=f.isFunction,i=f.isArray;d.prototype={constructor:d,register:function(a,b,c){var d=this.queries,f=c&&this.browserIsIncapable;return d[a]||(d[a]=new e(a,f)),h(b)&&(b={match:b}),i(b)||(b=[b]),g(b,function(b){h(b)&&(b={match:b}),d[a].addHandler(b)}),this},unregister:function(a,b){var c=this.queries[a];return c&&(b?c.removeHandler(b):(c.clear(),delete this.queries[a])),this}},b.exports=d},{1:1,4:4}],3:[function(a,b,c){function d(a){this.options=a,!a.deferSetup&&this.setup()}d.prototype={constructor:d,setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(a){return this.options===a||this.options.match===a}},b.exports=d},{}],4:[function(a,b,c){function d(a,b){var c=0,d=a.length;for(c;c<d&&b(a[c],c)!==!1;c++);}function e(a){return"[object Array]"===Object.prototype.toString.apply(a)}function f(a){return"function"==typeof a}b.exports={isFunction:f,isArray:e,each:d}},{}],5:[function(a,b,c){var d=a(2);b.exports=new d},{2:2}]},{},[5])(5)});
(-)a/koha-tmpl/opac-tmpl/lib/media.match.js (-325 lines)
Lines 1-325 Link Here
1
/* MediaMatch v.2.0.2 - Testing css media queries in Javascript. Authors & copyright (c) 2013: WebLinc, David Knight. */
2
3
window.matchMedia || (window.matchMedia = function (win) {
4
    'use strict';
5
6
    // Internal globals
7
    var _doc        = win.document,
8
        _viewport   = _doc.documentElement,
9
        _queries    = [],
10
        _queryID    = 0,
11
        _type       = '',
12
        _features   = {},
13
                    // only screen
14
                    // only screen and
15
                    // not screen
16
                    // not screen and
17
                    // screen
18
                    // screen and
19
        _typeExpr   = /\s*(only|not)?\s*(screen|print|[a-z\-]+)\s*(and)?\s*/i,
20
                    // (-vendor-min-width: 300px)
21
                    // (min-width: 300px)
22
                    // (width: 300px)
23
                    // (width)
24
                    // (orientation: portrait|landscape)
25
        _mediaExpr  = /^\s*\(\s*(-[a-z]+-)?(min-|max-)?([a-z\-]+)\s*(:?\s*([0-9]+(\.[0-9]+)?|portrait|landscape)(px|em|dppx|dpcm|rem|%|in|cm|mm|ex|pt|pc|\/([0-9]+(\.[0-9]+)?))?)?\s*\)\s*$/,
26
        _timer      = 0,
27
28
        // Helper methods
29
30
        /*
31
            _matches
32
         */
33
        _matches = function (media) {
34
            // screen and (min-width: 400px), screen and (max-width: 500px)
35
            var mql         = (media.indexOf(',') !== -1 && media.split(',')) || [media],
36
                mqIndex     = mql.length - 1,
37
                mqLength    = mqIndex,
38
                mq          = null,
39
40
                // not screen, screen
41
                negateType      = null,
42
                negateTypeFound = '',
43
                negateTypeIndex = 0,
44
                negate          = false,
45
                type            = '',
46
47
                // (min-width: 400px), (min-width)
48
                exprListStr = '',
49
                exprList    = null,
50
                exprIndex   = 0,
51
                exprLength  = 0,
52
                expr        = null,
53
54
                prefix      = '',
55
                length      = '',
56
                unit        = '',
57
                value       = '',
58
                feature     = '',
59
60
                match       = false;
61
62
            if (media === '') {
63
                return true;
64
            }
65
66
            do {
67
                mq          = mql[mqLength - mqIndex];
68
                negate      = false;
69
                negateType  = mq.match(_typeExpr);
70
71
                if (negateType) {
72
                    negateTypeFound = negateType[0];
73
                    negateTypeIndex = negateType.index;
74
                }
75
76
                if (!negateType || ((mq.substring(0, negateTypeIndex).indexOf('(') === -1) && (negateTypeIndex || (!negateType[3] && negateTypeFound !== negateType.input)))) {
77
                    match = false;
78
                    continue;
79
                }
80
81
                exprListStr = mq;
82
83
                negate = negateType[1] === 'not';
84
85
                if (!negateTypeIndex) {
86
                    type        =  negateType[2];
87
                    exprListStr = mq.substring(negateTypeFound.length);
88
                }
89
90
                // Test media type
91
                // Test type against this device or if 'all' or empty ''
92
                match       = type === _type || type === 'all' || type === '';
93
94
                exprList    = (exprListStr.indexOf(' and ') !== -1 && exprListStr.split(' and ')) || [exprListStr];
95
                exprIndex   = exprList.length - 1;
96
                exprLength  = exprIndex;
97
98
                if (match && exprIndex >= 0 && exprListStr !== '') {
99
                    do {
100
                        expr = exprList[exprIndex].match(_mediaExpr);
101
102
                        if (!expr || !_features[expr[3]]) {
103
                            match = false;
104
                            break;
105
                        }
106
107
                        prefix  = expr[2];
108
                        length  = expr[5];
109
                        value   = length;
110
                        unit    = expr[7];
111
                        feature = _features[expr[3]];
112
113
                        // Convert unit types
114
                        if (unit) {
115
                            if (unit === 'px') {
116
                                // If unit is px
117
                                value = Number(length);
118
                            } else if (unit === 'em' || unit === 'rem') {
119
                                // Convert relative length unit to pixels
120
                                // Assumed base font size is 16px
121
                                value = 16 * length;
122
                            } else if (expr[8]) {
123
                                // Convert aspect ratio to decimal
124
                                value = (length / expr[8]).toFixed(2);
125
                            } else if (unit === 'dppx') {
126
                                // Convert resolution dppx unit to pixels
127
                                value = length * 96;
128
                            } else if (unit === 'dpcm') {
129
                                // Convert resolution dpcm unit to pixels
130
                                value = length * 0.3937;
131
                            } else {
132
                                // default
133
                                value = Number(length);
134
                            }
135
                        }
136
137
                        // Test for prefix min or max
138
                        // Test value against feature
139
                        if (prefix === 'min-' && value) {
140
                            match = feature >= value;
141
                        } else if (prefix === 'max-' && value) {
142
                            match = feature <= value;
143
                        } else if (value) {
144
                            match = feature === value;
145
                        } else {
146
                            match = !!feature;
147
                        }
148
149
                        // If 'match' is false, break loop
150
                        // Continue main loop through query list
151
                        if (!match) {
152
                            break;
153
                        }
154
                    } while (exprIndex--);
155
                }
156
157
                // If match is true, break loop
158
                // Once matched, no need to check other queries
159
                if (match) {
160
                    break;
161
                }
162
            } while (mqIndex--);
163
164
            return negate ? !match : match;
165
        },
166
167
        /*
168
            _setFeature
169
         */
170
        _setFeature = function () {
171
            // Sets properties of '_features' that change on resize and/or orientation.
172
            var w   = win.innerWidth || _viewport.clientWidth,
173
                h   = win.innerHeight || _viewport.clientHeight,
174
                dw  = win.screen.width,
175
                dh  = win.screen.height,
176
                c   = win.screen.colorDepth,
177
                x   = win.devicePixelRatio;
178
179
            _features.width                     = w;
180
            _features.height                    = h;
181
            _features['aspect-ratio']           = (w / h).toFixed(2);
182
            _features['device-width']           = dw;
183
            _features['device-height']          = dh;
184
            _features['device-aspect-ratio']    = (dw / dh).toFixed(2);
185
            _features.color                     = c;
186
            _features['color-index']            = Math.pow(2, c);
187
            _features.orientation               = (h >= w ? 'portrait' : 'landscape');
188
            _features.resolution                = (x && x * 96) || win.screen.deviceXDPI || 96;
189
            _features['device-pixel-ratio']     = x || 1;
190
        },
191
192
        /*
193
            _watch
194
         */
195
        _watch = function () {
196
            clearTimeout(_timer);
197
198
            _timer = setTimeout(function () {
199
                var query   = null,
200
                    qIndex  = _queryID - 1,
201
                    qLength = qIndex,
202
                    match   = false;
203
204
                if (qIndex >= 0) {
205
                    _setFeature();
206
207
                    do {
208
                        query = _queries[qLength - qIndex];
209
210
                        if (query) {
211
                            match = _matches(query.mql.media);
212
213
                            if ((match && !query.mql.matches) || (!match && query.mql.matches)) {
214
                                query.mql.matches = match;
215
216
                                if (query.listeners) {
217
                                    for (var i = 0, il = query.listeners.length; i < il; i++) {
218
                                        if (query.listeners[i]) {
219
                                            query.listeners[i].call(win, query.mql);
220
                                        }
221
                                    }
222
                                }
223
                            }
224
                        }
225
                    } while(qIndex--);
226
                }
227
228
229
            }, 10);
230
        },
231
232
        /*
233
            _init
234
         */
235
        _init = function () {
236
            var head        = _doc.getElementsByTagName('head')[0],
237
                style       = _doc.createElement('style'),
238
                info        = null,
239
                typeList    = ['screen', 'print', 'speech', 'projection', 'handheld', 'tv', 'braille', 'embossed', 'tty'],
240
                typeIndex   = 0,
241
                typeLength  = typeList.length,
242
                cssText     = '#mediamatchjs { position: relative; z-index: 0; }',
243
                eventPrefix = '',
244
                addEvent    = win.addEventListener || (eventPrefix = 'on') && win.attachEvent;
245
246
            style.type  = 'text/css';
247
            style.id    = 'mediamatchjs';
248
249
            head.appendChild(style);
250
251
            // Must be placed after style is inserted into the DOM for IE
252
            info = (win.getComputedStyle && win.getComputedStyle(style)) || style.currentStyle;
253
254
            // Create media blocks to test for media type
255
            for ( ; typeIndex < typeLength; typeIndex++) {
256
                cssText += '@media ' + typeList[typeIndex] + ' { #mediamatchjs { position: relative; z-index: ' + typeIndex + ' } }';
257
            }
258
259
            // Add rules to style element
260
            if (style.styleSheet) {
261
                style.styleSheet.cssText = cssText;
262
            } else {
263
                style.textContent = cssText;
264
            }
265
266
            // Get media type
267
            _type = typeList[(info.zIndex * 1) || 0];
268
269
            head.removeChild(style);
270
271
            _setFeature();
272
273
            // Set up listeners
274
            addEvent(eventPrefix + 'resize', _watch);
275
            addEvent(eventPrefix + 'orientationchange', _watch);
276
        };
277
278
    _init();
279
280
    /*
281
        A list of parsed media queries, ex. screen and (max-width: 400px), screen and (max-width: 800px)
282
    */
283
    return function (media) {
284
        var id  = _queryID,
285
            mql = {
286
                matches         : false,
287
                media           : media,
288
                addListener     : function addListener(listener) {
289
                    _queries[id].listeners || (_queries[id].listeners = []);
290
                    listener && _queries[id].listeners.push(listener);
291
                },
292
                removeListener  : function removeListener(listener) {
293
                    var query   = _queries[id],
294
                        i       = 0,
295
                        il      = 0;
296
297
                    if (!query) {
298
                        return;
299
                    }
300
301
                    il = query.listeners.length;
302
303
                    for ( ; i < il; i++) {
304
                        if (query.listeners[i] === listener) {
305
                            query.listeners.splice(i, 1);
306
                        }
307
                    }
308
                }
309
            };
310
311
        if (media === '') {
312
            mql.matches = true;
313
            return mql;
314
        }
315
316
        mql.matches = _matches(media);
317
318
        _queryID = _queries.push({
319
            mql         : mql,
320
            listeners   : null
321
        });
322
323
        return mql;
324
    };
325
}(window));
(-)a/koha-tmpl/opac-tmpl/lib/media.match.min.js (-9 lines)
Lines 1-8 Link Here
1
/* MediaMatch v.2.0.2 - Testing css media queries in Javascript. Authors & copyright (c) 2013: WebLinc, David Knight. */
2
3
window.matchMedia||(window.matchMedia=function(c){var a=c.document,w=a.documentElement,l=[],t=0,x="",h={},G=/\s*(only|not)?\s*(screen|print|[a-z\-]+)\s*(and)?\s*/i,H=/^\s*\(\s*(-[a-z]+-)?(min-|max-)?([a-z\-]+)\s*(:?\s*([0-9]+(\.[0-9]+)?|portrait|landscape)(px|em|dppx|dpcm|rem|%|in|cm|mm|ex|pt|pc|\/([0-9]+(\.[0-9]+)?))?)?\s*\)\s*$/,y=0,A=function(b){var z=-1!==b.indexOf(",")&&b.split(",")||[b],e=z.length-1,j=e,g=null,d=null,c="",a=0,l=!1,m="",f="",g=null,d=0,f=null,k="",p="",q="",n="",r="",k=!1;if(""===
4
b)return!0;do{g=z[j-e];l=!1;if(d=g.match(G))c=d[0],a=d.index;if(!d||-1===g.substring(0,a).indexOf("(")&&(a||!d[3]&&c!==d.input))k=!1;else{f=g;l="not"===d[1];a||(m=d[2],f=g.substring(c.length));k=m===x||"all"===m||""===m;g=-1!==f.indexOf(" and ")&&f.split(" and ")||[f];d=g.length-1;if(k&&0<=d&&""!==f){do{f=g[d].match(H);if(!f||!h[f[3]]){k=!1;break}k=f[2];n=p=f[5];q=f[7];r=h[f[3]];q&&(n="px"===q?Number(p):"em"===q||"rem"===q?16*p:f[8]?(p/f[8]).toFixed(2):"dppx"===q?96*p:"dpcm"===q?0.3937*p:Number(p));
5
k="min-"===k&&n?r>=n:"max-"===k&&n?r<=n:n?r===n:!!r;if(!k)break}while(d--)}if(k)break}}while(e--);return l?!k:k},B=function(){var b=c.innerWidth||w.clientWidth,a=c.innerHeight||w.clientHeight,e=c.screen.width,j=c.screen.height,g=c.screen.colorDepth,d=c.devicePixelRatio;h.width=b;h.height=a;h["aspect-ratio"]=(b/a).toFixed(2);h["device-width"]=e;h["device-height"]=j;h["device-aspect-ratio"]=(e/j).toFixed(2);h.color=g;h["color-index"]=Math.pow(2,g);h.orientation=a>=b?"portrait":"landscape";h.resolution=
6
d&&96*d||c.screen.deviceXDPI||96;h["device-pixel-ratio"]=d||1},C=function(){clearTimeout(y);y=setTimeout(function(){var b=null,a=t-1,e=a,j=!1;if(0<=a){B();do if(b=l[e-a])if((j=A(b.mql.media))&&!b.mql.matches||!j&&b.mql.matches)if(b.mql.matches=j,b.listeners)for(var j=0,g=b.listeners.length;j<g;j++)b.listeners[j]&&b.listeners[j].call(c,b.mql);while(a--)}},10)},D=a.getElementsByTagName("head")[0],a=a.createElement("style"),E=null,u="screen print speech projection handheld tv braille embossed tty".split(" "),
7
m=0,I=u.length,s="#mediamatchjs { position: relative; z-index: 0; }",v="",F=c.addEventListener||(v="on")&&c.attachEvent;a.type="text/css";a.id="mediamatchjs";D.appendChild(a);for(E=c.getComputedStyle&&c.getComputedStyle(a)||a.currentStyle;m<I;m++)s+="@media "+u[m]+" { #mediamatchjs { position: relative; z-index: "+m+" } }";a.styleSheet?a.styleSheet.cssText=s:a.textContent=s;x=u[1*E.zIndex||0];D.removeChild(a);B();F(v+"resize",C);F(v+"orientationchange",C);return function(a){var c=t,e={matches:!1,
8
media:a,addListener:function(a){l[c].listeners||(l[c].listeners=[]);a&&l[c].listeners.push(a)},removeListener:function(a){var b=l[c],d=0,e=0;if(b)for(e=b.listeners.length;d<e;d++)b.listeners[d]===a&&b.listeners.splice(d,1)}};if(""===a)return e.matches=!0,e;e.matches=A(a);t=l.push({mql:e,listeners:null});return e}}(window));
9
- 

Return to bug 35638