From bb28464ebf99994ad2d6db53d2b7755e34bbe152 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 22 Feb 2015 20:11:23 +0100 Subject: [PATCH] Added pretty country flags to geoselector --- Site5/Automation/Json-GeographiesTree.aspx.cs | 23 +++++++++--------- Site5/Controls/v5/Base/ComboGeographies.ascx | 18 +++++++++++--- Site5/Images/Flags/gh-24px.png | Bin 0 -> 560 bytes Site5/Images/Flags/gh-64px.png | Bin 0 -> 1984 bytes Site5/Style/v5-easyui-elements.css | 4 +++ 5 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 Site5/Images/Flags/gh-24px.png create mode 100644 Site5/Images/Flags/gh-64px.png diff --git a/Site5/Automation/Json-GeographiesTree.aspx.cs b/Site5/Automation/Json-GeographiesTree.aspx.cs index b8c65b24..abb18c4c 100644 --- a/Site5/Automation/Json-GeographiesTree.aspx.cs +++ b/Site5/Automation/Json-GeographiesTree.aspx.cs @@ -19,12 +19,7 @@ namespace Swarmops.Frontend.Automation int parentGeographyId = 0; - bool initialExpand = true; - - if (Request.QueryString["InitialExpand"] == "false") - { - initialExpand = false; - } + bool initialExpand = (Request.QueryString["InitialExpand"] != "false"); string parentIdString = Request.QueryString["ParentGeographyId"]; if (!string.IsNullOrEmpty (parentIdString)) @@ -37,7 +32,7 @@ namespace Swarmops.Frontend.Automation string cacheKey = "Geographies-Json-" + parentGeographyId.ToString (CultureInfo.InvariantCulture) + "-" + Thread.CurrentThread.CurrentCulture.Name; - string accountsJson = (string) Cache[cacheKey]; + string accountsJson = null; // (string) Cache[cacheKey]; if (accountsJson != null) { @@ -92,6 +87,7 @@ namespace Swarmops.Frontend.Automation foreach (TreeNode geographyNode in geoBranch) { Geography geography = geographyNode.Data; + Country country = null; string geoName = TestLocalization (geography.Name); @@ -99,7 +95,8 @@ namespace Swarmops.Frontend.Automation { // Special case for country nodes: "[NativeName] ([LocalizedName])", e.g. "Deutschland (Tyskland)" for Germany when in Swedish - string localizedCountryName = GeographyNames.ResourceManager.GetString("Country_" + _countryLookup[geography.Identity].Code); + country = _countryLookup[geography.Identity]; + string localizedCountryName = GeographyNames.ResourceManager.GetString("Country_" + country.Code); string nativeCountryName = geography.Name.Split ('(')[0].Trim(); if (localizedCountryName != nativeCountryName) @@ -115,13 +112,15 @@ namespace Swarmops.Frontend.Automation string element = string.Format ("\"id\":{0},\"text\":\"{1}\"", geography.Identity, JsonSanitize (TestLocalization (geoName))); - if (_countryLookup.ContainsKey (geography.Identity)) + if (country != null) { - // this is a country node. Populate with stuff to enable lazy-load of the tree. - Country country = _countryLookup[geography.Identity]; + // this is a country node. Populate with stuff to enable lazy-load of the tree at this point. element += ",\"children1\":\"\",\"state\":\"closed\"," + - string.Format ("\"countryId\":\"{0}\",\"countryNode\":\"{1}\"", country.Code, geography.Identity); + string.Format ("\"countryId\":\"{0}\",\"countryNode\":\"{1}\"", country.Code.ToLowerInvariant(), geography.Identity); + + // Suppress icon to reaplce with flag + element += ",\"iconCls\":\"countryNode\""; } else if (geographyNode.Children.Count > 0) { diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx b/Site5/Controls/v5/Base/ComboGeographies.ascx index 5b4dbb78..88712729 100644 --- a/Site5/Controls/v5/Base/ComboGeographies.ascx +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx @@ -19,15 +19,25 @@ } else { $.getJSON("/Automation/Json-GeographiesTree.aspx?InitialExpand=false&ParentGeographyId=" + param.id, null, success); } - } - <% + }, + onSelect: function (row) { + <% if (!String.IsNullOrEmpty(this.OnClientSelect)) { - Response.Write(", onSelect: function(row) { " + this.OnClientSelect + "(row.id); }"); + Response.Write(this.OnClientSelect + "(row.id);"); } %> - }); + }, + formatter: function (row) { + // If we're at a country node, add that country's flag ahead of the country name. Replaces the folder icon (that part is done in CSS). + + if (row.countryId != null) { + return " " + row.text; + } + else return row.text; + } + }); $('#<%=this.ClientID %>_SpanGeographies span.combo input.combo-text').click(function () { $('#<%=this.ClientID %>_SpanGeographies span.combo span span.combo-arrow').click(); diff --git a/Site5/Images/Flags/gh-24px.png b/Site5/Images/Flags/gh-24px.png new file mode 100644 index 0000000000000000000000000000000000000000..4fcc198c43a5b77b3ca0ee891746b249809bdda8 GIT binary patch literal 560 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbQ|PfiXM4C&U%V{r~?z10y3c+GOOg z)yQ$Xk>gGy$K7DG&d~l|YyX4Vj>oP2&w8dkpD^piq}eYf&wVj<{>$kL=JU(nD6GAi zn14Gd|87$Ly`+M9{PI`Rif%+_+=|Y;9i4e6I%_V!{Q01St3e6ZgA#%0Mo{9udBU&H z`h33P^Yxm~x9h&&ulruxJj?Q-6J2Y&j->eZh1W!E86d9Cv{nH-TJtCO>`N6bGJkC!S1a-b`mE zUww`Q8;%q^&QyEOGzX3}dnO+})>uo{L~GV08`fkXvSsx%V2`unNVE}1cNWX>kS_3* zDfE*s3Q#BxR4fVN2{ji8w-SuB5sbDGjIjkHJH8nGa$spSz978nDuf6Ea*Py_|a^aeYN!xRp>S~{%4PwPpcj)?A~g9 kVA6e=kb-Rt`v3nhX_@Exu~eDV04-+lboFyt=akR{04RplR{#J2 literal 0 HcmV?d00001 diff --git a/Site5/Images/Flags/gh-64px.png b/Site5/Images/Flags/gh-64px.png new file mode 100644 index 0000000000000000000000000000000000000000..9653c86c252e0cebf8bf2d8dfe6a7cc0e25e06b5 GIT binary patch literal 1984 zcmV;x2S50UP)E(QMnM=5m%5Qr z(1jUXxNtGJ5)?6t7-tlOVL%)mHIqzYW|HnsS9RTcj*D~Ot5==ZiFS8k=&sYedaqu+ zdUfx2zw_Pip4YI9Wh`SE%UH%Tma&XwEaM=Clzsi<2hUCqQpZ1a>+b^~)#d$)10TNd zEcwbcR012>38JGRIvPP;A$1k!sv0Ej)|}feJmqrWcuuo(DPxlfKH2=A+vMfd9IDf& z`1xnQ0I&kAH2~BONH)^-8>sB8^Y?Q&VD8kXP82|>+ZO;=WqNCs>A&|k0E4wPP;JlG z-HXz->)873mah9P%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