PageSourceSearch

https://fotopatracka.cz/js/plugins/jquery.taconite-3.66.js

js fotopatracka.cz collected 2026-09-24 10:28:38 UTC 13,242 bytes, 440 lines download raw bytes

1/*!
2 * jQuery Taconite plugin - A port of the Taconite framework by Ryan Asleson and
3 *     Nathaniel T. Schutta: http://taconite.sourceforge.net/
4 *
5 * Examples and documentation at: http://malsup.com/jquery/taconite/
6 * Copyright (c) 2007-2011 M. Alsup
7 * Dual licensed under the MIT and GPL licenses:
8 * http://www.opensource.org/licenses/mit-license.php
9 * http://www.gnu.org/licenses/gpl.html
10 * Thanks to Kenton Simpson for contributing many good ideas!
11 *
12 * @version: 3.66  02-MAR-2013
13 * @requires jQuery v1.3.2 or later
14 */
15
16(function($) {
17var version = '3.66';
18
19var browser = $.browser;
20if ( ! browser ) {
21   var ua = navigator.userAgent.toLowerCase();
22   var m = /(msie) ([\w.]+)/.exec( ua ) || ! /compatible/.test(ua) && /(mozilla)/.exec( ua ) || [];
23   browser = { version: m[2] };
24   browser[ m[1] ] = true;
25}
26
27
28$.taconite = function(xml) {
29    processDoc(xml);
30};
31
32$.taconite.debug = 0;  // set to true to enable debug logging to window.console.log
33$.taconite.autodetect = true;
34$.taconite.defaults = {
35    cdataWrap: 'div'
36};
37
38// add 'replace' and 'replaceContent' plugins (conditionally)
39$.fn.replace = $.fn.replace || function(a) {
40    this.after(a);
41    this.remove();
42    return this; // #14
43};
44$.fn.replaceContent = $.fn.replaceContent || function(a) {
45    return this.empty().append(a);
46};
47
48$.expr[':'].taconiteTag = function(a) {
49    return a.taconiteTag === 1;
50};
51
52// allow auto-detection to be enabled/disabled on-demand
53$.taconite.enableAutoDetection = function(b) {
54    $.taconite.autodetect = b;
55    if (origHttpData)
56        $.httpData = b ? origHttpData : detect;
57};
58
59var logCount = 0;
60function log() {
61    if (!$.taconite.debug || !window.console || !window.console.log) return;
62    if (++logCount === 1)
63        log('Plugin Version: ' + version);
64    window.console.log('[taconite] ' + [].join.call(arguments,''));
65}
66
67var parseJSON = $.parseJSON || function(s) {
68    /*jshint evil:true */
69    return window['eval']('(' + s + ')');
70};
71
72function httpData( xhr, type, s ) {
73    var ct = xhr.getResponseHeader('content-type') || '',
74        xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
75        data = xml ? xhr.responseXML : xhr.responseText;
76
77    if (xml && data.documentElement.nodeName === 'parsererror') {
78        if ($.error)
79            $.error('parsererror');
80    }
81    if (s && s.dataFilter) {
82        data = s.dataFilter(data, type);
83    }
84    if (typeof data === 'string') {
85        if (type === 'json' || !type && ct.indexOf('json') >= 0) {
86            data = parseJSON(data);
87        } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
88            $.globalEval(data);
89        }
90    }
91    return data;
92}
93
94function getResponse(xhr, type, s) {
95    if (origHttpData)
96        return origHttpData(xhr, type, s);
97    return xhr.responseXML || xhr.responseText;
98}
99
100function detect(xhr, type, s) {
101    var ct = xhr.getResponseHeader('content-type');
102    if ($.taconite.debug) {
103        log('[AJAX response] content-type: ', ct, ';  status: ', xhr.status, ' ', xhr.statusText, ';  has responseXML: ', xhr.responseXML !== null);
104        log('type arg: ' + type);
105//        log('responseXML: ' + xhr.responseXML);  // IE9 doesn't like xhr.toString()
106    }
107    var data = getResponse(xhr, type, s);
108    if (data && data.documentElement && data.documentElement.nodeName != 'parsererror') {
109        $.taconite(data);
110    }
111    else if (typeof data == 'string') {
112        // issue #4 (don't try to parse plain text or html responses
113        if ( /taconite/.test(data) )
114            $.taconite(data);
115    }
116    else {
117        log('jQuery core httpData returned: ' + data);
118        log('httpData: response is not XML (or not "valid" XML)');
119    }
120    return data;
121}
122
123// 1.5+ hook
124if ($.ajaxPrefilter) {
125    $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
126        jqXHR.success(function( data, status, jqXHR ) {
127            if ($.taconite.autodetect)
128                detect(jqXHR, options.dataType, options);
129        });
130    });
131}
132
133// < 1.5 hook
134var origHttpData = $.httpData;
135if ($.httpData)
136    $.httpData = detect;  // replace jQuery's httpData method
137
138// custom data parsers
139var parsers = { 'json': jsonParser }, rawData, rawDataIndic;
140
141$.taconite.registerParser = function(type, fn) {
142    parsers[type] = fn;
143};
144
145function parseRawData(type, data) {
146    var d = data, parser = parsers[type];
147    if ($.isFunction(parser))
148        return parser(data);
149    else
150        throw 'No parser registered for rawData of type "' + type + '"';
151}
152
153function jsonParser(json) {
154    return parseJSON(json);
155}
156
157
158function processDoc(xml) {
159    var status = true, ex;
160    try {
161        if (typeof xml == 'string')
162            xml = convert(xml);
163        if (! ( xml && xml.documentElement) ) {
164            log('$.taconite invoked without valid document; nothing to process');
165            return false;
166        }
167
168        var root = xml.documentElement.tagName;
169        log('XML document root: ', root);
170
171        var taconiteDoc = $('taconite', xml)[0];
172
173        if (!taconiteDoc) {
174            log('document does not contain <taconite> element; nothing to process');
175            return false;
176        }
177
178        $.event.trigger('taconite-begin-notify', [taconiteDoc]);
179        status = go(taconiteDoc);
180    } catch(e) {
181        status = ex = e;
182    }
183    if (rawDataIndic)
184        $.event.trigger('taconite-rawdata-notify', [rawData]);
185    $.event.trigger('taconite-complete-notify', [xml, !!status, status === true ? null : status]);
186    if (ex)
187        throw ex;
188}
189
190// convert string to xml document
191function convert(s) {
192    var doc;
193    log('attempting string to document conversion');
194    try {
195        if (window.DOMParser) {
196            var parser = new DOMParser();
197            doc = parser.parseFromString(s, 'text/xml');
198        }
199        else {
200            doc = $("<xml>")[0];
201            doc.async = 'false';
202            doc.loadXML(s);
203        }
204    }
205    catch(e) {
206        if (window.console && window.console.error)
207            window.console.error('[taconite] ERROR parsing XML string for conversion: ' + e);
208        throw e;
209    }
210    var ok = doc && doc.documentElement && doc.documentElement.tagName != 'parsererror';
211    log('conversion ', ok ? 'successful!' : 'FAILED');
212    return doc;
213}
214
215function go(xml) {
216    try {
217        var t = new Date().getTime();
218        // process the document
219        process(xml.childNodes);
220        $.taconite.lastTime = (new Date().getTime()) - t;
221        log('time to process response: ' + $.taconite.lastTime + 'ms');
222    } catch(e) {
223        if (window.console && window.console.error)
224            window.console.error('[taconite] ERROR processing document: ' + e);
225        throw e;
226    }
227    return true;
228}
229
230// process the taconite commands
231function process(commands) {
232    rawData = {};
233    rawDataIndic = false;
234    var trimHash = { wrap: 1 };
235    var doPostProcess = 0;
236    var a, n, v, i, j, js, els, raw, type, q, jq, cdataWrap, tmp;
237
238    for(i=0; i < commands.length; i++) {
239        if (commands[i].nodeType != 1)
240            continue; // commands are elements
241        var cmdNode = commands[i], cmd = cmdNode.tagName;
242        if (cmd == 'eval') {
243            js = (cmdNode.firstChild ? cmdNode.firstChild.nodeValue : null);
244            log('invoking "eval" command: ', js);
245            if (js)
246                $.globalEval(js);
247            continue;
248        }
249        if (cmd == 'rawData') {
250            raw = (cmdNode.firstChild ? cmdNode.firstChild.nodeValue : null);
251            type = cmdNode.getAttribute('type');
252            log('rawData ('+type+'): ', raw);
253
254            var namespace = cmdNode.getAttribute('namespace') || 'none';
255
256            if (!rawData[namespace])
257                rawData[namespace] = [];
258
259            rawData[namespace].push({
260                data: parseRawData(type, raw),
261                type: type,
262                name: cmdNode.getAttribute('name') || null,
263                raw: raw
264            });
265            if (!rawDataIndic)
266                rawDataIndic = true;
267            continue;
268        }
269        q = cmdNode.getAttribute('select');
270        jq = $(q);
271        if (!jq[0]) {
272            log('No matching targets for selector: ', q);
273            continue;
274        }
275        cdataWrap = cmdNode.getAttribute('cdataWrap') || $.taconite.defaults.cdataWrap;
276
277        a = [];
278        if (cmdNode.childNodes.length > 0) {
279            doPostProcess = 1;
280            for (j=0,els=[]; j < cmdNode.childNodes.length; j++)
281                els[j] = createNode(cmdNode.childNodes[j], cdataWrap);
282            a.push(trimHash[cmd] ? cleanse(els) : els);
283        }
284
285        // remain backward compat with pre 2.0.9 versions
286        n = cmdNode.getAttribute('name');
287        v = cmdNode.getAttribute('value');
288        if (n !== null) 
289            a.push(n);
290        if (v !== null) {
291            tmp = Number(v);
292            if (v == tmp)
293                v = tmp;
294            a.push(v);
295        }
296
297        // @since: 2.0.9: support arg1, arg2, arg3...
298        for (j=1; true; j++) {
299            v = cmdNode.getAttribute('arg'+j);
300            if (v === null)
301                break;
302            // support numeric primitives
303            if (v.length) {
304                tmp = Number(v);
305                if (v == tmp)
306                    v = tmp;
307            }
308            a.push(v);
309        }
310
311        if ($.taconite.debug)
312            logCommand(q, cmd, a, els);
313        jq[cmd].apply(jq,a);
314    }
315
316    // apply dynamic fixes
317    if (doPostProcess)
318        postProcess();
319}
320
321function logCommand(q, cmd, a, els) {
322    var args = '...';
323    if (!els) {
324        args = '';
325        for (var k=0; k < a.length; k++) {
326            val=a[k];
327            if (k > 0)
328                args += ',';
329            if (typeof val == 'string')
330                args += ("'" + val + "'");
331            else
332                args += val;
333        }
334    }
335    log("invoking command: $('", q, "').", cmd, '('+ args +')');
336}
337
338function postProcess() {
339    if (browser.mozilla) return;
340    // post processing fixes go here; currently there is only one:
341    // fix1: opera, IE6, Safari/Win don't maintain selected options in all cases (thanks to Karel Fučík for this!)
342    $('select:taconiteTag').each(function() {
343        var sel = this;
344        $('option:taconiteTag', this).each(function() {
345            this.setAttribute('selected','selected');
346            this.taconiteTag = null;
347            if (sel.type == 'select-one') {
348                var idx = $('option',sel).index(this);
349                sel.selectedIndex = idx;
350            }
351        });
352        this.taconiteTag = null;
353    });
354}
355
356function cleanse(els) {
357    for (var i=0, a=[]; i < els.length; i++)
358        if (els[i].nodeType == 1) a.push(els[i]);
359    return a;
360}
361
362function createNode(node, cdataWrap) {
363    var type = node.nodeType;
364    if (type == 1) return createElement(node, cdataWrap);
365    if (type == 3) return fixTextNode(node.nodeValue);
366    if (type == 4) return handleCDATA(node.nodeValue, cdataWrap);
367    return null;
368}
369
370function handleCDATA(s, cdataWrap) {
371    var el = document.createElement(cdataWrap);
372    var $el = $(el)[cdataWrap == 'script' ? 'text' : 'html'](s);
373    var $ch = $el.children();
374
375    // remove wrapper node if possible
376    if ($ch.size() == 1)
377        return $ch[0];
378    return el;
379}
380
381function fixTextNode(s) {
382    if (browser.msie) 
383        s = s.replace(/\n/g, '\r').replace(/\s+/g, ' ');
384    return document.createTextNode(s);
385}
386
387function createElement(node, cdataWrap) {
388    var e, tag = node.tagName.toLowerCase();
389    // some elements in IE need to be created with attrs inline
390    if (browser.msie && browser.version < 9) {
391        var type = node.getAttribute('type');
392        if (tag == 'table' || type == 'radio' || type == 'checkbox' || tag == 'button' ||
393            (tag == 'select' && node.getAttribute('multiple'))) {
394            e = document.createElement('<' + tag + ' ' + copyAttrs(null, node, true) + '>');
395        }
396    }
397    if (!e) {
398        e = document.createElement(tag);
399        copyAttrs(e, node);
400    }
401
402    // IE fix; colspan must be explicitly set
403    if (browser.msie && tag == 'td') {
404        var colspan = node.getAttribute('colspan');
405        if (colspan) 
406            e.colSpan = parseInt(colspan, 10);
407    }
408
409    // IE fix; script tag not allowed to have children
410    if(browser.msie && !e.canHaveChildren) {
411        if(node.childNodes.length > 0)
412            e.text = node.text;
413    }
414    else {
415        for(var i=0, max=node.childNodes.length; i < max; i++) {
416            var child = createNode (node.childNodes[i], cdataWrap);
417            if(child) e.appendChild(child);
418        }
419    }
420    if (! browser.mozilla) {
421        if (tag == 'select' || (tag == 'option' && node.getAttribute('selected')))
422            e.taconiteTag = 1;
423    }
424    return e;
425}
426
427function copyAttrs(dest, src, inline) {
428    for (var i=0, attr=''; i < src.attributes.length; i++) {
429        var a = src.attributes[i], n = $.trim(a.name), v = $.trim(a.value);
430        if (inline) attr += (n + '="' + v + '" ');
431        else if (n == 'style') { // IE workaround
432            dest.style.cssText = v;
433            dest.setAttribute(n, v);
434        }
435        else $.attr(dest, n, v);
436    }
437    return attr;
438}
439
440})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.