Commits

T. Michael Keesey  committed 43444da

Animation tweaks.

  • Participants
  • Parent commits fc65b34
  • Branches default

Comments (0)

Files changed (2)

File src/assets/scripts/phylopic/name.js

-var pp={};pp.ajax=function(a){var b=$.Deferred();$.ajax(a).fail(function(e,d,c){b.reject({code:d?d:"fail",message:(c?String(c):"Error loading data")+".",details:e})}).done(function(c){try{if(c.success){b.resolve(c.result)}else{b.reject(c.fault)}}catch(d){alert(d)}});return b};pp.api={};pp.api.name={};pp.api.name.images=function(c,g,f,a,b){var e={};if(g!==null){e.supertaxa=g?"true":"false"}if(f!==null){e.subtaxa=f?"true":"false"}if(a!==null){e.other=a?"true":"false"}if(b&&b.length>0){e.options=b.join(" ")}var d={cache:true,data:e,dataType:"json",url:"/api/a/name/"+$.trim(c)+"/images"};return pp.ajax(d)};pp.api.name.taxonomy=function(b,g,f,d,a){var e={};if(g){e.supertaxa=g}if(f){e.subtaxa=f}if(d!==null){e.useUBio=d?"true":"false"}if(a&&a.length>0){e.options=a.join(" ")}var c={cache:true,data:e,dataType:"json",type:"GET",url:"/api/a/name/"+b+"/taxonomy"};return pp.ajax(c)};pp.api.name.taxonomySources=function(b,a){var d=null;if(a&&a.length>0){d={options:a.join(" ")}}var c={cache:true,data:d,dataType:"json",type:"GET",url:"/api/a/name/"+$.trim(b)+"/taxonomy/sources"};return pp.ajax(c)};pp.api.name.taxonomyUBio=function(e,c){var b=$.Deferred();pp.api.name.taxonomy(e,"immediate","immediate",true,c).fail(b.reject).done(d);return b;function d(g){if(g.uBioCommands){f(0)}else{b.resolve(g)}function f(i){b.notify("progress",i+1,g.commands.length+2);if(i>=g.commands.length){a()}else{var l=g.commands[i];b.notify("message",l.title);var k={cache:true,dataType:"json",type:"GET",url:l.url};$.ajax(k).fail(h).done(j)}function h(m){b.notify("fault",m);f(i+1)}function j(){f(i+1)}}}function a(){b.notify("message","Loading taxonomy");pp.api.name.taxonomy(e,"immediate","immediate",false,c).fail(b.reject).done(b.resolve)}};pp.page={};pp.page.name=function(b){var h=["credit","licenseURL","pngFiles","taxa","html"];var i=false;var c=pp.api.name.images(b.uid,false,false,false,h).done(g).done(a).always(e);pp.ui.progress(c,$("#illustration .status"),"Loading images");function j(){var k=$('<a href="#" class="btn btn-primary pull-right">Search for Related Images</a>');k.prependTo($("#illustration"));k.click(function(){var l=pp.api.name.images(b.uid,true,true,false,h).done(a).done(function(){k.remove()});pp.ui.progress(l,$("#illustration .status"),"Searching for related images")})}function g(k){i=k.same.length>0}function f(m,k){k.show();if(k.children().length>0){$.when(k.children().slideUp("fast")).then(l)}else{l()}function l(){m.appendTo(k).hide().slideDown()}}function a(k){f(pp.view.image.sections(k),$("#illustration .content"))}function d(k){f(pp.view.name.sections(b,k),$("#taxonomy .content"))}function e(){var k=pp.api.name.taxonomyUBio(b.uid,["canonicalName","html","names","root","string"]).done(d).always(l);pp.ui.progress(k,$("#taxonomy .status"),"Loading taxonomy");function l(){if(i){j()}else{$("#illustration .content").children().remove();var m=pp.api.name.images(b.uid,true,false,false,h).done(a).always(j);pp.ui.progress(m,$("#illustration .status"),"Loading images")}}}};pp.ui={};pp.ui.progress=function(f,c,g){c=$(c);c.children().remove();var a=$('<div class="progress progress-striped active"></div>');var h=$('<div class="bar"></div>').css("width","5%").appendTo(a);var b=$("<div></div>");var j=$('<div class="alert alert-info"></div>').appendTo(b);$("<span>"+(g||"Please wait")+"...</span>").appendTo(j);a.appendTo(b);pp.ui.progress._tasks.push([f,c,b]);setTimeout("pp.ui.progress._runTasks()",250);f.progress(i).fail(d).then(e);function e(){$.when(b.slideUp("fast")).then(function(){b.remove()})}function d(l,n){var m=$('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a></div>');var k="Warning";if(!n){m.addClass("alert-error");k="Error"}$('<h4 class="alert-heading">'+k+"!</h4>").appendTo(m);$("<span></span>").text(l.message).appendTo(m);m.appendTo(c)}function i(m,l,k){if(m=="fault"){d(l,true)}else{if(m=="message"){j.children().remove();$("<span>"+l+"...</span>").appendTo(j)}else{if(m=="progress"){if(k>0){h.width(String(Math.max(5,Math.floor(100*l/k)))+"%")}}}}}};pp.ui.progress._tasks=[];pp.ui.progress._runTasks=function(){var b=pp.ui.progress._tasks;var a;while(a=b.pop()){if(!a[0].isResolved()&&!a[0].isRejected()){a[2].appendTo(a[1]).hide().slideDown()}}};pp.view={};pp.view.image={};pp.view.image.link=function(f){var b=$('<div class="span1"></div>');var c=pp.view.image.thumb(f);if(c){var l=$('<a class="btn"></a>');l.attr("href","/image/"+f.uid);l.appendTo(b);var j=$('<img alt="" />');j.attr("src",c.url);j.attr("width",c.width);j.attr("height",c.height);var k=String((64-c.width)/2)+"px";j.css("margin-left",k);j.css("margin-right",k);j.css("margin-top",String(64-c.height)+"px");j.appendTo(l)}var e=f.credit;if(e&&e.length>0){if(e.length>=32&&false){var g=e.split(/\s+/g);var m=[];for(var h=0;h<g.length;++h){m.push(g[h]);if(m.join(" ").length>=32){if(m.length>1){m.pop()}break}}e=m.join(" ")+"\u2026"}var d=$('<p style="text-align:center;font-size:10px;margin-top:10px;line-height:1"></p>');d.text(e);d.appendTo(b)}return b};pp.view.image.list=function(a){var e=$("<div></div>");var f=null;var c=0;for(var b=0;b<a.length;++b){var d=a[b];if(!f){f=$('<div class="row"></div>')}pp.view.image.link(d).appendTo(f);if(++c>=12){c=0;f.appendTo(e);f=null}}if(f){f.appendTo(e)}return e};pp.view.image.sections=function(f,a){var d={same:null,supertaxa:"Supertaxa",subtaxa:"Subtaxa",other:"Related Taxa"};if(!a){a="illustration"}var b=$("<div></div>");var i=false;for(var e in d){var c=f[e];if(c.length>0){i=true;var h=$("<section></section>");h.attr("id",[a,e].join("-"));var g=d[e];if(g){$("<h3>"+g+"</h3>").appendTo(h)}pp.view.image.list(c).appendTo(h);h.appendTo(b)}}if(!i){$("<p>No images found.</p>").appendTo(b)}return b};pp.view.image.thumb=function(e){if(!e||!e.pngFiles){return null}var d=Number.POSITIVE_INFINITY;var a=null;for(var c=0;c<e.pngFiles.length;++c){var b=e.pngFiles[c];if(b.width<d){a=b;d=b.width}}return a};pp.view.name={};pp.view.name.link=function(c){var b=$('<a class="btn nomen span2">'+c.html+"</a>");b.attr("href","/name/"+c.uid);return b};pp.view.name.list=function(e){var d=$("<div></div>");var f=null;var c=0;for(var b=0;b<e.length;++b){var a=e[b];if(!f){f=$('<div class="row"></div>')}pp.view.name.link(a).appendTo(f);if(++c>=6){c=0;f.appendTo(d);f=null}}if(f){f.appendTo(d)}return d};pp.view.name.sections=function(c,d,a){if(!a){a="taxonomy-"}var f=[];var l=[];var k=[];var j=e(c.uid,d.taxa);if(j>=0){k=d.taxa[j].names;var g;for(g=0;g<k.length;++g){if(k[g].uid===c.uid){k.splice(g,1);break}}for(g=0;g<d.inclusions.length;++g){var o=d.inclusions[g];if(o[0]===j){l.push(d.taxa[o[1]])}else{if(o[1]===j){f.push(d.taxa[o[0]])}}}}f.sort(h);l.sort(h);k.sort(m);var b=$("<div></div>");var n=$('<section id="'+a+'-supertaxa"><h3>Supertaxa</h3></section>');if(f.length>0){pp.view.taxon.list(f).appendTo(n)}n.appendTo(b);if(l.length>0){n=$('<section id="'+a+'-subtaxa"><h3>Subtaxa</h3></section>');pp.view.taxon.list(l).appendTo(n);n.appendTo(b)}if(k.length>0){n=$('<section id="'+a+'-synonyms"><h3>Synonyms</h3></section>');pp.view.name.list(k).appendTo(n);n.appendTo(b)}return b;function m(p,i){if(p.string.toUpperCase()<i.string.toUpperCase()){return -1}if(i.string.toUpperCase()<p.string.toUpperCase()){return 1}if(p.string<i.string){return -1}if(i.string<p.string){return 1}return 0}function h(p,i){return m(p.canonicalName,i.canonicalName)}function e(){for(g=0;g<d.taxa.length;++g){var p=d.taxa[g];for(var i=0;i<p.names.length;++i){if(p.names[i].uid===c.uid){return g}}}return -1}};pp.view.taxon={};pp.view.taxon.list=function(a){var e=$("<div></div>");var f=null;var d=0;for(var c=0;c<a.length;++c){var b=a[c];if(!f){f=$('<div class="row"></div>')}pp.view.name.link(b.canonicalName).appendTo(f);if(++d>=6){d=0;f.appendTo(e);f=null}}if(f){f.appendTo(e)}return e};
+var pp={};pp.ajax=function(a){var b=$.Deferred();$.ajax(a).fail(function(e,d,c){b.reject({code:d?d:"fail",message:(c?String(c):"Error loading data")+".",details:e})}).done(function(c){try{if(c.success){b.resolve(c.result)}else{b.reject(c.fault)}}catch(d){alert(d)}});return b};pp.api={};pp.api.name={};pp.api.name.images=function(c,g,f,a,b){var e={};if(g!==null){e.supertaxa=g?"true":"false"}if(f!==null){e.subtaxa=f?"true":"false"}if(a!==null){e.other=a?"true":"false"}if(b&&b.length>0){e.options=b.join(" ")}var d={cache:true,data:e,dataType:"json",url:"/api/a/name/"+$.trim(c)+"/images"};return pp.ajax(d)};pp.api.name.taxonomy=function(b,g,f,d,a){var e={};if(g){e.supertaxa=g}if(f){e.subtaxa=f}if(d!==null){e.useUBio=d?"true":"false"}if(a&&a.length>0){e.options=a.join(" ")}var c={cache:true,data:e,dataType:"json",type:"GET",url:"/api/a/name/"+b+"/taxonomy"};return pp.ajax(c)};pp.api.name.taxonomySources=function(b,a){var d=null;if(a&&a.length>0){d={options:a.join(" ")}}var c={cache:true,data:d,dataType:"json",type:"GET",url:"/api/a/name/"+$.trim(b)+"/taxonomy/sources"};return pp.ajax(c)};pp.api.name.taxonomyUBio=function(e,c){var b=$.Deferred();pp.api.name.taxonomy(e,"immediate","immediate",true,c).fail(b.reject).done(d);return b;function d(g){if(g.uBioCommands){f(0)}else{b.resolve(g)}function f(i){b.notify("progress",i+1,g.commands.length+2);if(i>=g.commands.length){a()}else{var l=g.commands[i];b.notify("message",l.title);var k={cache:true,dataType:"json",type:"GET",url:l.url};$.ajax(k).fail(h).done(j)}function h(m){b.notify("fault",m);f(i+1)}function j(){f(i+1)}}}function a(){b.notify("message","Loading taxonomy");pp.api.name.taxonomy(e,"immediate","immediate",false,c).fail(b.reject).done(b.resolve)}};pp.page={};pp.page.name=function(b){var h=["credit","licenseURL","pngFiles","taxa","html"];var i=false;var c=pp.api.name.images(b.uid,false,false,false,h).done(g).done(a).always(e);pp.ui.progress(c,$("#illustration .status"),"Loading images");function j(){var k=$('<a href="#" class="btn btn-primary pull-right">Search for Related Images</a>');k.prependTo($("#illustration"));k.click(function(){var l=pp.api.name.images(b.uid,true,true,false,h).done(a).done(function(){k.remove()});pp.ui.progress(l,$("#illustration .status"),"Searching for related images")})}function g(k){i=k.same.length>0}function f(m,k){k.show();if(k.children().length>0){$.when(k.children().slideUp("fast")).then(l)}else{l()}function l(){m.appendTo(k).hide().slideDown()}}function a(k){f(pp.view.image.sections(k),$("#illustration .content"))}function d(k){f(pp.view.name.sections(b,k),$("#taxonomy .content"))}function e(){var k=pp.api.name.taxonomyUBio(b.uid,["canonicalName","html","names","root","string"]).done(d).always(l);pp.ui.progress(k,$("#taxonomy .status"),"Loading taxonomy");function l(){if(i){j()}else{$("#illustration .content").children().remove();var m=pp.api.name.images(b.uid,true,false,false,h).done(a).always(j);pp.ui.progress(m,$("#illustration .status"),"Loading images")}}}};pp.ui={};pp.ui.progress=function(f,c,g){c=$(c);c.children().remove();var a=$('<div class="progress progress-striped active"></div>');var h=$('<div class="bar"></div>').css("width","5%").appendTo(a);var b=$("<div></div>");var j=$('<div class="alert alert-info"></div>').appendTo(b);$("<span>"+(g||"Please wait")+"...</span>").appendTo(j);a.appendTo(b);pp.ui.progress._tasks.push([f,c,b]);setTimeout("pp.ui.progress._runTasks()",250);f.progress(i).fail(d).then(e);function e(){$.when(b.slideUp("fast")).then(function(){b.remove()})}function d(l,n){var m=$('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a></div>');var k="Warning";if(!n){m.addClass("alert-error");k="Error"}$('<h4 class="alert-heading">'+k+"!</h4>").appendTo(m);$("<span></span>").text(l.message).appendTo(m);m.appendTo(c)}function i(m,l,k){if(m=="fault"){d(l,true)}else{if(m=="message"){j.children().remove();$("<span>"+l+"...</span>").appendTo(j)}else{if(m=="progress"){if(k>0){h.width(String(Math.max(5,Math.floor(100*l/k)))+"%")}}}}}};pp.ui.progress._tasks=[];pp.ui.progress._runTasks=function(){var b=pp.ui.progress._tasks;var a;while(a=b.pop()){if(!a[0].isResolved()&&!a[0].isRejected()){a[2].appendTo(a[1]).hide().slideDown()}}};pp.view={};pp.view.image={};pp.view.image.link=function(f){var b=$('<div class="span1"></div>');var c=pp.view.image.thumb(f);if(c){var l=$('<a class="btn"></a>');l.attr("href","/image/"+f.uid);l.appendTo(b);var j=$('<img alt="" />');j.attr("src",c.url);j.attr("width",c.width);j.attr("height",c.height);var k=String((64-c.width)/2)+"px";j.css("margin-left",k);j.css("margin-right",k);j.css("margin-top",String(64-c.height)+"px");j.appendTo(l)}var e=f.credit;if(e&&e.length>0){if(e.length>=32&&false){var g=e.split(/\s+/g);var m=[];for(var h=0;h<g.length;++h){m.push(g[h]);if(m.join(" ").length>=32){if(m.length>1){m.pop()}break}}e=m.join(" ")+"\u2026"}var d=$('<p style="text-align:center;font-size:10px;margin-top:10px;line-height:1"></p>');d.text(e);d.appendTo(b)}return b};pp.view.image.list=function(a){var e=$("<div></div>");var f=null;var c=0;for(var b=0;b<a.length;++b){var d=a[b];if(!f){f=$('<div class="row"></div>')}pp.view.image.link(d).appendTo(f).hide().delay(b*100).fadeIn();if(++c>=12){c=0;f.appendTo(e);f=null}}if(f){f.appendTo(e)}return e};pp.view.image.sections=function(f,a){var d={same:null,supertaxa:"Supertaxa",subtaxa:"Subtaxa",other:"Related Taxa"};if(!a){a="illustration"}var b=$("<div></div>");var i=false;for(var e in d){var c=f[e];if(c.length>0){i=true;var h=$("<section></section>");h.attr("id",[a,e].join("-"));var g=d[e];if(g){$("<h3>"+g+"</h3>").appendTo(h)}pp.view.image.list(c).appendTo(h);h.appendTo(b)}}if(!i){$("<p>No images found.</p>").appendTo(b)}return b};pp.view.image.thumb=function(e){if(!e||!e.pngFiles){return null}var d=Number.POSITIVE_INFINITY;var a=null;for(var c=0;c<e.pngFiles.length;++c){var b=e.pngFiles[c];if(b.width<d){a=b;d=b.width}}return a};pp.view.name={};pp.view.name.link=function(c){var b=$('<a class="btn nomen span2">'+c.html+"</a>");b.attr("href","/name/"+c.uid);return b};pp.view.name.list=function(e){var d=$("<div></div>");var f=null;var c=0;for(var b=0;b<e.length;++b){var a=e[b];if(!f){f=$('<div class="row"></div>')}pp.view.name.link(a).appendTo(f);if(++c>=6){c=0;f.appendTo(d);f=null}}if(f){f.appendTo(d)}return d};pp.view.name.sections=function(c,d,a){if(!a){a="taxonomy-"}var f=[];var l=[];var k=[];var j=e(c.uid,d.taxa);if(j>=0){k=d.taxa[j].names;var g;for(g=0;g<k.length;++g){if(k[g].uid===c.uid){k.splice(g,1);break}}for(g=0;g<d.inclusions.length;++g){var o=d.inclusions[g];if(o[0]===j){l.push(d.taxa[o[1]])}else{if(o[1]===j){f.push(d.taxa[o[0]])}}}}f.sort(h);l.sort(h);k.sort(m);var b=$("<div></div>");var n=$('<section id="'+a+'-supertaxa"><h3>Supertaxa</h3></section>');if(f.length>0){pp.view.taxon.list(f).appendTo(n)}n.appendTo(b);if(l.length>0){n=$('<section id="'+a+'-subtaxa"><h3>Subtaxa</h3></section>');pp.view.taxon.list(l).appendTo(n);n.appendTo(b)}if(k.length>0){n=$('<section id="'+a+'-synonyms"><h3>Synonyms</h3></section>');pp.view.name.list(k).appendTo(n);n.appendTo(b)}return b;function m(p,i){if(p.string.toUpperCase()<i.string.toUpperCase()){return -1}if(i.string.toUpperCase()<p.string.toUpperCase()){return 1}if(p.string<i.string){return -1}if(i.string<p.string){return 1}return 0}function h(p,i){return m(p.canonicalName,i.canonicalName)}function e(){for(g=0;g<d.taxa.length;++g){var p=d.taxa[g];for(var i=0;i<p.names.length;++i){if(p.names[i].uid===c.uid){return g}}}return -1}};pp.view.taxon={};pp.view.taxon.list=function(a){var e=$("<div></div>");var f=null;var d=0;for(var c=0;c<a.length;++c){var b=a[c];if(!f){f=$('<div class="row"></div>')}pp.view.name.link(b.canonicalName).appendTo(f);if(++d>=6){d=0;f.appendTo(e);f=null}}if(f){f.appendTo(e)}return e};

File src/javascript/pp/view/image/list.js

 		if (!row)
 			row = $('<div class="row"></div>');
 		pp.view.image.link(image)
-			.appendTo(row);
+			.appendTo(row)
+			.hide()
+			.delay(i * 200)
+			.fadeIn();
 		if (++column >= 12)
 		{
 			column = 0;