Skip to content

Commit

Permalink
Updated component to version 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Semantic-Pusher-Robot committed Mar 5, 2015
1 parent 934cc92 commit 7199c1e
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 76 deletions.
7 changes: 7 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Version 1.11.0 - March 3, 2015

- **Popup** - Added `exclusive` parameter to automatically close other popups on open
- **Popup** - Fix issue with `popup` not re-opening until another element gains focus on a mobile touchscreen
- **Popup** - Popup will now fire `onHidden` when an element is hidden by opening a different popup
- **Popup** - Fix popup not namespacing `window` events and unbinding on `destroy` **Thanks @revov**

### UI Changes

- **Transition** - Transitions with direction now use word order dependency to prevent conflict with component directions, for example `bottom left popup slide down in transition
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"framework"
],
"license": "MIT",
"version": "1.10.3"
"version": "1.11.0"
}
105 changes: 71 additions & 34 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 1.10.3 - Popup
* # Semantic UI 1.11.0 - Popup
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down Expand Up @@ -64,39 +64,27 @@ module.exports = function(parameters) {

element = this,
instance = $module.data(moduleNamespace),

elementNamespace,
id,
module
;

module = {

// binds events
initialize: function() {
module.debug('Initializing module', $module);
if(settings.on == 'click') {
$module
.on('click' + eventNamespace, module.toggle)
;
}
else if( module.get.startEvent() ) {
$module
.on(module.get.startEvent() + eventNamespace, module.event.start)
.on(module.get.endEvent() + eventNamespace, module.event.end)
;
}
if(settings.target) {
module.debug('Target set to element', $target);
}
$window
.on('resize' + eventNamespace, module.event.resize)
;
module.debug('Initializing', $module);
module.createID();
module.bind.events();
if( !module.exists() && settings.preserve) {
module.create();
}
module.instantiate();
},

instantiate: function() {
module.verbose('Storing instance of module', module);
module.verbose('Storing instance', module);
instance = module;
$module
.data(moduleNamespace, instance)
Expand Down Expand Up @@ -145,11 +133,15 @@ module.exports = function(parameters) {

destroy: function() {
module.debug('Destroying previous module');
// remove element only if was created dynamically
if($popup && !settings.preserve) {
module.removePopup();
}
// clear all timeouts
clearTimeout(module.hideTimer);
clearTimeout(module.showTimer);
// remove events
$window.off(elementNamespace);
$module
.off(eventNamespace)
.removeData(moduleNamespace)
Expand Down Expand Up @@ -209,6 +201,7 @@ module.exports = function(parameters) {
$popup = $('<div/>')
.addClass(className.popup)
.addClass(variation)
.data(metadata.activator, $module)
.html(html)
;
if(variation) {
Expand Down Expand Up @@ -237,13 +230,14 @@ module.exports = function(parameters) {
else if($target.next(selector.popup).length !== 0) {
module.verbose('Pre-existing popup found');
settings.inline = true;
settings.popup = $target.next(selector.popup);
settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
module.refresh();
if(settings.hoverable) {
module.bind.popup();
}
}
else if(settings.popup) {
settings.popup.data(metadata.activator, $module);
module.verbose('Used popup specified in settings');
module.refresh();
if(settings.hoverable) {
Expand All @@ -255,13 +249,18 @@ module.exports = function(parameters) {
}
},

createID: function() {
id = (Math.random().toString(16) + '000000000').substr(2,8);
elementNamespace = '.' + id;
module.verbose('Creating unique id for element', id);
},

// determines popup state
toggle: function() {
module.debug('Toggling pop-up');
if( module.is.hidden() ) {
module.debug('Popup is hidden, showing pop-up');
module.unbind.close();
module.hideAll();
module.show();
}
else {
Expand All @@ -281,6 +280,9 @@ module.exports = function(parameters) {
}
if( $popup && module.set.position() ) {
module.save.conditions();
if(settings.exclusive) {
module.hideAll();
}
module.animate.show(callback);
}
},
Expand All @@ -298,8 +300,13 @@ module.exports = function(parameters) {

hideAll: function() {
$(selector.popup)
.filter(':visible')
.transition(settings.transition)
.filter('.' + className.visible)
.each(function() {
$(this)
.data(metadata.activator)
.popup('hide')
;
})
;
},

Expand Down Expand Up @@ -425,15 +432,27 @@ module.exports = function(parameters) {
},

get: {
id: function() {
return id;
},
startEvent: function() {
if(settings.on == 'hover') {
return 'mouseenter';
return (hasTouch)
? 'touchstart mouseenter'
: 'mouseenter'
;
}
else if(settings.on == 'focus') {
return 'focus';
}
return false;
},
scrollEvent: function() {
return (hasTouch)
? 'touchmove scroll'
: 'scroll'
;
},
endEvent: function() {
if(settings.on == 'hover') {
return 'mouseleave';
Expand Down Expand Up @@ -743,7 +762,7 @@ module.exports = function(parameters) {
}
else if(!settings.lastResort) {
module.debug('Popup could not find a position in view', $popup);
module.error(error.cannotPlace);
module.error(error.cannotPlace, element);
module.remove.attempts();
module.remove.loading();
module.reset();
Expand Down Expand Up @@ -784,6 +803,24 @@ module.exports = function(parameters) {
},

bind: {
events: function() {
module.debug('Binding popup events to module');
if(settings.on == 'click') {
$module
.on('click' + eventNamespace, module.toggle)
;
}
else if( module.get.startEvent() ) {
$module
.on(module.get.startEvent() + eventNamespace, module.event.start)
.on(module.get.endEvent() + eventNamespace, module.event.end)
;
}
if(settings.target) {
module.debug('Target set to element', $target);
}
$window.on('resize' + elementNamespace, module.event.resize);
},
popup: function() {
module.verbose('Allowing hover events on popup to prevent closing');
if( $popup && module.has.popup() ) {
Expand All @@ -796,18 +833,16 @@ module.exports = function(parameters) {
close:function() {
if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
$document
.one('touchmove' + eventNamespace, module.hideGracefully)
.one('scroll' + eventNamespace, module.hideGracefully)
.one(module.get.scrollEvent() + elementNamespace, module.hideGracefully)
;
$context
.one('touchmove' + eventNamespace, module.hideGracefully)
.one('scroll' + eventNamespace, module.hideGracefully)
.one(module.get.scrollEvent() + elementNamespace, module.hideGracefully)
;
}
if(settings.on == 'click' && settings.closable) {
module.verbose('Binding popup close event to document');
$document
.on('click' + eventNamespace, function(event) {
.on('click' + elementNamespace, function(event) {
module.verbose('Pop-up clickaway intent detected');
module.hideGracefully.call(element, event);
})
Expand All @@ -820,16 +855,16 @@ module.exports = function(parameters) {
close: function() {
if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
$document
.off('scroll' + eventNamespace, module.hide)
.off('scroll' + elementNamespace, module.hide)
;
$context
.off('scroll' + eventNamespace, module.hide)
.off('scroll' + elementNamespace, module.hide)
;
}
if(settings.on == 'click' && settings.closable) {
module.verbose('Removing close event from document');
$document
.off('click' + eventNamespace)
.off('click' + elementNamespace)
;
}
}
Expand Down Expand Up @@ -1076,6 +1111,7 @@ module.exports.settings = {
on : 'hover',
closable : true,
hideOnScroll : 'auto',
exclusive : true,

context : 'body',

Expand Down Expand Up @@ -1112,6 +1148,7 @@ module.exports.settings = {
},

metadata: {
activator : 'activator',
content : 'content',
html : 'html',
offset : 'offset',
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Package.describe({
name : 'semantic:ui-popup',
summary : 'Semantic UI - Popup: Single component release',
version : '1.10.3',
version : '1.11.0',
git : 'git://github.com/Semantic-Org/UI-Popup.git',
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "semantic-ui-popup",
"version": "1.10.3",
"version": "1.11.0",
"title": "Semantic UI - Popup",
"description": "Single component release of popup",
"homepage": "http://www.semantic-ui.com",
Expand Down
2 changes: 1 addition & 1 deletion popup.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 1.10.3 - Popup
* # Semantic UI 1.11.0 - Popup
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
Loading

0 comments on commit 7199c1e

Please sign in to comment.