From 239110a2bc1744418a58d06914a3ff652c7470df Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 28 Dec 2012 23:28:53 +0100 Subject: [PATCH 1/5] Change acl selection box templating Keep dynamic templating in javascript so browsers don't prefetch non-existing files. --- js/acl.js | 2 +- view/acl_selector.tpl | 1 - view/smarty3/acl_selector.tpl | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/js/acl.js b/js/acl.js index e383224ca..4f4325284 100644 --- a/js/acl.js +++ b/js/acl.js @@ -247,7 +247,7 @@ ACL.prototype.populate = function(data){ var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height); $(data.items).each(function(){ - html = "
"+that.item_tpl+"
"; + html = "

{1}

"+that.item_tpl+"
"; html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); diff --git a/view/acl_selector.tpl b/view/acl_selector.tpl index 655ea8980..e2b85e36b 100644 --- a/view/acl_selector.tpl +++ b/view/acl_selector.tpl @@ -9,7 +9,6 @@ diff --git a/view/smarty3/acl_selector.tpl b/view/smarty3/acl_selector.tpl index 52f0573c8..bc669a2ac 100644 --- a/view/smarty3/acl_selector.tpl +++ b/view/smarty3/acl_selector.tpl @@ -9,7 +9,6 @@ From a41692120e92e0b8afc73be24994cd6985a8b110 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 28 Dec 2012 23:51:40 +0100 Subject: [PATCH 2/5] Also change acl stuff in the other themes --- view/theme/frost-mobile/acl_selector.tpl | 1 - view/theme/frost-mobile/js/acl.js | 2 +- view/theme/frost-mobile/smarty3/acl_selector.tpl | 1 - view/theme/frost/acl_selector.tpl | 1 - view/theme/frost/js/acl.js | 2 +- view/theme/frost/smarty3/acl_selector.tpl | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/view/theme/frost-mobile/acl_selector.tpl b/view/theme/frost-mobile/acl_selector.tpl index 327f18b65..e79a6891a 100644 --- a/view/theme/frost-mobile/acl_selector.tpl +++ b/view/theme/frost-mobile/acl_selector.tpl @@ -9,7 +9,6 @@ diff --git a/view/theme/frost-mobile/js/acl.js b/view/theme/frost-mobile/js/acl.js index 65b2d3829..6feded6ab 100644 --- a/view/theme/frost-mobile/js/acl.js +++ b/view/theme/frost-mobile/js/acl.js @@ -247,7 +247,7 @@ ACL.prototype.populate = function(data){ /* var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height);*/ $j(data.items).each(function(){ - html = "
"+that.item_tpl+"
"; + html = "

{1}

"+that.item_tpl+"
"; html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); diff --git a/view/theme/frost-mobile/smarty3/acl_selector.tpl b/view/theme/frost-mobile/smarty3/acl_selector.tpl index 5b330de91..361bf8843 100644 --- a/view/theme/frost-mobile/smarty3/acl_selector.tpl +++ b/view/theme/frost-mobile/smarty3/acl_selector.tpl @@ -9,7 +9,6 @@ diff --git a/view/theme/frost/acl_selector.tpl b/view/theme/frost/acl_selector.tpl index 327f18b65..e79a6891a 100644 --- a/view/theme/frost/acl_selector.tpl +++ b/view/theme/frost/acl_selector.tpl @@ -9,7 +9,6 @@ diff --git a/view/theme/frost/js/acl.js b/view/theme/frost/js/acl.js index 9675588af..0f080cfe1 100644 --- a/view/theme/frost/js/acl.js +++ b/view/theme/frost/js/acl.js @@ -247,7 +247,7 @@ ACL.prototype.populate = function(data){ var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height); $j(data.items).each(function(){ - html = "
"+that.item_tpl+"
"; + html = "

{1}

