Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bubble(content, triggerElm){
- this.element = $('<div class="bubble" />').html(content);
- this.element.css(.....) // here is positioned based on triggerElm
- }
- bubble.prototype.show = function(){
- $(document).on('click', this._click.bind(this));
- this.element.css(....)
- };
- bubble.prototype.hide = function(){
- $(document).off('click', this._click.bind(this));
- this.element.css(....)
- };
- bubble.prototype._click = function(event){
- console.log('click', this);
- if(this.element.is(event.target) || (this.element.has(event.target).length > 0))
- return true;
- this.hide();
- };
- var b = new bubble();
- b.show();
- b.hide();
- function bubble(content, tiggerElm) {
- var element = $('<div class="bubble" />').html(content);
- element.css(.....); // here is positioned based on triggerElm
- function click(event) {
- console.log('click', element);
- if (element.is(event.target) ||
- element.has(event.target).length > 0) {
- return true;
- }
- hide();
- }
- function show() {
- $(document).on('click', click);
- element.css(....);
- }
- function hide() {
- $(document).off('click', click);
- element.css(....);
- }
- return {
- show: show,
- hide: hide
- };
- }
- var b1 = bubble(..., ...);
- b1.show();
- var b2 = bubble(..., ...);
- b2.show();
- $(document).on('click.name', test.bind(this));
- $(document).off('click.name');
- var test = function(){
- console.log('click');
- };
- $(document).on('click', $.proxy(test, this));
- $(document).off('click', $.proxy(test, this));
- var test = function(){
- console.log('click');
- };
- var newFunct = test.bind(this);
- $(document).on('click', newFunct );
- $(document).off('click', newFunct );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement