summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authordumpfmprod <dumpfmprod@ubuntu.(none)>2010-03-12 19:38:27 -0500
committerdumpfmprod <dumpfmprod@ubuntu.(none)>2010-03-12 19:38:27 -0500
commit58c4f6858b83360286698a32e266fe9a33ed763a (patch)
tree2a980fc1120683eb2391c5ccda03c79d4a9330df /static/js
parent0e066e6b22ec91bb6b6d233d8f5e94400bfb062d (diff)
timb committing ryder's changes
Diffstat (limited to 'static/js')
-rwxr-xr-xstatic/js/pichat.js115
1 files changed, 77 insertions, 38 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 7314ff8..132d67e 100755
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -215,25 +215,12 @@ function isSameTopic(curTopic, newTopic) {
}
}
-function displayNewTopic(topic) {
- $('#topic').empty()
- .append(topic.topic)
- .append(topic.deadline)
- .append(topic.maker).show();
-}
-
-function hideTopic(topic) {
- $('#topic').empty().hide();
-}
-
function updateTopic(newTopic) {
- if ($('#topic').length == 0) { return; }
if (isSameTopic(CurrentTopic, newTopic)) { return; }
- if (newTopic) {
- displayNewTopic(newTopic);
- } else {
- hideTopic();
- }
+ alert('new topic');
+ CurrentTopic = newTopic;
+ $('#topic').text(topic.topic);
+
}
function refresh() {
@@ -379,29 +366,13 @@ function favoriteImage() {};
function setupUpload(elementId, roomKey) {
var onSubmit = function(file, ext) {
if (!(ext && /^(jpg|png|jpeg|gif|bmp)$/i.test(ext))) {
- alert('SORRY, NOT AN IMAGE DUDE... ');
- return false;
+ alert('SORRY, NOT AN IMAGE DUDE... ');
+ return false;
}
};
var onComplete = function(file, response) {
- if (response.match(/FILE_TOO_BIG/)) {
- var maxSize = response.split(" ")[1] / 1024;
- alert("Sorry. Your file is just too fucking big. "
- + maxSize + "KB or less please.");
- return;
- } else if (response.match(/FILE_NOT_IMAGE/)) {
- alert("What did you upload? Doesn't seem like an image. Sorry.");
- return;
- } else if (response.match(/INVALID_RESOLUTION/)) {
- var maxWidth = response.split(" ")[1];
- var maxHeight = response.split(" ")[2];
- alert("Sorry, the maximum image resolution is "
- + maxWidth + "x" + maxHeight);
- return;
- }
- if (typeof pageTracker !== 'undefined') {
- var room = typeof Room !== 'undefined' ? Room : 'UnknownRoom'
- pageTracker._trackEvent('Message', 'Upload', room);
+ if (typeof pageTracker !== 'undefined') {
+ pageTracker._trackEvent('Message', 'Upload', typeof Room !== 'undefined' ? Room : 'UnknownRoom');
}
}
new AjaxUpload(elementId, {
@@ -409,7 +380,7 @@ function setupUpload(elementId, roomKey) {
autoSubmit: true,
name: 'image',
data: { room: roomKey },
- onSubmit: onSubmit,
+ onSubmit: onSubmit,
onComplete: onComplete
});
}
@@ -492,4 +463,72 @@ function initDirectory() {
var text = jQuery(this).text();
jQuery(this).html(linkify(text));
});
+}
+
+//big hand stuff
+
+
+function initBigHand(id){
+ var cursorId = "#cursor-big"
+ var cursor = $(cursorId)[0]
+
+ // jquery's reported element sizes are not exactly the same as the browser's 'mouseover' target sizes
+ // so we'll allow a few pixels extra
+ var fudgeFactor = 2
+
+ $(id).addClass("no-cursor")
+
+ // i have to do this weirdly bc putting the cursor image where the mouse cursor is causes problems with mouse events:
+ // * it stops mousemove events on the image below the mouse cursor
+ // * it fucks up mouseover/out and even mouseenter/leave events, as well as click
+
+ // so i am doing this:
+ // on mousing over the image:
+ // make cursor visible
+ // find image co-ords
+ // bind a global mousemove func
+ // bind cursor click event
+ // unbind mouseover
+ // mousemove func:
+ // move image to mouse co-ords
+ // if mouse co-ords are outside the image co-ords:
+ // make cursor invisible
+ // unbind mousemove func
+ // unbind cursor click event
+
+ var mousemove = function(e){
+ var y = e.pageY, x = e.pageX, coords = initBigHand.coords
+
+ cursor.style.top = y + "px"
+ cursor.style.left = x - 32 + "px" // 32: (4 pixels * 8 pixels per big pixel) to line up pointy finger with cursor
+ if (y < coords.top ||
+ y > coords.bottom ||
+ x < coords.left ||
+ x > coords.right) {
+ $(cursorId).addClass('invisible')
+ $(cursorId).css({"top": 0, "left": 0 })
+ $(cursorId).unbind('click', cursorClick)
+ $('logo7').unbind('mousemove', mousemove)
+ $(id).mouseover(imageMouseOver)
+ }
+ }
+
+ var cursorClick = function(){ $(id).click() }
+
+ var imageMouseOver = function(){
+ //console.log("moused over...")
+ initBigHand.coords = {
+ "left": $(id).offset().left - fudgeFactor,
+ "top": $(id).offset().top - fudgeFactor,
+ "right": $(id).offset().left + $(id).width() + fudgeFactor,
+ "bottom": $(id).offset().top + $(id).height() + fudgeFactor
+ }
+ $('body').mousemove(mousemove)
+ $(cursorId).click(cursorClick)
+ $(cursorId).removeClass('invisible')
+ $(id).unbind('mouseover', imageMouseOver)
+ }
+
+ $(id).mouseover(imageMouseOver)
+
} \ No newline at end of file