0
+var HomeMarksUtilities = {
0
+ actionBar: function(request) { return $('action_bar'); },
0
+ getRequestMood: function(request) {
0
+ return (request.status >= 200 && request.status < 300) ? 'good' : 'bad';
0
+ messagesToAlert: function(request) {
0
+ var messages = request.responseJSON;
0
+ var alertText = messages.join(".\n");
0
+ if (alertText.endsWith('.')) { alert(alertText); } else { alert(alertText+'.'); };
0
+ messagesToList: function(request) {
0
+ var messages = request.responseJSON;
0
+ var messageList = UL();
0
+ messages.each(function(message){
0
+ messageList.appendChild( LI(message.escapeHTML()) );
0
+ scroll: function() { return document.viewport.getScrollOffsets(); },
0
+ pageSize: function() {
0
+ if (window.innerHeight && window.scrollMaxY) {
0
+ xScroll = window.innerWidth + window.scrollMaxX;
0
+ yScroll = window.innerHeight + window.scrollMaxY;
0
+ } else if (document.body.scrollHeight > document.body.offsetHeight){
0
+ xScroll = document.body.scrollWidth;
0
+ yScroll = document.body.scrollHeight;
0
+ xScroll = document.body.offsetWidth;
0
+ yScroll = document.body.offsetHeight;
0
+ var windowWidth, windowHeight;
0
+ if (self.innerHeight) {
0
+ if(document.documentElement.clientWidth){
0
+ windowWidth = document.documentElement.clientWidth;
0
+ windowWidth = self.innerWidth;
0
+ windowHeight = self.innerHeight;
0
+ } else if (document.documentElement && document.documentElement.clientHeight) {
0
+ windowWidth = document.documentElement.clientWidth;
0
+ windowHeight = document.documentElement.clientHeight;
0
+ } else if (document.body) {
0
+ windowWidth = document.body.clientWidth;
0
+ windowHeight = document.body.clientHeight;
0
+ if(yScroll < windowHeight){
0
+ pageHeight = windowHeight;
0
+ if(xScroll < windowWidth){
0
+ pageWidth = windowWidth;
0
+ return { width: pageWidth, height: pageHeight };
0
+var HomeMarksSite = Class.create(HomeMarksUtilities,{
0
+ initialize: function() {
0
+ this.ajaxFrom = $('ajaxforms_wrapper');
0
+ this.ajaxFromLinks = $$('.ajaxform_link');
0
+ this.supportForm = $('support_form');
0
+ this.loginForm = $('login_form');
0
+ this.signupForm = $('signup_form');
0
+ this.flashes = $$('div.flash_message');
0
+ clearFlashes: function() {
0
+ this.flashes.invoke('hide');
0
+ this.flashes.invoke('update','');
0
+ flash: function(mood,html) {
0
+ var moodFlash = this.flashes.find(function(e){ if (e.id == 'flash_'+mood) {return true}; });
0
+ moodFlash.update(html);
0
+ $('site_wrapper').scrollTo();
0
+ toggleAjaxFormBlind: function(event) {
0
+ if (event) { event.element().blur(); };
0
+ Effect.toggle(this.ajaxFrom, 'blind', {duration:0.4});
0
+ startAjaxForm: function(event) {
0
+ var form = event.findElement('form');
0
+ var options = Object.extend({loadId:'form_loading',imgSrc:'loading_invert.gif'}, arguments[1] || {});
0
+ var imgTag = IMG({src:('/images/'+options.imgSrc)});
0
+ $(options.loadId).update(imgTag);
0
+ new Ajax.Request(form.action,{
0
+ onComplete: function(request){ this.delegateCompleteAjaxForm(form,request) }.bind(this),
0
+ parameters: form.serialize(true)
0
+ delegateCompleteAjaxForm: function(form,request) {
0
+ var mood = this.getRequestMood(request);
0
+ this.completeAjaxForm(form,{mood:mood});
0
+ case this.supportForm : this.completeSupportForm(request);
0
+ case this.loginForm : this.completeLoginForm(request);
0
+ case this.signupForm : this.completeSignupForm(request);
0
+ var flashHtml = DIV([H2('Errors:'),this.messagesToList(request)]);
0
+ this.flash('bad',flashHtml);
0
+ completeAjaxForm: function(form) {
0
+ var options = Object.extend({loadId:'form_loading',mood:'good'}, arguments[1] || {});
0
+ var completeId = 'complete_ajax_form_' + options.loadId;
0
+ var imgSrc = '/images/'+options.mood+'.png';
0
+ var moodHtml = SPAN({id:completeId,class:'m0 p0'}, [IMG({src:imgSrc})]);
0
+ $(options.loadId).update(moodHtml);
0
+ setTimeout(function() { $(completeId).visualEffect('fade') },3000);
0
+ submitSupportForm: function(event) {
0
+ this.startAjaxForm(event,{imgSrc:'loading.gif'});
0
+ completeSupportForm: function(request) {
0
+ setTimeout(function(){ this.supportForm.reset(); this.supportForm.enable(); }.bind(this),2000);
0
+ this.toggleAjaxFormBlind();
0
+ this.flash('good','Thanks for submitting a support request!');
0
+ completeLoginForm: function(request) {
0
+ window.location = '/myhome'
0
+ completeSignupForm: function(request) {
0
+ var flashHTML = DIV([H2('Signup Complete:'),P('We have sent an email with a link to verify and activate your account. You can not login unless you verify your email address.')]);
0
+ this.flash('good',flashHTML);
0
+ initEvents: function() {
0
+ if (this.supportForm) { this.supportForm.observe('submit', this.submitSupportForm.bindAsEventListener(this)); };
0
+ if (this.loginForm) { this.loginForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
+ if (this.signupForm) { this.signupForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
+ this.ajaxFromLinks.each(function(element){
0
+ element.observe('click', this.toggleAjaxFormBlind.bindAsEventListener(this));
0
+// WindowUtilities.getWindowScroll() // => { top: 0, left: 0, width: 1002, height: 464 }
0
+// document.viewport.getDimensions() // => { width: 987, height: 494 }
0
+// document.viewport.getWidth() // => 987
0
+// document.viewport.getHeight() // => 494
0
+// document.viewport.getScrollOffsets() // => [0, 0]
0
+// WindowUtilities.getPageSize() // => { pageWidth: 1002, pageHeight: 3129, windowWidth: 1002 }
0
+// WindowUtilities.getPageSize() // => [987,3129]
0
+var Modal = Class.create(HomeMarksUtilities,{
0
+ initialize: function(modalFor) {
0
+ this.mask = $('modalmask');
0
+ this.progress = $('modal_progress');
0
+ this.wrapper = $('modal_html_ap-wrapper');
0
+ this.content = $('modal_html_rel-wrapper');
0
+ showProgress: function() {
0
+ var maskHTML = DIV({id:'modalmask',style:'display:none;'},[DIV({id:'modal_progress',style:'display:none;'})]);
0
+ var modalHTML = DIV({id:'modal_html_ap-wrapper',className:'inhomemarks_site'},[DIV({id:'modal_html_rel-wrapper',style:'display:none;'})]);
0
+ // :before => "this.blur(); setupModal(#{box.id})",
0
+ // :loading => "Element.show('modal_progress')" )
0
+ setupModal: function(boxid) {
0
+ boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ Effect.Appear(modalMask, {duration:0.4, from:0.0, to:0.9, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ Event.observe(window, 'resize', centerStuff);
0
+ Event.observe(window, 'scroll', centerStuff);
0
+ Event.observe(document, 'keypress', respondtoKeypress);
0
+ if (typeof($('action_area_shim'))!='undefined') {
0
+ Event.stopObserving(document, 'keypress', actionAreaHelper);
0
+ if (this.action_bar().hasClassName('barout')) { toggleActionArea('inbox'); }
0
+ centerStuff: function() {
0
+ if (this.wrapper.hasClassName('inhomemarks_site')) {this.centerBoxEdit();} else {this.centerBookmarklet();};
0
+ centerMask: function() {
0
+ this.mask.setStyle({height: this.pageSize().height + 'px'});
0
+ this.progress.setStyle({top: (this.scroll().top + 60) + 'px'});
0
+ centerBoxEdit: function() {
0
+ modalWrapperLeft = (this.pageSize().width - 652)/2;
0
+ if (modalWrapperLeft < 0) modalWrapperLeft = 0;
0
+ modalWrapper.setStyle({left: modalWrapperLeft+'px'}) ;
0
+ centerBookmarklet: function() {
0
+ modalWrapperLeft = (this.pageSize().width - 352)/2;
0
+ if (modalWrapperLeft < 0) modalWrapperLeft = 0;
0
+ modalWrapper.setStyle({left: modalWrapperLeft+'px'}) ;
0
+ destroyModal: function(boxid) {
0
+ boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ Event.stopObserving(window, 'resize', centerStuff);
0
+ Event.stopObserving(window, 'scroll', centerStuff);
0
+ Event.stopObserving(document, 'keypress', respondtoKeypress);
0
+ Effect.SlideUp(modalContent, {duration:0.4, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ Effect.Fade(modalMask, {duration:0.2, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ Event.observe(document, 'keypress', actionAreaHelper);
0
+ respondtoKeypress: function(event) {
0
+ if ($('modal_html_ap-wrapper').hasClassName('inhomemarks_site')) {
0
+ boxidstring = $('modal_button_cancel').classNames().toString();
0
+ boxid = boxidstring.gsub('cancel_modalbox_','');
0
+ if (event.keyCode == Event.KEY_ESC) destroyModal(boxid);
0
+ if (event.keyCode == Event.KEY_ESC) destroyModal();
0
+ hideModal: function(boxid) {
0
+ boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ Event.stopObserving(document, 'keypress', respondtoKeypress);
0
+ Effect.SlideUp(modalContent, {duration:0.4, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ Effect.Appear(modalProgress, {duration:0.2, from:0.0, to:0.9, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ destroyModalMask: function(boxid) {
0
+ boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ Event.stopObserving(window, 'resize', centerStuff);
0
+ Event.stopObserving(window, 'scroll', centerStuff);
0
+ Effect.Fade(modalMask, {duration:0.2, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ window.location.reload();
0
+document.observe('dom:loaded', function(){
0
+ HmSite = new HomeMarksSite();
0
+/* General Application Wide Functions
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+Event.observe(document, 'keypress', actionAreaHelper);
0
+function actionAreaHelper(event) { if (event.charCode == 96) {toggleActionArea('inbox')}; };
0
+function globalLoadingBehavior() {
0
+ $('hud').classNames().set('');
0
+ Element.show('loading');
0
+ Element.update('message_wrapper', '<span id="message"> </span>');
0
+function loadLameActionSpan(boxid,direction) {
0
+ if (direction == 'down') { spanclass = 'box_action box_action_down' }
0
+ if (direction == 'up') { spanclass = 'box_action' }
0
+ Element.replace('boxid_'+boxid+'_action_alink', '<span class="'+spanclass+'" id="boxid_'+boxid+'_action_lame"></span>')
0
+function remoteFormLoading(formobj,loadid) {
0
+ loadid = (loadid == null) ? 'form_loading' : loadid;
0
+ if (formobj.id == 'request_support_form') {loadimg=''} else {loadimg='_invert'};
0
+ Element.update($(loadid),'<img src="/images/loading'+loadimg+'.gif" />');
0
+ Form.disable(formobj);
0
+/* Custom sortable serialize params Column#sort
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+function findSortedInfo(obj) {
0
+ pg_sortable_id = obj.element.id;
0
+ pg_lastvalues = $A(obj.lastValue.gsub(/col_wrapper\[\]=/i,'').split('&'));
0
+ pg_sortable_seq = $A(Sortable.sequence(pg_sortable_id));
0
+ if (pg_lastvalues.length == pg_sortable_seq.length) { // Find the column info within the sortable.
0
+ pg_lastvalues.each(function(v,i) {
0
+ if (v != pg_sortable_seq[i]) {
0
+ /* Check to see if the bookmark was moved down */
0
+ if (pg_lastvalues[i+1] == pg_sortable_seq[i]) { col_id=v; col_position=pg_sortable_seq.indexOf(v)+1; };
0
+ /* Check to see if the bookmark was moved up */
0
+ if (pg_lastvalues[i] == pg_sortable_seq[i+1]) { col_id=pg_sortable_seq[i]; col_position=i+1; };
0
+ return 'col_id='+col_id+'&col_position='+col_position;
0
+ else { return false; }
0
+/* Custom sortable serialize params Box#sort
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+function findDroppedBoxInfo(obj) {
0
+ col_sortable_id = obj.element.id;
0
+ col_sortable_id_num = col_sortable_id.gsub(/col_/i,'');
0
+ col_empty = obj.lastValue.length == 0 ? true : false ;
0
+ col_lastvalues = $A(obj.lastValue.gsub(/(col_\d+)\[\]=/i,'').split('&'));
0
+ col_sortable_seq = $A(Sortable.sequence(col_sortable_id));
0
+ if ((col_lastvalues.length == col_sortable_seq.length) && !col_empty) { // Find the box info within the sortable.
0
+ col_internal_sort = true; col_lost_box = false;
0
+ col_lastvalues.each(function(v,i) {
0
+ if (v != col_sortable_seq[i]) {
0
+ /* Check to see if the box was moved down */
0
+ if (col_lastvalues[i+1] == col_sortable_seq[i]) { box_id=v; box_position=col_sortable_seq.indexOf(v)+1; };
0
+ /* Check to see if the box was moved up */
0
+ if (col_lastvalues[i] == col_sortable_seq[i+1]) { box_id=col_sortable_seq[i]; box_position=i+1; };
0
+ else { // Find the new or lost box info.
0
+ col_internal_sort = false;
0
+ col_lost_box = col_lastvalues.length > col_sortable_seq.length ? true : false ;
0
+ /* Column's with a lost box is ignored by the server. */
0
+ if (col_lost_box == true) { box_id = 'na' ; box_position = 'na' ; }
0
+ /* Column with no boxes now gaining one. */
0
+ else if (col_empty) { box_id = col_sortable_seq[0] ; box_position = 1 ; }
0
+ col_long_array = col_lastvalues.length > col_sortable_seq.length ? col_lastvalues : col_sortable_seq ;
0
+ col_short_array = col_lastvalues.length < col_sortable_seq.length ? col_lastvalues : col_sortable_seq ;
0
+ col_long_array.each(function(v,i) {
0
+ if (v != col_short_array[i]) { box_id=v; box_position=i+1; throw $break; };
0
+ return 'internal_sort='+col_internal_sort+'&lost_box='+col_lost_box+'&col_id='+col_sortable_id_num+'&box_id='+box_id+'&box_position='+box_position
0
+/* Custom sortable serialize params Bookmark#sort
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+function findDroppedBookmarkInfo(obj) {
0
+ sortable_id = obj.element.id;
0
+ sortable_id_num = sortable_id.gsub(/boxid_list_/i,'');
0
+ box_type = findSortableBoxType(sortable_id_num);
0
+ box_empty = obj.lastValue.length == 0 ? true : false ;
0
+ lastvalues = $A(obj.lastValue.gsub(/(boxid_list_\d+|inbox_list|trashbox_list)\[\]=/i,'').split('&'));
0
+ sortable_seq = $A(Sortable.sequence(sortable_id));
0
+ if ((lastvalues.length == sortable_seq.length) && !box_empty) { // Find the bookmark info within the sortable.
0
+ internal_sort = true; lost_bmark = false; bmark_scope = box_type;
0
+ lastvalues.each(function(v,i) {
0
+ if (v != sortable_seq[i]) {
0
+ /* Check to see if the bookmark was moved down */
0
+ if (lastvalues[i+1] == sortable_seq[i]) { bmark_id=v; bmark_position=sortable_seq.indexOf(v)+1; };
0
+ /* Check to see if the bookmark was moved up */
0
+ if (lastvalues[i] == sortable_seq[i+1]) { bmark_id=sortable_seq[i]; bmark_position=i+1; };
0
+ else { // Find the new or lost bookmark info.
0
+ internal_sort = false;
0
+ lost_bmark = lastvalues.length > sortable_seq.length ? true : false ;
0
+ /* Box's with a lost bookmark are ignored by the server. */
0
+ if (lost_bmark == true) { bmark_id = 'na' ; bmark_position = 'na' ; bmark_scope = 'na'; }
0
+ /* Box with no bookmarks now gaining one. */
0
+ else if (box_empty) { bmark_id = sortable_seq[0] ; bmark_position = 1 ; bmark_scope = findBmarkScope(box_type,sortable_id); }
0
+ long_array = lastvalues.length > sortable_seq.length ? lastvalues : sortable_seq ;
0
+ short_array = lastvalues.length < sortable_seq.length ? lastvalues : sortable_seq ;
0
+ long_array.each(function(v,i) {
0
+ if (v != short_array[i]) { bmark_id=v; bmark_position=i+1; throw $break; };
0
+ bmark_scope = findBmarkScope(box_type,sortable_id);
0
+ return 'internal_sort='+internal_sort+'&lost_bmark='+lost_bmark+'&box_type='+box_type+'&sortable_id='+sortable_id_num+'&bmark_id='+bmark_id+'&bmark_position='+bmark_position+'&bmark_scope='+bmark_scope
0
+function findSortableBoxType(sortable_id_num) {
0
+ if (sortable_id_num == 'inbox_list') { return 'inbox'; }
0
+ else if (sortable_id_num == 'trashbox_list') { return 'trashbox'; }
0
+ else { return 'box'; }
0
+function findBmarkScope(box_type, sortable_id) {
0
+ if (box_type == 'box') {
0
+ if ($('inbox_list').visible() && sortableHasClass(sortable_id,'inbox')) {return 'inbox'}
0
+ else if ($('trashbox_list').visible() && sortableHasClass(sortable_id,'trashbox')) {return 'trashbox'}
0
+function sortableHasClass(sortable_id, css_class) {
0
+ $A($(sortable_id).childNodes).each(function(li) {
0
+ if (li.hasClassName(css_class)) {css_check=true; throw $break;}
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+var Tooltip = Class.create();
0
+ initialize: function(a) {
0
+ this.a.onmouseover = this.showTooltip.bindAsEventListener(this);
0
+ this.a.onmouseout = this.hideTooltip.bindAsEventListener(this);
0
+ this.tooltip_id = this.a.firstChild.id.gsub('button_','tt_');
0
+ this.tooltip = this.a.title;
0
+ tooltip_box = Builder.node('div',{id:this.tooltip_id,className:'tooltip_box',style:'display:none;'},[
0
+ Builder.node('div',{className:'tooltip_left'}),
0
+ Builder.node('div',{className:'tooltip_middle'},[
0
+ Builder.node('div',{className:'tooltip_middlergt'}),
0
+ Builder.node('span',{className:'tooltip_message'},this.tooltip),
0
+ Builder.node('div',{className:'tooltip_right'}),
0
+ $('button_box').insertBefore(tooltip_box, this.a);
0
+ this.a.removeAttribute('title');
0
+ reseteffect: function() {
0
+ var effect = $(this.a)._effect;
0
+ if(effect) effect.cancel();
0
+ showTooltip: function(evt) {
0
+ this.a._effect = new Effect.Appear(this.tooltip_id,{delay:0.5,duration:0.3});
0
+ hideTooltip: function(evt) {
0
+ this.a._effect = new Effect.Fade(this.tooltip_id,{duration:0.3});
0
+Event.observe(window, 'load', activateTooltips, false);
0
+function activateTooltips() {
0
+ toolTipLinks = $$('a.tooltipable');
0
+ toolTipLinks.each( function(a) { new Tooltip(a); } );
0
+/* Action Area Specific Functions
0
+ * ----------------------------------------------------------------------------------------------------------------- */
0
+function getActionAreaVars() {
0
+ actionBar = $('action_bar');
0
+ actionArea = $('action_area');
0
+ actionAreaShim = $('action_area_shim');
0
+ pageSize = WindowUtilities.getPageSize();
0
+function toggleActionArea(action_box) {
0
+ setActionAreaHeigth();
0
+ if (Element.hasClassName(actionBar,'barout')) {
0
+ if (forceTrashbox(action_box)) { forceTrashboxLoad() }
0
+ actionAreaShim.hide();
0
+ actionBar.classNames().set('');
0
+ hud.setStyle({marginLeft:'28px'});
0
+ Event.stopObserving(window, 'resize', setActionAreaHeigth);
0
+ Event.stopObserving(window, 'scroll', setActionAreaHeigth);
0
+ actionAreaShim.show();
0
+ actionAreaShim.setStyle({height:pageSize.pageHeight+'px'});
0
+ actionArea.setStyle({height:pageSize.windowHeight+'px'});
0
+ actionBar.classNames().set('barout');
0
+ hud.setStyle({marginLeft:'9px'})
0
+ Event.observe(window, 'resize', setActionAreaHeigth);
0
+ Event.observe(window, 'scroll', setActionAreaHeigth);
0
+ if (getFieldsetFlag()=='') {
0
+ if (action_box=='inbox') {inboxLoad()}
0
+ else if (action_box=='trashbox') {trashboxLoad();}
0
+ else if (forceTrashbox(action_box)) { forceTrashboxLoad() }
0
+function forceTrashbox(action_box) {
0
+ if ((getFieldsetFlag()!='legend_trash') && (action_box=='trashbox')) { return true; } else { return false };
0
+function forceTrashboxLoad() {
0
+ loadingActionArea($('legend_trash_link'));
0
+ new Ajax.Request('/actionarea/trashbox', {asynchronous:true, evalScripts:true});
0
+function trashboxLoad() {
0
+ setFieldsetFlag('legend_trash');
0
+ $('legend_trash').classNames().set('fld_on');
0
+ new Ajax.Request('/actionarea/trashbox', {asynchronous:true, evalScripts:true});
0
+ setFieldsetFlag('legend_inbox');
0
+ $('legend_inbox').classNames().set('fld_on');
0
+ new Ajax.Request('/actionarea/inbox', {asynchronous:true, evalScripts:true});
0
+function setActionAreaHeigth(event) {
0
+ actionAreaShim.setStyle({height:pageSize.pageHeight+'px'});
0
+ actionArea.setStyle({height:pageSize.windowHeight+'px'});
0
+function setFieldsetFlag(ulid) {
0
+ $('fieldset_legend').classNames().set(ulid);
0
+function getFieldsetFlag() {
0
+ return $('fieldset_legend').classNames().toString();
0
+function isActionAreaDisplayed(obj) {
0
+ if (obj.childNodes[0].hasClassName('fld_on')) return false ;
0
+function loadingActionArea(obj) {
0
+ clicked = obj.childNodes[0];
0
+ currentFieldsetFlag = getFieldsetFlag();
0
+ switch (currentFieldsetFlag) {
0
+ case 'legend_inbox' : hidelist = 'inbox_list' ; break;
0
+ case 'legend_trash' : hidelist = 'trashbox_list' ; break;
0
+ case 'legend_search' : hidelist = 'searchbox_list' ; break;
0
+ setFieldsetFlag(clicked.id);
0
+ clicked.classNames().set('fld_on');
0
+ $(currentFieldsetFlag).classNames().set('');
0
+ if (clicked.id != 'legend_trash') {$('trashbox_emptytrash_box').hide()};
0
+ $('fieldset_progress_wrap').visualEffect('blind_down',{duration: 0.35});
0
+ $(hidelist).visualEffect('blind_up',{duration: 0.35});
0
+function showOrHideEmptyTrashBox() {
0
+ emptyTrashBox = $('trashbox_emptytrash_box');
0
+ if ( (Element.hasClassName('trashcan','trash_full')) && (getFieldsetFlag()=='legend_trash') ) {emptyTrashBox.show();} else {emptyTrashBox.hide();};