0
+var HomeMarksUtil
ities = {
0
- parseResponseMood: function(request) {
0
+ actionBar: function(request) { return $('action_bar'); },
0
+ getRequestMood: function(request) {
0
return (request.status >= 200 && request.status < 300) ? 'good' : 'bad';
0
-
alertMessages: function(request) {
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
-
parseFlashMessages: function(request) {
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(
{
0
+var HomeMarksSite = Class.create(
HomeMarksUtilities,{
0
initialize: function() {
0
this.ajaxFrom = $('ajaxforms_wrapper');
0
delegateCompleteAjaxForm: function(form,request) {
0
- var mood =
HomeMarksUtil.parseResponseMood(request);
0
+ var mood =
this.getRequestMood(request);
0
this.completeAjaxForm(form,{mood:mood});
0
- var flashHtml = DIV([H2('Errors:'),
HomeMarksUtil.parseFlashMessages(request)]);
0
+ var flashHtml = DIV([H2('Errors:'),
this.messagesToList(request)]);
0
this.flash('bad',flashHtml);
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
+ 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
+// 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
+var Box = Class.create({
0
+var HomeMarksApp = Class.create(HomeMarksUtilities,{
0
+ initialize: function() {
0
+ var boxEdits = $$('span.box_edit');
0
+ editBoxLinks: function() {
0
+ // page.replace_html 'modal_html_rel-wrapper', :partial => 'edit_links'
0
+ // page.hide :modal_progress
0
+ // page.visual_effect :slide_down, 'modal_html_rel-wrapper', :duration => 0.4, :queue => {:position => 'end', :scope => "boxid_#{@box.id}"}
0
+ initEvents: function() {
0
+ this.boxEdits.each(function(element){
0
+ element.observe('click', this.editBoxLinks.bindAsEventListener(this));
0
document.observe('dom:loaded', function(){
0
HmSite = new HomeMarksSite();
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
/* Custom sortable serialize params Column#sort
0
function activateTooltips() {
0
toolTipLinks = $$('a.tooltipable');
0
toolTipLinks.each( function(a) { new Tooltip(a); } );
0
-/* Modal Specific Functions
0
- * ----------------------------------------------------------------------------------------------------------------- */
0
-function getModalVars() {
0
- modalMask = $('modalmask');
0
- modalProgress = $('modal_progress');
0
- modalWrapper = $('modal_html_ap-wrapper');
0
- modalContent = $('modal_html_rel-wrapper');
0
- windowScroll = WindowUtilities.getWindowScroll();
0
- pageSize = WindowUtilities.getPageSize();
0
-function setupModal(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 (Element.hasClassName('action_bar','barout')) { toggleActionArea('inbox'); }
0
-function centerStuff() {
0
- if (modalWrapper.hasClassName('inhomemarks_site')) {centerBoxEditModal();} else {centerBookmarkletModal();};
0
-function centerModalMask() {
0
- modalMask.setStyle({height: pageSize.pageHeight + 'px'});
0
- modalProgress.setStyle({top: (windowScroll.top + 60) + 'px'});
0
-function centerBoxEditModal() {
0
- modalWrapperLeft = (pageSize.pageWidth - 652)/2;
0
- if (modalWrapperLeft < 0) modalWrapperLeft = 0;
0
- modalWrapper.setStyle({left: modalWrapperLeft+'px'}) ;
0
-function centerBookmarkletModal() {
0
- modalWrapperLeft = (pageSize.pageWidth - 352)/2;
0
- if (modalWrapperLeft < 0) modalWrapperLeft = 0;
0
- modalWrapper.setStyle({left: modalWrapperLeft+'px'}) ;
0
-function destroyModal(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
-function respondtoKeypress(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
-function hideModal(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
-function destroyModalMask(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
/* Action Area Specific Functions
0
* ----------------------------------------------------------------------------------------------------------------- */
0
actionArea = $('action_area');
0
actionAreaShim = $('action_area_shim');
0
pageSize = WindowUtilities.getPageSize();
0
- windowScroll = WindowUtilities.getWindowScroll();
0
function toggleActionArea(action_box) {
0
hud.setStyle({marginLeft:'28px'});
0
Event.stopObserving(window, 'resize', setActionAreaHeigth);
0
Event.stopObserving(window, 'scroll', setActionAreaHeigth);
0
actionAreaShim.setStyle({height:pageSize.pageHeight+'px'});
0
if (getFieldsetFlag()=='') {
0
if (action_box=='inbox') {inboxLoad()}
0
else if (action_box=='trashbox') {trashboxLoad();}
0
- else if (forceTrashbox(action_box)) { forceTrashboxLoad() }
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
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();};
0
-/* Some Window Utilities
0
- * -----------------------------------------------------------------------------------------------------------------
0
- * getPageSize() based on Lightbox JS: Fullsize Image Overlays by Lokesh Dhakar - http://www.huddletogether.com
0
- * For more information on this script, visit: http://huddletogether.com/projects/lightbox/
0
- * Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
0
- * getWindowScroll() - Returns a hash with top & left scroll offset and total viewport scroll area. From script.aculo.us
0
- * Get geeky and learn more at http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
0
- * ----------------------------------------------------------------------------------------------------------------- */
0
-var WindowUtilities = {
0
- getWindowScroll: function() {
0
- if (w.document.documentElement && documentElement.scrollTop) {
0
- T = documentElement.scrollTop;
0
- L = documentElement.scrollLeft;
0
- } else if (w.document.body) {
0
- } else if (w.document.documentElement && documentElement.clientWidth) {
0
- W = documentElement.clientWidth;
0
- H = documentElement.clientHeight;
0
- return { top: T, left: L, width: W, height: H };
0
- getPageSize: function(){
0
- if (window.innerHeight && window.scrollMaxY) {
0
- xScroll = document.body.scrollWidth;
0
- yScroll = window.innerHeight + window.scrollMaxY;
0
- } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
0
- xScroll = document.body.scrollWidth;
0
- yScroll = document.body.scrollHeight;
0
- } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
0
- xScroll = document.body.offsetWidth;
0
- yScroll = document.body.offsetHeight;
0
- var windowWidth, windowHeight;
0
- if (self.innerHeight) { // all except Explorer
0
- windowWidth = self.innerWidth;
0
- windowHeight = self.innerHeight;
0
- } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
0
- windowWidth = document.documentElement.clientWidth;
0
- windowHeight = document.documentElement.clientHeight;
0
- } else if (document.body) { // other Explorers
0
- windowWidth = document.body.clientWidth;
0
- windowHeight = document.body.clientHeight;
0
- var pageHeight, pageWidth;
0
- // for small pages with total height less then height of the viewport
0
- if(yScroll < windowHeight){
0
- pageHeight = windowHeight;
0
- // for small pages with total width less then width of the viewport
0
- if(xScroll < windowWidth){
0
- pageWidth = windowWidth;
0
- return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
Comments
No one has commented yet.