Created
August 4, 2012 04:11
-
-
Save andriasang/3254347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Behavior.addGlobalFilters ({ | |
AnimatedAnchor: { | |
defaults: { | |
duration: 'short', | |
transition: 'quad:in:out' | |
}, | |
setup: function (link, api) { | |
link.addEvent('click', function(event){ | |
anchor = link.get('href'); | |
anchor = anchor.substr (1, anchor.length); // get rid of the # | |
var el = document.getElement('a[name=' + anchor + ']'); | |
if (!el) return; | |
event.preventDefault(); | |
new Fx.Scroll (window, api.options).toElement(el); | |
}.bind(this)); | |
} | |
}, | |
SendMessage: { | |
defaults: { | |
recipient: null, | |
sender: null | |
}, | |
setup: function (elem, api) { | |
elem.addEvent ("click", function (e) { | |
e.preventDefault(); | |
if (window.message_composer) { | |
new message_composer ({"recipient_usernames": [api.get("recipient")], | |
"sender_username": api.get("sender"), | |
"position": "centered" | |
}); | |
} else { | |
sh.main.notify ("Loading messenger module"); | |
sh.util.require.loadModule ('message_composer', function () { | |
new message_composer ({ | |
"recipient_usernames": [api.get("recipient")], | |
"sender_username": api.get("sender"), | |
"position": "centered" | |
}); | |
}); | |
} | |
}); | |
} | |
}, | |
ToolTip: { | |
// these are just the options for the More.Tips class | |
defaults: { | |
"fixed": false, | |
"showDelay": 400, | |
"hideDelay": 200, | |
"offset": {x:5, y:20} | |
}, | |
setup: function (elem, api) { | |
myTip = new Tips (elem, api.options); | |
elem.store ('tip:title', elem.get ("data-tooltip-title")); | |
elem.store ('tip:text', elem.get ("data-tooltip-text")); | |
} | |
}, | |
DatePicker: { | |
// these are just the options for the More.Tips class | |
defaults: { | |
format: "%Y-%m-%d", | |
timePicker: false, | |
positionOffset: {x: 5, y: 0}, | |
pickerClass: 'datepicker_dashboard', | |
submitForm: true | |
}, | |
setup: function (elem, api) { | |
elem.set ("value", elem.get ("value")); | |
new Picker.Date(elem, { | |
format: api.options.format, | |
timePicker: api.options.timePicker, | |
positionOffset: api.options.positionOffset, | |
useFadeInOut: !Browser.ie, | |
animationDuration: 100, | |
blockKeydown: false, | |
pickerClass: api.options.pickerClass, | |
onSelect: function (date) { | |
if (api.options.submitForm) { | |
date = date.format(api.options.format) | |
// set the date value field and submit the form | |
elem.set ("value", date); | |
elem.getParent ("form").submit(); | |
} | |
return false; | |
} | |
}); | |
} | |
}, | |
PinOnScroll: { | |
defaults: { | |
}, | |
setup: function (elem, api) { | |
var unpinned_top = elem.getStyle ("top"); | |
var unpinned_left = elem.getStyle ("left"); | |
// get pinned style values by cloning and setting the style, then destroying | |
test_elem = elem.clone(); | |
test_elem.addClass ("pinned") | |
test_elem.setStyle ("display", "none"); | |
test_elem.inject (elem.getParent(), "top"); | |
var pinned_top = test_elem.getStyle ("top"); | |
var pinned_left = test_elem.getStyle ("left"); | |
test_elem.destroy(); | |
elem_position = elem.getPosition() | |
setPinVal = function (elem, param, val) { | |
if (val == "auto") { | |
// let the pin function set the value | |
} else { | |
elem.setStyle (param, val.toInt()) | |
} | |
}; | |
var ss = new ScrollSpy ({ | |
min: elem_position.y - pinned_top.toInt(), | |
// pin the element | |
onEnter: function(position,state,enters) { | |
elem.pin(); | |
elem.addClass ("pinned"); | |
setPinVal (elem, "top", pinned_top) | |
setPinVal (elem, "left", pinned_left) | |
}, | |
// unpin the element | |
onLeave: function(position,state,leaves) { | |
elem.unpin(); | |
elem.removeClass ("pinned"); | |
setPinVal (elem, "top", unpinned_top) | |
setPinVal (elem, "left", unpinned_left) | |
}, | |
container: window | |
}); | |
} | |
}, | |
Dropmenu: { | |
defaults: { | |
}, | |
setup: function (elem, api) { | |
elem.getElement (".dropmenu-toggle").addEvents({ | |
"click": function (e) { | |
e.preventDefault(); | |
elem.toggleClass ("open"); | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment