Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: static/js/animation.js

Issue 29337838: #2992 - Added fallback to english animations if translated animations do not exist on adblockplus.o… (Closed)
Patch Set: Added fallback to english animations if translated animations do not exist Created March 1, 2016, 2:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus website, 2 * This file is part of the Adblock Plus website,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 container.appendChild(image); 76 container.appendChild(image);
77 animation.appendChild(container); 77 animation.appendChild(container);
78 78
79 image.onload = function() { 79 image.onload = function() {
80 container.style.left = Math.round((50 - image.width) / 2) + "px"; 80 container.style.left = Math.round((50 - image.width) / 2) + "px";
81 container.style.top = Math.round((50 - image.height) / 2) + "px"; 81 container.style.top = Math.round((50 - image.height) / 2) + "px";
82 container.style.visibility = ""; 82 container.style.visibility = "";
83 } 83 }
84 image.src = "data:image/gif;base64,R0lGODlhGAAYAPQAAP%2F%2F%2FwCA%2F87m%2Fvr8% 2FuDv%2FrDX%2Fujz%2Fo7G%2Fsjj%2FpzN%2Ftjr%2FqjT%2FsDf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ZKipBopW8XRLDkeCiAMyMvQAA%2BuON4JEIo%2BvqukkKQ6RhLHplVGN%2BLyKcXA4Dgx5DWwGDXx %2BgIKENnqNdzIDaiMECwcFRgQCCowiCAcHCZIlCgICVgSfCEMMnA0CXaU2YSQFoQAKUQMMqjoyAglcA AyBAAIMRUYLCUkFlybDeAYJryLNk6xGNCTQXY0juHghACH5BAAHAAsALAAAAAAYABgAAAWzICCOJNA0Z VoOAmkY5KCSSgSNBDE2hDyLjohClBMNij8RJHIQvZwEVOpIekRQJyJs5AMoHA%2BGMbE1lnm9EcPhOHR nhpwUl3AsknHDm5RN%2Bv8qCAkHBwkIfw1xBAYNgoSGiIqMgJQifZUjBhAJYj95ewIJCQV7KYpzBAkLL QADCHOtOpY5PgNlAAykAEUsQ1wzCgWdCIdeArczBQVbDJ0NAqyeBb64nQAGArBTt8R8mLuyPyEAOwAAA AAAAAAAAA%3D%3D";
85 85
86 var request = new XMLHttpRequest(); 86 //empty loadLang defaults to current language
87 request.open("GET", loadPrefix + encodeURIComponent(animation.getAttribute("na me")) + loadSuffix); 87 var loadLang = "";
88 request.onload = function() { 88
89 var onLoadAnimation = function()
90 {
89 if (!request.responseXML || !request.responseXML.documentElement) 91 if (!request.responseXML || !request.responseXML.documentElement)
92 {
93 //fallback to english animation
94 if (loadLang == "")
95 {
96 loadLang = "/en/";
97 request = requestAnimationData();
98 }
90 return; 99 return;
91 100 }
92 animation._data = request.responseXML.documentElement; 101 animation._data = request.responseXML.documentElement;
93 initAnimation(animation); 102 initAnimation(animation);
94 } 103 }
95 request.send(null); 104
105 var requestAnimationData = function ()
106 {
107 var request = new XMLHttpRequest();
108 request.open("GET", loadLang + loadPrefix + encodeURIComponent(animation.get Attribute("name")) + loadSuffix);
109 request.onload = onLoadAnimation;
110 request.send(null);
111 return request;
112 }
113
114 var request = requestAnimationData();
96 } 115 }
97 116
98 function initAnimation(animation) { 117 function initAnimation(animation) {
99 while (animation.firstChild) 118 while (animation.firstChild)
100 animation.removeChild(animation.firstChild); 119 animation.removeChild(animation.firstChild);
101 120
102 var data = animation._data; 121 var data = animation._data;
103 animation._width = (parseInt(data.getAttribute("width")) || 150); 122 animation._width = (parseInt(data.getAttribute("width")) || 150);
104 animation._height = (parseInt(data.getAttribute("height")) || 150); 123 animation._height = (parseInt(data.getAttribute("height")) || 150);
105 animation._stepSize = parseInt(data.getAttribute("step")) || 20; 124 animation._stepSize = parseInt(data.getAttribute("step")) || 20;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (/right/i.test(anchor)) 359 if (/right/i.test(anchor))
341 coords[0] += size[0]; 360 coords[0] += size[0];
342 else if (!/left/i.test(anchor)) 361 else if (!/left/i.test(anchor))
343 coords[0] += Math.round(size[0]/2); 362 coords[0] += Math.round(size[0]/2);
344 363
345 if (/bottom/i.test(anchor)) 364 if (/bottom/i.test(anchor))
346 coords[1] += size[1]; 365 coords[1] += size[1];
347 else if (!/top/i.test(anchor)) 366 else if (!/top/i.test(anchor))
348 coords[1] += Math.round(size[1]/2); 367 coords[1] += Math.round(size[1]/2);
349 } 368 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld