X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=www%2Fplugins%2Fgalleria.history.js;fp=www%2Fplugins%2Fgalleria.history.js;h=f26be1ae1d29868e69b708664bef5e19de520f57;hb=6468e8c20ecbb8ca9601058bc17b0d18d178e171;hp=0000000000000000000000000000000000000000;hpb=2dbf4d0209064d7c481ae33df8a2e0fa2b5a4982;p=scribo diff --git a/www/plugins/galleria.history.js b/www/plugins/galleria.history.js new file mode 100644 index 0000000..f26be1a --- /dev/null +++ b/www/plugins/galleria.history.js @@ -0,0 +1,602 @@ +/*! + * Galleria History Plugin v 1.0 + * http://galleria.aino.se + * + * Original Copyright (c) 2009-2010 Rostislav Hristov + * Modified by Aino (c) 2010 + * + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + */ +(function($) { + + var G = window.Galleria; + if (typeof G == 'undefined') { + return; + } + + G.History = (function () { + + var _trigger = function(name) { + $(G.History).trigger( + $.extend($.Event(name), + (function() { + var parameters = {}, + parameterNames = G.History.parameterNames(); + for (var i = 0, l = parameterNames.length; i < l; i++) { + parameters[parameterNames[i]] = G.History.parameter(parameterNames[i]); + } + return { + value: G.History.value(), + path: G.History.path(), + pathNames: G.History.pathNames(), + parameterNames: parameterNames, + parameters: parameters, + queryString: G.History.queryString() + }; + }).call(G.History) + ) + ); + }, + _bind = function(value, data, fn) { + fn = fn || function(){}; + $(G.History).bind(value, data, fn); + return G.History; + }, + _hash = function() { + var index = _l.href.indexOf('#'); + return index != -1 ? _ec(_dc(_crawl(_l.href.substr(index + 1), FALSE))) : ''; + }, + _window = function() { + try { + return top.document !== undefined ? top : window; + } catch (e) { + return window; + } + }, + _js = function() { + return 'javascript'; + }, + _strict = function(value, force) { + if (_opts.strict) { + value = force ? (value.substr(0, 1) != '/' ? '/' + value : value) : (value == '' ? '/' : value); + } + return value; + }, + _local = function(value, direction) { + return (_msie && _l.protocol == 'file:') ? + (direction ? _value.replace(/\?/, '%3F') : _value.replace(/%253F/, '?')) : value; + }, + _crawl = function(value, direction) { + if (_opts.crawlable && direction) { + return (value != '' ? '!' : '') + value; + } + return value.replace(/^\!/, ''); + }, + _cssint = function(el, value) { + return parseInt(el.css(value), 10); + }, + _search = function(el) { + var url, s; + for (var i = 0, l = el.childNodes.length; i < l; i++) { + if (el.childNodes[i].src) { + url = String(el.childNodes[i].src); + } + s = _search(el.childNodes[i]); + if (s) { + url = s; + } + } + return url; + }, + _listen = function() { + if (!_silent) { + var hash = _hash(), + diff = _value != hash; + if (_safari && _version < 523) { + if (_length != _h.length) { + _length = _h.length; + if (typeof _stack[_length - 1] != UNDEFINED) { + _value = _stack[_length - 1]; + } + _update(FALSE); + } + } else if (_msie && _version < 7 && diff) { + _l.reload(); + } else if (diff) { + _value = hash; + _update(FALSE); + } + } + }, + _update = function(internal) { + _trigger(CHANGE); + _trigger(internal ? INTERNAL_CHANGE : EXTERNAL_CHANGE); + _st(_track, 10); + }, + _track = function() { + var value = (_l.pathname + (/\/$/.test(_l.pathname) ? '' : '/') + + (G.History ? G.History.value() : '')).replace(/\/\//, '/').replace(/^\/$/, ''), + fn = _t[_opts.tracker]; + if (typeof fn == FUNCTION) { + fn(value); + } else if (typeof urchinTracker == FUNCTION) { + urchinTracker(value); + } else if (typeof pageTracker != UNDEFINED && typeof pageTracker._trackPageview == FUNCTION) { + pageTracker._trackPageview(value); + } else if (typeof _gaq != UNDEFINED && typeof _gaq.push == FUNCTION) { + _gaq.push(['_trackPageview', value]); + } + }, + _html = function() { + var doc = _frame.contentWindow.document; + doc.open(); + doc.write('' + _d.title + '