"+that.item_tpl+"
"; html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); diff --git a/view/theme/frost/smarty3/acl_selector.tpl b/view/theme/frost/smarty3/acl_selector.tpl index 5b330de91..361bf8843 100644 --- a/view/theme/frost/smarty3/acl_selector.tpl +++ b/view/theme/frost/smarty3/acl_selector.tpl @@ -9,7 +9,6 @@ From 94c8d7693fd43b75018dcab866affd7606a56a9c Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Sat, 29 Dec 2012 23:44:26 +0100 Subject: [PATCH 3/5] Keep html in template, use data attribute for img Revert previous changes to fix browser preloading a template variable as image. Images use a data attribute within templates as src. Javascript will substitute them. --- js/acl.js | 9 +++++++-- view/acl_selector.tpl | 1 + view/smarty3/acl_selector.tpl | 1 + view/theme/frost-mobile/acl_selector.tpl | 1 + view/theme/frost-mobile/js/acl.js | 7 ++++++- view/theme/frost-mobile/smarty3/acl_selector.tpl | 1 + view/theme/frost/js/acl.js | 7 ++++++- view/theme/frost/smarty3/acl_selector.tpl | 1 + 8 files changed, 24 insertions(+), 4 deletions(-) diff --git a/js/acl.js b/js/acl.js index 4f4325284..36cf74970 100644 --- a/js/acl.js +++ b/js/acl.js @@ -247,12 +247,17 @@ ACL.prototype.populate = function(data){ var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height); $(data.items).each(function(){ - html = "

{1}

"+that.item_tpl+"
"; - html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); + html = "
"+that.item_tpl+"
"; + html = html.format(this.photo, this.name, this.type, this.id, '', this.network, this.link); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); that.list_content.append(html); }); + $(".acl-list-item img[data-src]").each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); that.update_view(); } diff --git a/view/acl_selector.tpl b/view/acl_selector.tpl index e2b85e36b..837225a5b 100644 --- a/view/acl_selector.tpl +++ b/view/acl_selector.tpl @@ -9,6 +9,7 @@ diff --git a/view/smarty3/acl_selector.tpl b/view/smarty3/acl_selector.tpl index bc669a2ac..e9f8030d7 100644 --- a/view/smarty3/acl_selector.tpl +++ b/view/smarty3/acl_selector.tpl @@ -9,6 +9,7 @@ diff --git a/view/theme/frost-mobile/acl_selector.tpl b/view/theme/frost-mobile/acl_selector.tpl index e79a6891a..df34a1a2a 100644 --- a/view/theme/frost-mobile/acl_selector.tpl +++ b/view/theme/frost-mobile/acl_selector.tpl @@ -9,6 +9,7 @@ diff --git a/view/theme/frost-mobile/js/acl.js b/view/theme/frost-mobile/js/acl.js index 6feded6ab..20f0d4618 100644 --- a/view/theme/frost-mobile/js/acl.js +++ b/view/theme/frost-mobile/js/acl.js @@ -247,12 +247,17 @@ ACL.prototype.populate = function(data){ /* var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height);*/ $j(data.items).each(function(){ - html = "

{1}

"+that.item_tpl+"
"; + html = "
"+that.item_tpl+"
"; html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); that.list_content.append(html); }); + $(".acl-list-item img[data-src]").each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); that.update_view(); } diff --git a/view/theme/frost-mobile/smarty3/acl_selector.tpl b/view/theme/frost-mobile/smarty3/acl_selector.tpl index 361bf8843..f3b1abea7 100644 --- a/view/theme/frost-mobile/smarty3/acl_selector.tpl +++ b/view/theme/frost-mobile/smarty3/acl_selector.tpl @@ -9,6 +9,7 @@ diff --git a/view/theme/frost/js/acl.js b/view/theme/frost/js/acl.js index 0f080cfe1..6b443b248 100644 --- a/view/theme/frost/js/acl.js +++ b/view/theme/frost/js/acl.js @@ -247,12 +247,17 @@ ACL.prototype.populate = function(data){ var height = Math.ceil(data.tot / that.nw) * 42; that.list_content.height(height); $j(data.items).each(function(){ - html = "

{1}

"+that.item_tpl+"
"; + html = "
"+that.item_tpl+"
"; html = html.format( this.photo, this.name, this.type, this.id, '', this.network, this.link ); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); that.list_content.append(html); }); + $(".acl-list-item img[data-src]").each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); that.update_view(); } diff --git a/view/theme/frost/smarty3/acl_selector.tpl b/view/theme/frost/smarty3/acl_selector.tpl index 361bf8843..f3b1abea7 100644 --- a/view/theme/frost/smarty3/acl_selector.tpl +++ b/view/theme/frost/smarty3/acl_selector.tpl @@ -9,6 +9,7 @@ From dbf8f711cffbc7b659a06856b2301820c66274ca Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Sun, 30 Dec 2012 00:28:48 +0100 Subject: [PATCH 4/5] Fix browser prefetch in notifications menu Fix browser prefetch by substituting data-src with src for images --- js/main.js | 10 ++++++++-- view/nav.tpl | 2 +- view/smarty3/nav.tpl | 2 +- view/theme/cleanzero/nav.tpl | 2 +- view/theme/cleanzero/smarty3/nav.tpl | 2 +- view/theme/diabook/nav.tpl | 2 +- view/theme/diabook/smarty3/nav.tpl | 2 +- view/theme/dispy/nav.tpl | 2 +- view/theme/dispy/smarty3/nav.tpl | 2 +- view/theme/duepuntozero/nav.tpl | 2 +- view/theme/duepuntozero/smarty3/nav.tpl | 2 +- view/theme/facepark/nav.tpl | 2 +- view/theme/facepark/smarty3/nav.tpl | 2 +- view/theme/frost-mobile/js/main.js | 6 ++++++ view/theme/frost-mobile/nav.tpl | 2 +- view/theme/frost-mobile/smarty3/nav.tpl | 2 +- view/theme/frost/js/main.js | 6 ++++++ view/theme/frost/nav.tpl | 2 +- view/theme/frost/smarty3/nav.tpl | 2 +- view/theme/quattro/nav.tpl | 2 +- view/theme/quattro/smarty3/nav.tpl | 2 +- view/theme/smoothly/nav.tpl | 2 +- view/theme/smoothly/smarty3/nav.tpl | 2 +- view/theme/testbubble/nav.tpl | 2 +- view/theme/testbubble/smarty3/nav.tpl | 2 +- view/theme/vier/nav.tpl | 2 +- view/theme/vier/smarty3/nav.tpl | 2 +- 27 files changed, 44 insertions(+), 26 deletions(-) diff --git a/js/main.js b/js/main.js index 4a75be747..5cdf2a080 100644 --- a/js/main.js +++ b/js/main.js @@ -181,7 +181,14 @@ html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen')); nnm.append(html); }); + + $("img[data-src]", nnm).each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); } + notif = eNotif.attr('count'); if (notif>0){ $("#nav-notifications-linkmenu").addClass("on"); @@ -202,8 +209,7 @@ }); }); - - + NavUpdate(); // Allow folks to stop the ajax page updates with the pause/break key $(document).keydown(function(event) { diff --git a/view/nav.tpl b/view/nav.tpl index 8969accb7..04c4931fc 100644 --- a/view/nav.tpl +++ b/view/nav.tpl @@ -64,5 +64,5 @@ diff --git a/view/smarty3/nav.tpl b/view/smarty3/nav.tpl index 832d9f123..7f7bb6290 100644 --- a/view/smarty3/nav.tpl +++ b/view/smarty3/nav.tpl @@ -64,5 +64,5 @@ diff --git a/view/theme/cleanzero/nav.tpl b/view/theme/cleanzero/nav.tpl index 981f975c9..17a2f7259 100644 --- a/view/theme/cleanzero/nav.tpl +++ b/view/theme/cleanzero/nav.tpl @@ -69,7 +69,7 @@