gutenbergsite/js/pg-mobile-one.js

47 lines
117 KiB
JavaScript
Raw Normal View History

/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.18 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
/*!
* jQuery JavaScript Library v1.11.3
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-04-28T16:19Z
*/
/*!
* Sizzle CSS Selector Engine v2.2.0-pre
* http://sizzlejs.com/
*
* Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2014-12-16
*/
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
/*
* pg-mobile.js Project Gutenberg Mobile Website
*
* Copyright 2010-2014 Marcello Perathoner <webmaster@gutenberg.org>
* Licensed under GPL version 3.0 or later.
*/
function Spinner(e,t,n,r,i,s){this.elem=e,this.no_of_frames=s,this.x_squares=i,this.y_squares=Math.floor(s/i)+1,this.img_url=t,this.x_step=n/this.x_squares,this.y_step=r/this.y_squares}function get_logo_token(e){var t=$(".icon_search",e),n=t.attr("id");$.cookie("bonus",n,{path:"/",domain:"gutenberg.org"})}function sanitize_headers(){var e,t="";$("li.header").each(function(){e=$(this).text(),e===t&&$(this).remove(),t=e})}function bind_more(){var e=$("li.more a"),t=e.attr("href");e.removeAttr("href"),$("span.title",e).text(msg_load_more),e.bind("click",{href:t},function(t){var n=new Spinner($("span.spinner",e),"/pics/24/gnome-spinner.png",176,88,8,31);e.css({"background-color":"rgba(0,0,255,0.4)"}),n.start(50),$.ajax({url:t.data.href}).done(function(t){n.stop(),get_logo_token(t);var r=$("li.booklink, li.more",t).clone();r.appendTo(e.parent().parent()),e.parent().remove(),sanitize_headers(),bind_more()})})}function clear_suggestions(e){$(".suggestion").slideUp("fast",function(){$(".suggestion").remove(),$("#searchlist").scrollTo(0,"fast")})}function get_suggestions(e){var t=e.target.value;t!==e.target.old_value&&(e.target.old_value=e.target.value,clear_suggestions(e),t.length>=4&&$.ajax({url:json_search,data:{query:t},dataType:"json",cache:!1,xhrFields:{withCredentials:!0}}).done(function(t){if(t[0]===e.target.value){var n,r=t[1];for(n=r.length-1;n>=0;--n)$("#searchlist").after('<li class="navlink suggestion"><a class="table link" href="'+mobile_search+r[n]+'"><span class="row"><span class="cell leftcell"><span class="icon icon_suggestion" /></span><span class="cell content"><span class="title">'+r[n]+'</span></span><span class="cell rightcell"><span class="icon icon_next" /></span></span></a></li>');$(".suggestion").slideDown("fast",function(){$("#searchlist").scrollTo(0,"fast")})}}))}function toggle_help(){$("#helpbox").slideToggle("fast")}function get_help(){$("#helpbox").slideDown("fast")}function clear_help(){$("#helpbox").slideUp("fast")}function bind_search(){var e=$("#query");e&&(e.keydown(function(e){e.target.suggestions_timer_id&&(clearTimeout(e.target.suggestions_timer_id),delete e.target.suggestions_timer_id)}),e.keyup(function(e){var t=e;t.target.suggestions_timer_id=setTimeout(get_suggestions,500,t)}),e.attr("placeholder",e.attr("title")),e.attr("type","search"),e.old_value=e.value)}function bind_clear(){var e=$("#query"),t=$("#clear");t.click(function(t){t.preventDefault(),e.val(""),e.old_value=e.value,clear_suggestions(),e.focus()})}function scroll_to_first_header(){if($.fx.off)return;$(".header:eq(0)").scrollTo(500,800,"swing")}function doc_ready(e,t){e.fn.extend({scrollTo:function(e,t,n){return this.each(function(){var r=$(this).offset().top;setTimeout(function(){$("html, body").animate({scrollTop:r},t,n)},e)})}}),e(document).ready(function(){get_logo_token($(document)),$.fx.off=!do_animations,bind_more(),bind_search(),bind_clear(),scroll_to_first_header()})}var requirejs,require,define;(function(global){function isFunction(e){return ostring.call(e)==="[object Function]"}function isArray(e){return ostring.call(e)==="[object Array]"}function each(e,t){if(e){var n;for(n=0;n<e.length;n+=1)if(e[n]&&t(e[n],n,e))break}}function eachReverse(e,t){if(e){var n;for(n=e.length-1;n>-1;n-=1)if(e[n]&&t(e[n],n,e))break}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var n;for(n in e)if(hasProp(e,n)&&t(e[n],n))break}function mixin(e,t,n,r){return t&&eachProp(t,function(t,i){if(n||!hasProp(e,i))r&&typeof t=="object"&&t&&!isArray(t)&&!isFunction(t)&&!(t instanceof RegExp)?(e[i]||(e[i]={}),mixin(e[i],t,n,r)):e[i]=t}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,n,r){var i=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return i.requireType=e,i.requireModules=r,n&&(i.originalError=n),i}function newContext(e)