// VIMEO BRAIN // window.addEvent('domready', function(){ avatar_init(); start_menudo(); xsrf_protect(); //if (document.addEventListener) { // document.addEventListener('copy', copy_protect, false); //} //else { // document.attachEvent('copy', copy_protect); //} var anchor = location.hash.substring(1); if (anchor == 'signin') loginLightbox(); }); function copy_protect(e) { // create fake element var sel, range, chars = /(?:\u200b)/g, shadow = new Element('div', { style: { overflow: 'hidden', position: 'absolute', top: '-5000px', height: '1px' } }); if (typeof window.getSelection !== 'undefined') { sel = window.getSelection(); range = sel.getRangeAt(0); shadow.appendChild(range.cloneContents()); shadow.innerHTML = shadow.innerHTML.replace(chars, ''); document.getElementsByTagName('body')[0].appendChild(shadow); sel.selectAllChildren(shadow); window.setTimeout(function() { shadow.parentNode.removeChild(shadow); if (typeof window.getSelection().setBaseAndExtent !== 'undefined') { sel.setBaseAndExtent( range.startContainer, range.startOffset, range.endContainer, range.endOffset ); } }, 0); } else { sel = document.selection; range = sel.createRange(); shadow.innerHTML = range.htmlText.replace(chars, ''); var range2 = body.createTextRange(); range2.moveToElementText(shadow); range2.select(); window.setTimeout(function() { shadow.parentNode.removeChild(shadow); if (range.text !== '') { range.select(); } }, 0); } } function start_menudo() { if (window.ie && document.all && document.getElementById) { var navRoot = document.getElementById("nav"); if (navRoot) for (i = 0; i < navRoot.childNodes.length; i++) { var node = navRoot.childNodes[i]; if (node.nodeName == "LI") { node.onmouseover = function() { this.className += " over"; } node.onmouseout = function() { this.className = this.className.replace(" over", ""); } } } } } function swap(e1, e2) { $(e1).style.display = 'none'; $(e2).style.display = ''; } var moo_rainbows = []; var vimeo_dropdowns = []; var tooltip = false; function avatar_init() { var avatar_hover = new Element('div', {'id': 'avatar_hover'}); $(document.body).adopt(avatar_hover); tooltip = new Tooltip(false, 'avatar_hover',{ position: 'tr', onclick: true, load: '/ajax/user/avatar' }); } function avatar_hover(args) { var x = window.ie && args.offset_x ? -25 : -5; var flash = args.flash ? 1 : 0; var clip = args.clip ? 1 : 0; var y = clip ? -95 : -19; $('avatar_hover').setHTML(''); if (tooltip.element != args.o) { tooltip.tooltipOff(); } else { if (tooltip.tool_tip.getStyle('display') != 'none') { tooltip.tooltipOff(); return false; } } tooltip.options.delta_x = x; if (args.browser) { var browser = $(args.browser); tooltip.options.delta_y = browser ? -browser.scrollTop + y : y; } else { tooltip.options.delta_y = y; } tooltip.options.load_args = { user_id: args.user_id, flash: flash, clip: clip }; tooltip.element = args.o; tooltip.toggleTooltip(args.e); } function avatar_contact(obj, user) { refresh_page({ jdata: { user: user }, url: '/ajax/user/contact_toggle', onComplete: function(data) { if (data = Json.evaluate(data)) { $(obj).addClass('avatar_link_remove'); $(obj).removeClass('avatar_link'); $(obj).setHTML('Remove from contacts'); for (var i = 0; i < $('avatar_checkboxes').getFirst().getChildren().length; i++) { $('avatar_checkboxes').getFirst().getChildren()[i].getFirst().getFirst().setProperty('src', '/assets/images/icon_avatar_checked.gif'); } } else { $(obj).addClass('avatar_link'); $(obj).removeClass('avatar_link_remove'); $(obj).setHTML('Add to my contacts'); } } }); } function avatar_subscribe(obj, user_id, subscription) { var subscribe = ($(obj).getFirst().getProperty('src').contains('unchecked')) ? 'true' : 'false'; refresh_page({ jdata: { type: subscription, value: subscribe, subject_id: user_id }, url: '/ajax/subscription/toggle', onComplete: function() { if (subscribe == 'true') { $(obj).getFirst().setProperty('src', '/assets/images/icon_avatar_checked.gif'); } else { $(obj).getFirst().setProperty('src', '/assets/images/icon_avatar_unchecked.gif'); } } }); } function set_reason(o) { $('reason').value = $(o).getNext().getText(); } function toggle_whitelist_video(clip_id, obj) { refresh_page({ jdata: { clip_id: clip_id }, url:'/ajax/clip/toggle_whitelist_video', onComplete: function(data) { $(obj).setHTML(data); } }); } function toggle_bury_all(user_id, obj) { refresh_page({ jdata: { user_id: user_id }, url:'/ajax/user/toggle_bury_all', onComplete: function(data) { $(obj).setHTML(data); } }); } function faux_link(el) { el = $(el); if (el.hasClass('faux_hover')) el.removeClass('faux_hover'); else el.addClass('faux_hover'); } /** * vimeo_alert() displays a closeable message in the header * example: vimeo_alert('Good News!','We\'ve increased the upload limit to 1GB per month!'); */ function vimeo_alert(headline, text) { var headlineDIV = new Element('div', {'class':'headline'}).setHTML(headline); var textDIV = new Element('div', {'class':'text'}).setHTML(text); var closewidget = new Element('img', { 'src': '/assets/images/undertaker_x_med.png', 'alt': 'close' }).addEvent('click', function(){ alertslide.toggle(); }); headlineDIV.adopt(closewidget); var alertDIV = new Element('div',{'class':'alert'}); alertDIV.adopt(headlineDIV); alertDIV.adopt(textDIV); alertDIV.injectBefore($('header')); var alertslide = new Fx.Slide(alertDIV,{duration:1000,transition:Fx.Transitions.expoOut}); alertslide.hide(); alertslide.toggle(); } function replace(chr, replace, str) { while( str.indexOf(chr) != -1 ) str = str.replace(chr, replace); return str; } /* returns the value of a (single) select box. */ function field_select_value(fieldId) { if (!$(fieldId)) return false; for(var i = 0; i <$(fieldId).options.length; ++i) { if ($(fieldId).options[i].selected == true) return $(fieldId).options[i].value; } } /** checks to see if any form element has been changed from its default value **/ function isDirtyForm(o_form) { if ( o_form ) { var num_elements = o_form.elements.length; for ( var i=0; i < num_elements; i++ ) { var element = o_form.elements[i]; if ( element.type == "text" || element.tagName == "TEXTAREA" ) { if (element.value != element.defaultValue) return true; } else if ( element.tagName == "SELECT" ) { var options = element.options; var num_options = options.length; for ( var j=0; j < num_options; j++) { var option = options[j]; if ( option.selected != option.defaultSelected ) return true; } } } } return false; } function menudo_search_blur() { var f = $('menudo_search_field'); if ( f.value == '' ) { f.value = 'Search ' + cur_search_type; } } function menudo_search_click() { var f = $('menudo_search_field'); if (f.value == 'Search ' + cur_search_type) f.value = ''; } function menudo_search() { var token_value = $('xsrft').value; var search_token = token_value.substring(0,8); setCookie('searchtoken', search_token); var f = $('menudo_search_field').value; f = encodeURIComponent(f); f = f.replace(/%26/g, '&'); f = f.replace(/%2F/g, '/'); switch (cur_search_type) { case 'Videos': location.href = '/search/videos/search:' + f + '/st/' + search_token; break; case 'People': location.href = '/search/people/search:' + f + '/st/' + search_token; break; case 'Forums': location.href = '/search/forums/search:' + f + '/st/' + search_token; break; case 'Groups': location.href = '/search/groups/search:' + f + '/st/' + search_token; break; case 'Channels': location.href = '/search/channels/search:' + f + '/st/' + search_token; break; } } function menudo_search_change(type) { if ($('menudo_search_field').value.search('Search ') >= 0) $('menudo_search_field').value = ''; $('menudo_search_field').focus(); cur_search_type = type; $$('#menudo_search_subtier ul.menudo_subtier li').removeClass('selected'); $('menudo_search_' + type.toLowerCase()).addClass('selected'); } function submit_secure() { token_value = $('xsrft').value; setCookie('xsrft', token_value); this.submit(); } function addtoken(form) { token_value = $('xsrft').value; hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("style", "display: none"); hiddenField.setAttribute("name", 'token'); hiddenField.setAttribute("value", token_value); form.appendChild(hiddenField); } function xsrf_protect() { $$('form').each(function(el) { addtoken(el); if (el.onsubmit == undefined) el.onsubmit = submit_secure; el.submitsecure = submit_secure; }); } function refresh_page(o) { var method = o.method ? o.method : 'post'; var pars = ''; if (o.form) if ($(o.form)) pars = $(o.form).toQueryString(); if (o.pars) pars += o.pars; if (o.jdata) pars += '&jdata=' + Json.toString(o.jdata); // attach token to request token_value = $('xsrft').value; setCookie('xsrft', token_value); pars += '&token=' + token_value; var method = pars == '' ? 'get' : 'post'; if (o.force_get === true) { method = 'get'; } if (!o.disable_loader) show_loader(); if (!o.url) { alert('url: URL needed'); return false; } o.evalScripts = o.evalScripts ? o.evalScripts : false; if (o.bind && o.onComplete) o.onComplete = o.onComplete.bind(o.bind); if (o.debug) { console.log('url: %o \npars: %o', o.url, pars); } if (o.div) { if ( o.onComplete ) { var complete = function( data ) { hide_loader(); o.onComplete(data); } var ajax_object = new Ajax(o.url, {update: o.div, method: method, postBody: pars, onComplete: complete, evalScripts: o.evalScripts }).request(); } else { var ajax_object = new Ajax(o.url, {update: o.div, method: method, postBody: pars, onComplete: hide_loader, evalScripts: o.evalScripts }).request(); } } else { var complete = function(data) { hide_loader(); if (o.onComplete) o.onComplete(data); } var ajax_object = new Ajax(o.url, {method: method, postBody: pars, onComplete: complete, evalScripts: o.evalScripts}).request(); } return ajax_object; } function getVersionInfo() { var player = getCookie('html_player') == 1 ? 'HTML' : 'Flash'; return BrowserDetect.OS + '|' + BrowserDetect.browser + ',' + BrowserDetect.version + '|' + 'Flash,' + GetSwfVer() + '|' + player + ' Player | '+vimeo.app_version; } var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "Browser unknown"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Version unknown"; this.OS = this.searchString(this.dataOS) || "OS unknown"; }, isMobile: function() { return /(iphone|ipod|android|webos)/.test(navigator.userAgent.toLowerCase()); }, searchString: function (data) { for (var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) { return data[i].identity; } } }, searchVersion: function (dataString) { var regex = new RegExp(this.versionSearchString + '\\s*([0-9\._]+)'); var str = dataString.match(regex); if (!str) { if (this.browser == 'Safari') return '2'; return false; } return str[1].replace(/_/g, '.'); }, dataBrowser: [ { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.platform, subString: "iP", identity: "Mobile Safari", versionSearch: "OS " }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version/" }, { prop: window.opera, identity: "Opera" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Chrome", versionSearch: "Chrome/", identity: "Chrome" }, { string: navigator.userAgent, subString: "Firefox", versionSearch: "Firefox/", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino", versionSearch: "Camino/" }, { // for newer Netscapes (6+) string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { // for older Netscapes (4-) string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" } ], dataOS : [ { string: navigator.userAgent, subString: "Windows NT 5", identity: "Windows XP" }, { string: navigator.userAgent, subString: "Windows NT 6.1", identity: "Windows 7" }, { string: navigator.userAgent, subString: "Windows NT 6", identity: "Windows Vista" }, { string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.userAgent, subString: "iPad", identity: "iPhone OS (iPad)" }, { string: navigator.userAgent, subString: "iP", identity: "iPhone OS" }, { string: navigator.userAgent, subString: "Mac OS X 10_4", identity: "Mac OS X 10.4" }, { string: navigator.userAgent, subString: "Mac OS X 10_5", identity: "Mac OS X 10.5" }, { string: navigator.userAgent, subString: "Mac OS X 10_6", identity: "Mac OS X 10.6" }, { string: navigator.userAgent, subString: "Mac OS X", identity: "Mac OS X" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.platform, subString: "Linux", identity: "Linux" } ] }; window.addEvent('domready', function() { BrowserDetect.init(); }); var comment_disabled = false; function add_comment(obj_id) { if ( !comment_disabled ) { if ( $('new_comment_text_'+obj_id).value == '' ) { alert('You must type in a comment first!'); $('new_comment_text_'+obj_id).focus(); return false; } comment_disabled = true; $('new_comment_btn_'+obj_id).disable('Posting...'); var divName = (($('frmDiv_'+obj_id) && $('frmDiv_'+obj_id).value) ? $('frmDiv_'+obj_id).value : 'comments_' + obj_id); var offset = ($('frmOffset') && $('frmOffset').value ? $('frmOffset').value : ''); refresh_page({ div: divName, form: 'frmNewComment_' + obj_id, jdata: { version: getVersionInfo() }, pars: '&limit=-1&id=' + obj_id, url: '/ajax/comment/update_' + $('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); comment_disabled = false; $('frmNewComment_' + obj_id).reset(); // we get ALL comments to ensure we get the one they posted. // so make sure we clear out the comments-rest-123 if we need to. if ($('frmDiv_'+obj_id) && ($('frmDiv_'+obj_id).value != 'comments-rest-'+obj_id)) { if ($('comments-rest-'+obj_id)) $('comments-rest-'+obj_id).innerHTML = ''; } $('new_comment_btn_'+obj_id).enable('Post Comment'); $('new_comment_'+obj_id).removeClass('no_dots'); } }); } } function reply_comment(id, obj_id) { if ( !comment_disabled ) { var text = $('comment-reply-text-'+id); if ( text.value == '' ) { alert('You must type in a comment first!'); text.focus(); return false; } comment_disabled = true; var button = $('comment-reply-button-'+id); button.disable('Posting...'); refresh_page({ div: 'comments_' + obj_id, form: 'frmReplyComment'+id, jdata: { version: getVersionInfo() }, pars: '&action=new&id=' + obj_id + '&parent_comment=' + id + '&limit=-1', url: '/ajax/comment/update_'+$('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); comment_disabled = false; if ($('comments-rest-'+obj_id)) $('comments-rest-'+obj_id).innerHTML = ''; } }); } } function delete_comment(id, obj_id, limit, offset) { if (limit != 0) { limit = -1; offset = 0; } if ( confirm('Are you sure you want to delete this comment?') ) { refresh_page({ div: 'comments_'+obj_id, pars: '&action=delete&id='+obj_id+'&comment_id='+id + '&limit=' + limit + '&offset=' + offset, url: '/ajax/comment/update_'+$('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); // we get ALL comments to ensure they delete one, we show it properly if (limit == -1) { if ($('comments-rest-'+obj_id)) $('comments-rest-'+obj_id).innerHTML = ''; } if ($('comments_'+obj_id).getChildren().length < 1) { $('new_comment_'+obj_id).addClass('no_dots'); } } }); } } function delete_sticky_comment(id, obj_id) { if ( confirm('Are you sure you want to delete this comment?') ) { refresh_page({ div: 'comments_'+obj_id, pars: '&action=delete&id='+obj_id+'&sticky_comment_id='+id, url: '/ajax/comment/update_'+$('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); } }); } } function edit_comment(id, obj_id, limit, offset) { if ( !comment_disabled ) { comment_disabled = true; if (limit != 0) { limit = -1; offset = 0; } refresh_page({ div: 'comments_'+obj_id, pars: '&action=edit&id='+obj_id+'&comment_id='+id+'&limit=' + limit + '&offset=' + offset+'&text='+encodeURIComponent($('comment-edit-text-'+id).value), url: '/ajax/comment/update_'+$('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); comment_disabled = false; } }); } } function edit_sticky_comment(id, obj_id) { if ( !comment_disabled ) { comment_disabled = true; refresh_page({ div: 'comments_'+obj_id, pars: '&action=edit&id='+obj_id+'&sticky_comment_id='+id+'&text='+encodeURIComponent($('sticky_comment-edit-text-'+id).value), url: '/ajax/comment/update_'+$('comment_type_'+obj_id).value, onComplete: function() { hide_loader(); comment_disabled = false; } }); } } function edit_comment_toggle(id) { $('comment-edit-'+id).toggle(); $('comment-text-'+id).toggle(); $('comment-edit-text-'+id).focus(); } function edit_sticky_comment_toggle(id) { $('sticky_comment-edit-'+id).toggle(); $('sticky_comment-text-'+id).toggle(); $('sticky_comment-edit-text-'+id).focus(); } var showing_all_comments = false; function show_all_comments(offset, type, type_id) { if ( !showing_all_comments ) { if ($('frmOffset')) $('frmOffset').value = offset; if ($('frmDiv')) $('frmDiv').value = "comments-rest-" + type_id; showing_all_comments = true; $('show_more_comments_link').innerHTML = 'Loading...'; refresh_page({ div: 'comments_' + type_id, pars: '&offset=' + offset + '&type=' + type + '&type_id=' + type_id, url: '/ajax/comment/show_all', onComplete: function(data) { $('comments-rest-' + type_id).innerHTML = ''; } }); } } function user_menu_init(hover, id) { var rollover = $(hover); var ol = $(id+'_content'); var un = $(id+'_under'); ol.style.height = (rollover.getSize().size.y - 3) + 'px'; un.style.height = ol.getSize().size.y + 'px'; un.style.width = ol.getSize().size.x + 'px'; $(id+'_bg').setOpacity(0.95); un.setOpacity(0.95); new Tooltip(hover, id, {position:'tr', delay:0, mouseover:true, delta_x: -5} ); } function set_context(str) { setCookie('context', str); } window.addEvent(window.webkit ? 'load' : 'domready', global_init); function global_init() { if ($('subscribe_controls')) { init_subscribe_controls(); } if ($('plus_controls')) { init_plus_controls(); } } function init_subscribe_controls() { var w = $('subscribe_controls').clone(); $('subscribe_controls').remove(); $(document.body).adopt(w); new Tooltip('subscribe_button', 'subscribe_controls', { position: 'bl', delay:200, mouseover: false, onclick:true, delta_y:6 }); } function init_plus_controls() { var w = $('plus_controls').clone(); $('plus_controls').remove(); $(document.body).adopt(w); new Tooltip('plus_button', 'plus_controls', { position: 'bl', delay:200, mouseover: true, delta_y:6 }); } function refresh_toolbar(clip_id, tag, user_id) { var tools = $('enabledTools').innerHTML.replace(/^\s+|\s+$/g, ''); $('subscribe_controls').remove(); refresh_page({ div: 'toolbar', jdata: { clip_id: clip_id, tag: tag, user_id: user_id, tools: tools }, url: '/ajax/toolbar/refresh', onComplete: function() { init_subscribe_controls(); hide_loader(); } }); } /** * Polling class to check if a form field has changed */ var Poll = new Class({ options: { bind: false, interval: 541, allow_empty: false }, initialize: function(fields, fn, options) { this.setOptions(options); this.fields = []; this.is_polling = false; if ( $type(fields) == 'array' ) { fields.each( function(item, index) { this.fields.push( $(item) ); }, this); } else { this.fields = [$(fields)]; } if ( !this.fields[0] ) return false; this.onChange = this.options.bind ? fn.bind(this.options.bind) : fn; this.cur_text = this.getValue(); this.start(); }, stop: function() { this.is_polling = false; $clear(this.period); }, start: function() { if ( !this.is_polling ) { this.is_polling = true; this.period = this.poll.periodical(this.options.interval, this); } }, resetTime: function() { this.stop(); this.start(); }, getValue: function() { var text = ''; this.fields.each( function(item, index) { text += item.value; }); return text; }, poll: function() { var text = this.getValue(); var actual_text = this.fields[0].value; if ( (this.options.allow_empty || actual_text != '') && this.cur_text != text ) { this.cur_text = text; this.onChange(actual_text, this.options); } } }); Poll.implement(new Options); function show_loader() { $(document.body).addClass('hourglass'); } function hide_loader() { $(document.body).removeClass('hourglass'); } function checkEmail(val) { if (val == '' || val.indexOf('@') == -1 || val.indexOf('.') == -1) { return false; } return /[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?\.)+(?:[A-Za-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum|cat|coop|pro|tel|int)\b/.test(val.toLowerCase()); } function checkUrl(val) { if (/^((http|https):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?/i.test(val) && val != '' ) { return true; } return false; } function setCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; var domain = vimeo_startup ? "; domain=" + vimeo_startup.domain : "; domain=.vimeo.com"; document.cookie = name + "=" + value + expires + "; path=/" + domain; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function deleteCookie(name) { setCookie(name, '', -1); } /** * NewAutoCopmlete * required args: text field id */ var NewAutoComplete = new Class({ options: { limit: 10, width: 0, delta_x: 0, delta_y: 0, onselect: false, url: '', search_text: 'Start typing to search...', empty_search_text: 'Nothing found.', more_results: false }, initialize: function(field, options) { this.field = $(field); if ( !this.field ) return false; this.setOptions(options); this.is_focused = false; this.hide_lock = false; this.setup(); this.poll = new Poll(field, this.search.bind(this), { interval: 300, allow_empty: true }); this.field.addEvent('focus', this.showSearch.bind(this)); this.field.addEvent('blur', this.onBlur.bind(this)); document.addEvent('click', this.onClick.bind(this)); document.addEvent('keydown', this.keyboard.bind(this)); }, keyboard: function(e) { var e = new Event(e); switch(e.key) { case 'up': if ( this.is_focused ) { this.up(); e.stop(); } break; case 'down': if ( this.is_focused ) { this.down(); e.stop(); } break; case 'enter': if ( this.is_focused ) { if ( this.results ) { this.select(this.selected_index); this.tt.hideTooltip(); e.stop(); } } break; default: if ( this.is_focused ) { this.showSearch(); } break; } }, showSearch: function(e) { this.is_focused = true; if ( e ) { var event = new Event(e); event.stop(); this.tt.showTooltip(e); } else { this.tt.tooltipOn(); } }, hideSearch: function() { if ( !this.hide_lock ) { this.is_focused = false; this.tt.hideTooltip(); } }, onClick: function( event ) { var e = new Event(event); var prev_lock = this.hide_lock; this.hide_lock = this.search_box.hasChild(e.target) || this.field.id == e.target.id; if ( prev_lock && !this.hide_lock) this.hideSearch(); }, onBlur: function() { this.hide_lock = false; this.hideSearch.delay(300, this); }, /** * Dynamically setting up the autocomplete search box */ setup: function() { this.search_box = new Element('div', {'id':this.field.id+'_search', 'class':'autocomplete'}); this.search_list = new Element('ul', {'id':this.field.id+'_search_list', 'class':'autocomplete_list'}); this.message( this.options.search_text ); $(document.body).adopt( this.search_box.adopt(this.search_list) ); if ( this.options.width > 12 ) { this.search_box.setStyle('width', (this.options.width-12)+'px'); } this.tt = new Tooltip(this.field.id, this.search_box.id, {position:'bl', onfocus: true, delta_x: this.options.delta_x, delta_y: this.options.delta_y }); }, search: function( text ) { if ( text == '' ) { this.message(this.options.search_text); this.poll.cur_text = ''; return false; } if ( this.search_box.style.display == '' && this.is_focused ) { this.search_text = text; if ( this.prev_ajax ) { this.prev_ajax.cancel(); } this.message('Loading...'); this.prev_ajax = refresh_page({ jdata: { search_term: this.search_text, limit: this.options.limit }, url: this.options.url, onComplete: this.onSearchComplete.bind(this) }); } }, onSearchComplete: function( data ) { this.clearList(); var data = Json.evaluate(data); // No users found if ( !data ) { this.message( this.options.empty_search_text ); } this.search_list = $(this.search_list.id); // redefine just in case if ( data.results ) { this.search_list.setStyle('display',''); this.search_list.empty(); this.results = data.results; this.selected_index = 0; // insert new results for( var i = 0; i < this.results.length; i++ ) { var disabled = false; var li = new Element('li',{ 'id': this.field.id+'_results_'+i, 'styles': { 'position': 'relative', 'cursor': 'pointer' } }); if (this.results[i].portrait){ li.adopt( new Element('img', { 'src':this.results[i].portrait, 'class':'portrait', 'styles': { 'position':'relative', 'width':30, 'height':30 } } )); } this.search_list.adopt( li.adopt( new Element('div',{'class':'acaption', 'styles': { 'position':'relative' } }).setHTML(this.results[i].name) ).adopt( new Element('div',{'class':'clear'}) ) ); if ( i == 0 ) li.className = 'hover'; li.onmousedown = this.select.bind(this).pass(i); li.onmouseover = this.highlight.bind(this).pass(i); } var li = new Element('li',{ 'id': 'outer_box', 'styles': { 'position': 'relative', 'cursor': 'pointer' } }); var div = new Element('div',{'class':'tools'}); if (this.options.more_results){ var searchtoken = $('xsrft').value.substr(1,8); var a = new Element('a', {'href':this.options.more_results + this.search_text + '/st/' + searchtoken }).setHTML('more results'); div.adopt(a); var span = new Element('span').setHTML(' or '); div.adopt(span); setCookie('searchtoken', searchtoken); } div.adopt( new Element('a', { 'href':'javascript:void(0);', 'class':'close' }).setHTML('close').adopt( new Element('span',{'class':'undertaker'})) ); this.search_list.adopt(li.adopt(div)); } if ( this.options.new_person ) { var li_see_all = new Element('li',{ 'styles': { 'position': 'relative', 'cursor': 'pointer', 'background-image': 'none' } }).adopt( new Element('div', {'id':this.field.id+'_new_person', 'class':'autocomplete autocomplete_new'}).adopt( new Element('div',{ 'styles': { 'position':'relative', 'cursor':'pointer' } }).adopt( new Element('img',{'class':'portrait','src':'/assets/images/portrait_blank_30.gif'}) ).adopt( new Element('div',{'class':'acaption', 'styles': { 'position':'relative', 'cursor':'pointer' } }).adopt( new Element('a',{'href':'/contacts/invite'}).setHTML('Invite someone new') ) ).adopt( new Element('div',{'class':'clear'}) ) ) ); this.search_list.adopt(li_see_all); } }, down: function() { this.selected_index++; if ( this.results && this.selected_index > this.results.length-1 ) { this.selected_index = this.results.length - 1; } else { this.highlight(this.selected_index); } }, up: function() { this.selected_index--; if (this.selected_index < 0) { this.selected_index = 0; } else { this.highlight(this.selected_index); } }, select: function(index) { this.selected_index = index; if ( this.results ) this.options.onselect( this.results[this.selected_index] ); }, deselect: function() { if ( this.results ) { for(var i = 0; i < this.results.length; i++) { $(this.field.id+'_results_'+i).className = ''; } } }, highlight: function(index) { this.selected_index = index; // first deselect all items if ( this.results ) { for(var i = 0; i < this.results.length; i++) { $(this.field.id+'_results_'+i).className = ''; } if ( $(this.field.id+'_results_'+this.selected_index) ) { $(this.field.id+'_results_'+this.selected_index).className = 'hover'; } } }, clearList: function(dont_clear) { this.results = false; if ( !dont_clear ) this.search_list.innerHTML = ''; this.search_list.setStyle('display','none'); }, message: function(text, options) { this.clearList(); this.search_list.setStyle('display',''); var li = new Element('li', {'class':'hover', 'styles': { 'background-image':'none' }} ); if ( options && options.onclick) { li.onclick = options.onclick; } this.search_list.adopt( li.adopt( new Element('div').setHTML(text)) ); } }) NewAutoComplete.implement(new Options); /** * Dropdown class */ var Dropdown = new Class({ options: { delta_x: 0, delta_y: 0, onComplete: function(val) {}, args: false, selected: '', cookie: false, enable_selected: false }, initialize: function(element, dropdown, options) { this.setOptions(options); this.t = new Tooltip(element, dropdown, { zindex: 100100, position:'bl', onclick:true, delta_y:this.options.delta_y, delta_x:this.options.delta_x }); this.element = $(element); this.dropdown = $(dropdown); this.cur_item = this.options.selected; this.items = this.dropdown.getFirst().getChildren(); this.mouseClick = this.itemTrigger.bindAsEventListener(this); this.hideClick = this.hideDropdown.bindAsEventListener(this); this.registerEvents(); if ( this.options.cookie ) { var id = getCookie(this.options.cookie); if ( id ) this.manualSelectItem(id); } }, registerEvents: function() { this.items.each( function(item) { if ( item.id.substr(0,1) != '|' ) { // Item is a divider - ignore if ( item.className == 'hilite' ) this.cur_item = item.id; item.addEvent("mouseup", this.mouseClick); } }, this); }, destroy: function() { this.t.destroy(); }, getValue: function() { return this.cur_item; }, manualSelectItem: function(id) { this.selectItem(id); $(this.element.id + '_value').innerHTML = $(id).innerHTML; }, addItem: function(id, name) { var new_li = new Element('li', { 'id': id, 'onmouseover': "this.addClass('hilite')", 'onmouseout': "this.removeClass('hilite')", 'events': { 'mouseup': this.mouseClick.bind(this) } }).setText(name); var ul = this.items[0].getParent(); ul.adopt(new_li); this.items.push( new_li ); }, deleteItem: function(id) { this.items.each( function(item) { if ( item.id == id ) { item.removeEvent("mouseup", this.mouseClick); item.remove(); } }); }, selectItem: function(id) { this.items.each( function(item) { if ( item.id.substr(0,1) != '|' ) { // Item is a divider - ignore if ( item.id == id ) { item.addClass('selected'); this.cur_item = id; } else { item.removeClass('selected'); } } }, this); }, itemTrigger: function(event) { var e = new Event(event); var item = e.target; if ( item.id.substr(0,1) != '*' ) { if ( e.target.tagName == 'SPAN' ) { item = e.target.getParent(); } e.stop(); if ( item.id == this.cur_item && !this.options.enable_selected ) return false; this.selectItem(item.id); $(this.element.id + '_value').innerHTML = item.innerHTML; $(this.element.id + '_value').setStyle('color', item.style.color); } this.hideDropdown(); if ( this.options.cookie ) { setCookie(this.options.cookie, this.cur_item); } if (this.options.onComplete) this.options.onComplete(item.id, this.options.args); }, hideDropdown: function() { this.t.wait = false; this.t.tooltipOff.delay(100, this.t); } }); Dropdown.implement(new Options); /** * Tooltip Class */ var Tooltip = new Class({ initialize: function(element, tool_tip) { //element = the thing you rollover //tool_tip = tooltip div itself //new Tooltip('e','e2', { position:'tr', delta_y:100, mouseover:true }) var options = Object.extend({ no_roll: false, default_css: false, position: false, // tr, tl, br, bl, rj delay: 0, // delay before displaying onclick: false, // have tooltip open onclick onfocus: false, // shows tooltip when onfocus mouseover: false, // can hover over tooltip, must be fixed in order for this to work global_click: true, // enables the user to click anywhere to turn off the tooltip width: 200, margin: "0px", padding: "5px", backgroundColor: "#cccccc", min_distance_x: 5, min_distance_y: 5, delta_x: 0, delta_y: 0, zindex: 100100, load: false, // specify a url to call when loading in load_args: false // ajax args }, arguments[2] || {}); if ( tool_tip ) { if ($type(element) == 'element') { this.element = element } else { this.element = $(element); } this.no_listeners = false; } else { this.no_listeners = true; } this.timer_on = false; this.timer_off = false; this.options = options; this.wait = false; if (!this.options.hide_delay) this.options.hide_delay = this.options.delay; if ($(tool_tip)) { $(tool_tip).moveToBottom(); this.tool_tip = $(tool_tip); } else { this.tool_tip = $(element); } // hide the tool-tip by default this.tool_tip.style.display = 'none'; if ( tool_tip && !this.options.no_roll ) { // no element to listen to if ( !this.options.onclick && !this.options.onfocus ) { this.eventMouseOver = this.showTooltip.bindAsEventListener(this); this.eventMouseOut = this.hideTooltip.bindAsEventListener(this); this.eventMouseMove = this.moveTooltip.bindAsEventListener(this); } else if ( this.options.onfocus ) { //this.eventFocus = this.showTooltip.bindAsEventListener(this); //this.eventBlur = this.hideTooltip.bindAsEventListener(this); } else { this.eventMouseDown = this.toggleTooltip.bindAsEventListener(this); this.eventTurnOff = this.tooltipOff.bindAsEventListener(this); this.eventWait = this.tooltipWait.bindAsEventListener(this); } this.registerEvents(); } window.addEvent("resize", this.moveTooltip.bindAsEventListener(this)); this.moveTooltip(false); }, load: function() { if ( this.options.load ) { refresh_page({ jdata: this.options.load_args, url: this.options.load, onComplete: function(data) { this.tool_tip.innerHTML = data; }.bind(this) }); } }, destroy: function() { if ( !this.options.onclick && !this.options.onfocus ) { this.element.removeEvent("mouseover", this.eventMouseOver); this.element.removeEvent("mouseout", this.eventMouseOut); this.element.removeEvent("mousemove", this.eventMouseMove); if ( this.options.mouseover ) { this.tool_tip.removeEvent("mouseover", this.eventMouseOver); this.tool_tip.removeEvent("mouseout", this.eventMouseOut); } } else if ( this.options.onfocus ) { //this.element.removeEvent("focus", this.eventFocus); // this.element.removeEvent("blur", this.eventBlur); } else { this.element.removeEvent("mousedown", this.eventMouseDown); this.element.removeEvent("mouseup", this.eventWait); if (this.options.global_click) $(document.body).removeEvent("click", this.eventTurnOff); } }, registerEvents: function() { if ( !this.options.onclick && !this.options.onfocus ) { // use mouse overs this.element.addEvent("mouseover", this.eventMouseOver); this.element.addEvent("mouseout", this.eventMouseOut); this.element.addEvent("mousemove", this.eventMouseMove); if ( this.options.mouseover ) { this.tool_tip.addEvent("mouseover", this.eventMouseOver) this.tool_tip.addEvent("mouseout", this.eventMouseOut) } } else if ( this.options.onfocus ) { //this.element.addEvent("focus", this.eventFocus); //this.element.addEvent("blur", this.eventBlur); } else { // use clicking if ( this.element ) { this.element.addEvent("mousedown", this.eventMouseDown); this.element.addEvent("mouseup", this.eventWait); } if (this.options.global_click) $(document.body).addEvent("click", this.eventTurnOff); } }, tooltipWait: function(event) { this.wait = true; }, moveTooltip: function(event){ if ( !this.element ) return false; if ( !this.options.position && event ) { // If not fixed var e = new Event(event); var mouse_x = e.client.x; var mouse_y = e.client.y; pos_y = (e.page.y - mouse_y) + mouse_y; pos_x = (e.page.x - mouse_x) + mouse_x; var dimensions = this.tool_tip.getSize(); var element_width = dimensions.size.x; var element_height = dimensions.size.y; if ( mouse_y - element_height < this.options.min_distance_y ) { // hitting top pos_y = pos_y + this.options.min_distance_y; } else { pos_y = pos_y - element_height - this.options.min_distance_y; } if ( (mouse_x + element_width + this.options.min_distance_x) >= (window.getWidth()) ) { // hitting right pos_x = pos_x - element_width - this.options.min_distance_x; } else { pos_x = pos_x + this.options.min_distance_x; } } else { // Fixed tooltip this.element = new Element(this.element); var coords = this.element.getPosition(); var size = this.element.getSize().size; switch( this.options.position ) { case 'tr': pos_x = coords.x + size.x; pos_y = coords.y; break; case 'tl': pos_x = coords.x; pos_y = coords.y; break; case 'br': pos_x = coords.x + size.x; pos_y = coords.y + size.y; break; case 'bl': pos_x = coords.x; pos_y = coords.y + size.y; break; case 'rj': pos_x = coords.x - ((this.tool_tip.getStyle('width').toInt() + 26) - size.x); pos_y = coords.y + size.y; break; } } this.setStyles(pos_x, pos_y); }, toggleTooltip: function(event) { if (event) new Event(event).stop(); this.load(); this.moveTooltip(event); this.tooltipToggle(); }, showTooltip: function(event) { var e = new Event(event).stop(); if ( this.no_listeners ) { this.tool_tip.innerHTML = e.target.title; } this.moveTooltip(event); this.timer_on = this.tooltipOn.delay(this.options.delay,this); $clear(this.timer_off); }, hideTooltip: function(event){ this.timer_off = this.tooltipOff.delay(this.options.hide_delay,this); $clear(this.timer_on); }, tooltipToggle: function() { if ( this.tool_tip.style.display == 'none' ) this.tool_tip.style.display = ''; else this.tool_tip.style.display = 'none'; }, tooltipOn: function(event) { this.tool_tip.style.display = ''; }, tooltipOff: function(event) { if ( event ) { var e = new Event(event); if ( this.tool_tip.hasChild(e.target) ) return false; } if ( !this.wait ) this.tool_tip.style.display = 'none'; this.wait = false; }, setStyles: function(x, y){ if ( this.no_listeners ) { var real_width = this.tool_tip.getSize().size.x; if ( real_width > this.options.width ) this.tool_tip.className = 'tooltip max-width'; else this.tool_tip.className = 'tooltip'; } // set the right styles to position the tool tip this.tool_tip.setStyle('position','absolute'); this.tool_tip.setStyle('top', y + this.options.delta_y + "px"); this.tool_tip.setStyle('left', x + this.options.delta_x + "px"); this.tool_tip.setStyle('z-index', this.options.zindex); // apply default theme if wanted if (this.options.default_css){ this.tool_tip.setStyle('margin', this.options.margin); this.tool_tip.setStyle('padding', this.options.padding); this.tool_tip.setStyle('backgroundColor', this.options.backgroundColor); this.tool_tip.setStyle('z-index', this.options.zindex); } } }); function toggle_collapsible(which,id,options) { if ($(id).style.display != 'block') { if (options && options['open_text']) which.innerHTML = options['open_text']; $(id).style.display = 'block'; which.setStyle('background-image','url(/assets/images/tri_down.gif)'); } else { if (options && options['closed_text']) which.innerHTML = options['closed_text']; $(id).style.display = 'none'; which.setStyle('background-image','url(/assets/images/tri_right.gif)'); } } function adjust_volume(volume) { setCookie('pl_volume', Math.ceil(volume), 10000); } function vimeo_checkbox_toggle( el ) { var len = el.src.length; if ( el.src.indexOf('_checked') >= 0 ) { el.src = el.src.substring(len - 57, len - 12) + '.gif'; return false; } else { el.src = el.src.substring(len - 49, len - 4) + '_checked.gif'; return true; } } function vimeo_checkbox( el ) { return $(el).src.indexOf('_checked') > 0; } var Moogaloop = new Class({ options: { buildnum: false, clip_id: false, server: 'vimeo.com', player_server: 'player.vimeo.com', autoplay: 0, fullscreen: 1, md5: 0, show_portrait: 0, show_title: 0, show_byline: 0, force_embed: 0, width: '100%', height: '100%', color: '00AEDF', multimoog: '' }, initialize: function(id, args) { this.id = id; this.setOptions(args); this.write(); }, write: function() { /** @todo: remove this when we get the html player working on embed settings page **/ if ( !DetectFlashVer(7, 0, 0) ) { // has Flash Player 6 or lower var iwhatever = /(i(pad|pod|phone))/.test(navigator.userAgent.toLowerCase()); var html = '
This action is currently disabled. Learn more about how PRO members can interact within the Vimeo Community.