Changes to support collapsible/expandable property groups on the profile pages.
This commit is contained in:
parent
b0a5961f4d
commit
c9a27d7f11
5 changed files with 157 additions and 0 deletions
10
webapp/web/js/amplify/amplify.store.min.js
vendored
Normal file
10
webapp/web/js/amplify/amplify.store.min.js
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*!
|
||||
* Amplify Store - Persistent Client-Side Storage 1.1.0
|
||||
*
|
||||
* Copyright 2011 appendTo LLC. (http://appendto.com/team)
|
||||
* Dual licensed under the MIT or GPL licenses.
|
||||
* http://appendto.com/open-source-licenses
|
||||
*
|
||||
* http://amplifyjs.com
|
||||
*/
|
||||
(function(a,b){function e(a,e){c.addType(a,function(f,g,h){var i,j,k,l,m=g,n=(new Date).getTime();if(!f){m={},l=[],k=0;try{f=e.length;while(f=e.key(k++))d.test(f)&&(j=JSON.parse(e.getItem(f)),j.expires&&j.expires<=n?l.push(f):m[f.replace(d,"")]=j.data);while(f=l.pop())e.removeItem(f)}catch(o){}return m}f="__amplify__"+f;if(g===b){i=e.getItem(f),j=i?JSON.parse(i):{expires:-1};if(j.expires&&j.expires<=n)e.removeItem(f);else return j.data}else if(g===null)e.removeItem(f);else{j=JSON.stringify({data:g,expires:h.expires?n+h.expires:null});try{e.setItem(f,j)}catch(o){c[a]();try{e.setItem(f,j)}catch(o){throw c.error()}}}return m})}var c=a.store=function(a,b,d,e){var e=c.type;d&&d.type&&d.type in c.types&&(e=d.type);return c.types[e](a,b,d||{})};c.types={},c.type=null,c.addType=function(a,b){c.type||(c.type=a),c.types[a]=b,c[a]=function(b,d,e){e=e||{},e.type=a;return c(b,d,e)}},c.error=function(){return"amplify.store quota exceeded"};var d=/^__amplify__/;for(var f in{localStorage:1,sessionStorage:1})try{window[f].getItem&&e(f,window[f])}catch(g){}if(window.globalStorage)try{e("globalStorage",window.globalStorage[window.location.hostname]),c.type==="sessionStorage"&&(c.type="globalStorage")}catch(g){}(function(){if(!c.types.localStorage){var a=document.createElement("div"),d="amplify";a.style.display="none",document.getElementsByTagName("head")[0].appendChild(a);try{a.addBehavior("#default#userdata"),a.load(d)}catch(e){a.parentNode.removeChild(a);return}c.addType("userData",function(e,f,g){a.load(d);var h,i,j,k,l,m=f,n=(new Date).getTime();if(!e){m={},l=[],k=0;while(h=a.XMLDocument.documentElement.attributes[k++])i=JSON.parse(h.value),i.expires&&i.expires<=n?l.push(h.name):m[h.name]=i.data;while(e=l.pop())a.removeAttribute(e);a.save(d);return m}e=e.replace(/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g,"-");if(f===b){h=a.getAttribute(e),i=h?JSON.parse(h):{expires:-1};if(i.expires&&i.expires<=n)a.removeAttribute(e);else return i.data}else f===null?a.removeAttribute(e):(j=a.getAttribute(e),i=JSON.stringify({data:f,expires:g.expires?n+g.expires:null}),a.setAttribute(e,i));try{a.save(d)}catch(o){j===null?a.removeAttribute(e):a.setAttribute(e,j),c.userData();try{a.setAttribute(e,i),a.save(d)}catch(o){j===null?a.removeAttribute(e):a.setAttribute(e,j);throw c.error()}}return m})}})(),function(){function e(a){return a===b?b:JSON.parse(JSON.stringify(a))}var a={},d={};c.addType("memory",function(c,f,g){if(!c)return e(a);if(f===b)return e(a[c]);d[c]&&(clearTimeout(d[c]),delete d[c]);if(f===null){delete a[c];return null}a[c]=f,g.expires&&(d[c]=setTimeout(function(){delete a[c],delete d[c]},g.expires));return f})}()})(this.amplify=this.amplify||{})
|
115
webapp/web/js/individual/propertyGroupControls.js
Normal file
115
webapp/web/js/individual/propertyGroupControls.js
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$.extend(this, individualLocalName);
|
||||
|
||||
retrieveLocalStorage();
|
||||
|
||||
// expands/collapses the div within each property group
|
||||
$.each($('section.property-group'), function() {
|
||||
var groupName = $(this).attr("id");
|
||||
$(this).children("nav").children("img").click(function() {
|
||||
if ( $("div[id='" + groupName + "Group']").is(":visible") ) {
|
||||
$("div[id='" + groupName + "Group']").slideUp(222);
|
||||
$(this).attr("src", $(this).attr("src").replace("collapse-prop-group","expand-prop-group"));
|
||||
$("section#" + groupName).children("h2").removeClass("expandedPropGroupH2");
|
||||
}
|
||||
else {
|
||||
$("div[id='" + groupName + "Group']").slideDown(222);
|
||||
$(this).attr("src", $(this).attr("src").replace("expand-prop-group","collapse-prop-group"));
|
||||
$("section#" + groupName).children("h2").addClass("expandedPropGroupH2");
|
||||
}
|
||||
manageLocalStorage();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// expands/collapses all property groups together
|
||||
$.each($('a#propertyGroupsToggle'), function() {
|
||||
$('a#propertyGroupsToggle').click(function() {
|
||||
var anchorHtml = $(this).html();
|
||||
if ( anchorHtml.indexOf('expand') > -1 ) {
|
||||
$.each($('section.property-group'), function() {
|
||||
$("div[id='" + $(this).attr("id") + "Group']").slideDown(222);
|
||||
var innerSrc = $(this).children("nav").children("img").attr("src");
|
||||
$(this).children("nav").children("img").attr("src",innerSrc.replace("expand-prop-group","collapse-prop-group"));
|
||||
$(this).children("h2").addClass("expandedPropGroupH2");
|
||||
});
|
||||
$(this).html("collapse all");
|
||||
}
|
||||
else {
|
||||
$.each($('section.property-group'), function() {
|
||||
$("div[id='" + $(this).attr("id") + "Group']").slideUp(222);
|
||||
var innerSrc = $(this).children("nav").children("img").attr("src");
|
||||
$(this).children("nav").children("img").attr("src",innerSrc.replace("collapse-prop-group","expand-prop-group"));
|
||||
$(this).children("h2").removeClass("expandedPropGroupH2");
|
||||
});
|
||||
$(this).html("expand all");
|
||||
}
|
||||
manageLocalStorage();
|
||||
});
|
||||
});
|
||||
|
||||
// Next two functions -- keep track of which property group tabs have been expanded,
|
||||
// so if we return from a custom form or a related individual, even via the back button,
|
||||
// the property groups will be expanded as before.
|
||||
function manageLocalStorage() {
|
||||
var localName = this.individualLocalName;
|
||||
// is this individual already stored? If not, how many have been stored?
|
||||
// If the answer is 3, remove the first one in before adding the new one
|
||||
var current = amplify.store(localName);
|
||||
var profiles = amplify.store("profiles");
|
||||
if ( current == undefined ) {
|
||||
if ( profiles == undefined ) {
|
||||
var lnArray = [];
|
||||
lnArray.push(localName);
|
||||
amplify.store("profiles", lnArray);
|
||||
}
|
||||
else if ( profiles != undefined && profiles.length >= 3 ) {
|
||||
firstItem = profiles[0];
|
||||
amplify.store(firstItem, null);
|
||||
profiles.splice(0,1);
|
||||
profiles.push(localName);
|
||||
amplify.store("profiles", profiles)
|
||||
}
|
||||
else if ( profiles != undefined && profiles.length < 3 ) {
|
||||
profiles.push(localName);
|
||||
amplify.store("profiles", profiles)
|
||||
}
|
||||
}
|
||||
var groups = [];
|
||||
$.each($('section.property-group').children("nav").children("img"), function() {
|
||||
if ( $(this).attr('src').indexOf('collapse-prop-group') > -1 ) {
|
||||
groups.push($(this).attr('groupName'));
|
||||
}
|
||||
});
|
||||
amplify.store(localName, groups);
|
||||
var checkLength = amplify.store(localName);
|
||||
if ( checkLength.length == 0 ) {
|
||||
amplify.store(localName, null);
|
||||
}
|
||||
}
|
||||
|
||||
function retrieveLocalStorage() {
|
||||
var localName = this.individualLocalName;
|
||||
var groups = amplify.store(individualLocalName);
|
||||
if ( groups != undefined ) {
|
||||
for ( i = 0; i < groups.length; i++) {
|
||||
var groupName = groups[i];
|
||||
// unlikely, but it's possible a group that was previously opened and stored won't be displayed
|
||||
// because the object properties would have been deleted. So ensure that the group in local
|
||||
// storage has been rendered on the page. More likely, a user navigated from a quick view to a full
|
||||
// profile, opened a group, then navigated back to the quick view where the group isn't rendered.
|
||||
if ($("section#" + groupName).length ) {
|
||||
$("div[id='" + groupName + "Group']").slideDown(1);
|
||||
$("img[groupName='" + groupName + "']").attr("src", $("img[groupName='" + groupName + "']").attr("src").replace("expand-prop-group","collapse-prop-group"));
|
||||
$("section#" + groupName).children("h2").addClass("expandedPropGroupH2");
|
||||
}
|
||||
}
|
||||
if ( groups.length == $('section.property-group').length ) {
|
||||
$('a#propertyGroupsToggle').html('collapse all');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue