Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more robust checking of icon properties during grid constriuction, an…

…d slight cleanup of demo page
  • Loading branch information...
commit 88b97962b62a6f77aff8a104f4ab66922c2a8216 1 parent 9128cad
@dwalkowski dwalkowski authored
Showing with 39 additions and 18 deletions.
  1. +35 −15 icongrid/icongrid.js
  2. +4 −3 index.html
View
50 icongrid/icongrid.js
@@ -168,7 +168,7 @@ IconGrid.prototype = {
var self = this;
if (!self.dashboardState.pages[pageIdx]) {
- //console.log("OWA: ERROR!! non-existent page index: " + pageIdx);
+ console.log("OWA: ERROR!! non-existent page index: " + pageIdx);
return null;
}
//use scratch pages to avoid allocation while dragging
@@ -351,8 +351,8 @@ IconGrid.prototype = {
},
_onMouseMove: function (e) {
- //too noisy
- ////console.log("mouse move");
+ //very noisy
+ //console.log("mouse move");
var self = this;
// slightly hokey caching of last mousemove event (the position is what we care about) for the case
@@ -927,18 +927,20 @@ IconGrid.prototype = {
var clickyIcon = $("<div/>").addClass("icon");
clickyIcon.attr("guid", guid);
-
-
- clickyIcon.css({
-
- });
+ clickyIcon.css({ });
//first see if the item itself has an 'imgURL'
- var imgURL = theItem.itemImgURL;
- //if it doesn't, ask the datasource for it
- if (!imgURL && self.datasource.getItemImgURL) {
- imgURL = self.datasource.getItemImgURL(Base32.decode(guid));
+ var imgURL;
+ try {
+ if (theItem && theItem.itemImgURL) {
+ imgURL = theItem.itemImgURL;
+ } else if (self.datasource.getItemImgURL) {
+ imgURL = self.datasource.getItemImgURL(Base32.decode(guid));
+ }
+ } catch (e) {
+ console.log("exception getting icon for guid: " + guid + " : " + e);
}
+
//if we still don't have one, use a generic gray icon as a placeholder
if (!imgURL) {
imgURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAC7mlDQ1BJQ0MgUHJvZmlsZQAAeAGFVM9rE0EU/jZuqdAiCFprDrJ4kCJJWatoRdQ2/RFiawzbH7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oyPj5ucnBz9ucA8b0s98AS4G5En0qSdQ1CYSF5ensEji5qcPBGztwLqcC3ig9h/gCV/D/ubmVuOsFuEoIgteCaPsZgHUOgdwIMNO1CMv2pRCTAKIhnosoEYgOSryJL/A99s/wPpsi66tGJO3QAAAABJRU5ErkJggg==";
@@ -963,11 +965,19 @@ IconGrid.prototype = {
var appName = $("<div/>").addClass("appLabel");
- var itemTitle = theItem.itemTitle;
- if (!itemTitle && self.datasource.getItemTitle) {
- itemTitle = self.datasource.getItemTitle(Base32.decode(guid));
+ var itemTitle;
+ try {
+ if (theItem && theItem.itemTitle) {
+ itemTitle = theItem.itemTitle;
+ } else if (self.datasource.getItemTitle) {
+ itemTitle = self.datasource.getItemTitle(Base32.decode(guid));
+ }
+ } catch (e) {
+ console.log("exception getting title for guid: " + guid + " : " + e);
}
+
if (!itemTitle) itemTitle = "";
+
appName.text(itemTitle);
appDisplayFrame.append(appName);
@@ -985,6 +995,10 @@ IconGrid.prototype = {
initialize: function () {
var self = this;
+
+ // check for document.createTouch?
+
+
self.dashboard = $("<div/>").addClass("dashboard");
self.dashboard.css({
width: self.layout.panelWidth,
@@ -1008,6 +1022,7 @@ IconGrid.prototype = {
self.dashcontainer.mousedown(function (evt) {
+ // console.log("mouse down");
self.lastMouseEvent = evt;
self._onMouseDown(evt);
});
@@ -1016,13 +1031,16 @@ IconGrid.prototype = {
self._onMouseMove(evt);
});
self.dashcontainer.mouseup(function (evt) {
+ // console.log("mouse up");
self._onMouseUp(evt);
});
self.dashcontainer.mouseleave(function (evt) {
+ // console.log("mouse leave");
self._onMouseLeave(evt);
});
self.dashcontainer.mouseenter(function (evt) {
+ // console.log("mouse enter");
self._onMouseEnter(evt);
});
@@ -1042,6 +1060,7 @@ IconGrid.prototype = {
e.clientX = e.touches[0].clientX;
e.clientY = e.touches[0].clientY;
}
+ // console.log("touch down: "+ e.clientX + " : " + e.clientY);
self.lastMouseEvent = e;
self._onMouseDown(e);
@@ -1058,6 +1077,7 @@ IconGrid.prototype = {
dashDomObj.addEventListener("touchend", function(e) {
//cached last touch or move event
+ // console.log("touch up: "+ self.lastMouseEvent.clientX + " : " + self.lastMouseEvent.clientY);
self._onMouseUp(self.lastMouseEvent);
}, false);
View
7 index.html
@@ -140,8 +140,9 @@
},
openItem: function(itemID) {
- var title = this.fruitlist[itemID]['itemTitle'];
- if (!title) title = "about:icongrid";
+ if (itemID == "about:icongrid")
+ window.open("http://mozilla.github.com/icongrid/");
+ else
window.open("http://www.google.com/search?q=" + itemID);
},
@@ -157,7 +158,7 @@
// These get called when an item doesn't have the right properties.
// Note that you can pass in data URIs for icons
getItemImgURL: function(itemID) {
- if (itemID == "about:icongrid") return "http://www.publicpress.org/images/about48.png"
+ if (itemID == "about:icongrid") return "http://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Question_mark_alternate.png/185px-Question_mark_alternate.png"
},
getItemTitle: function(itemID) {
Please sign in to comment.
Something went wrong with that request. Please try again.