Browse Source

Adds width and fluid variations to popup, fix issue where popup click events werent being removed on destroy, added several new examples of popup features

pull/1063/head
jlukic 11 years ago
parent
commit
e7b6fa119e
8 changed files with 125 additions and 29 deletions
  1. 102
      server/documents/modules/popup.html.eco
  2. 4
      server/documents/views/list.html.eco
  3. 7
      server/files/javascript/popup.js
  4. 2
      server/files/stylesheets/semantic.css
  5. 9
      src/definitions/modules/popup.js
  6. 25
      src/definitions/modules/popup.less
  7. 1
      src/themes/packages/default/elements/icon.overrides
  8. 4
      src/themes/packages/default/modules/popup.variables

102
server/documents/modules/popup.html.eco

@ -52,6 +52,27 @@ themes : ['Default']
<h2 class="ui dividing header">Variations</h2>
<div class="example">
<h3 class="ui header">Width</h3>
<p>A popup can be extra wide to allow for longer content</p>
<i class="circular heart icon link" data-content="Hello. This is a wide pop-up which allows for lots of content with additional space. You can fit a lot of words here and the paragraphs will be pretty wide." data-variation="wide"></i>
<i class="circular heart icon link" data-content="Hello. This is a very wide pop-up which allows for lots of content with additional space. You can fit a lot of words here and the paragraphs will be pretty wide." data-variation="very wide"></i>
</div>
<div class="fluid example">
<h3 class="ui header">Fluid</h3>
<p>A fluid popup will take up the entire width of its offset container</p>
<div class="ui button">Show fluid popup</div>
<div class="ui fluid popup">
<div class="ui four column fitted divided center aligned grid">
<div class="column">1</div>
<div class="column">2</div>
<div class="column">3</div>
<div class="column">4</div>
</div>
</div>
</div>
<div class="example">
<h3 class="ui header">Size</h3>
<p>A popup can vary in size</p>
@ -174,26 +195,62 @@ themes : ['Default']
<div class="ui tab" data-tab="examples">
<div class="example">
<h3 class="ui header">Complex Content</h3>
<p>An easier way to display complex content inside a popup, instead of generating it from data attributes, is to have the popup content as part of your page's html.</p>
<p>The easiest way to specify custom content for a popup, is to use the setting <code>inline: true</code>. This will let Semantic know to use the next sibling popup element after the activator as the popup content.</p>
<div class="evaluated code">
$('.example .menu .browse')
.popup({
inline : true,
position : 'bottom left'
})
;
</div>
<div class="ui menu">
<a class="active item">
<i class="home icon"></i> Home
</a>
<a class="browse item">
Browse
<i class="dropdown icon"></i>
</a>
<div class="ui very wide popup">
<div class="ui four column divided fitted grid">
<div class="ui column">
1
</div>
<div class="ui column">
2
</div>
<div class="ui column">
3
</div>
<div class="ui column">
4
</div>
</div>
</div>
</div>
</div>
<div class="example">
<h3 class="ui header">Using Your Own Popup</h3>
<p>When using an inline popup</p>
<h3 class="ui header">Specifying a selector for a popup</h3>
<p>If its not possible to include the popup content as the next sibling, you can also specify a custom selector to help link the popup contents to its activator.</p>
<div class="evaluated code">
$('.example .teal.button')
.popup({
on: 'click'
})
;
$('.example input')
.popup({
on: 'focus'
})
;
$('.example .custom.button')
.popup({
popup : $('.custom.popup'),
on : 'click'
})
;
</div>
<div class="ui teal button" data-title="Using click events" data-content="Clicked popups will close if you click away, but not if you click inside the popup">Click Me</div>
<div class="ui icon input">
<input type="text" placeholder="Focus me..." data-content="You can use me to enter data">
<i class="search icon"></i>
<div class="arbitrary container">
<div class="ui custom button">Show custom popup</div>
</div>
<div class="ui custom popup">
I'm not on the same level as the button, but i can still be found.
</div>
</div>
@ -236,7 +293,8 @@ themes : ['Default']
<div class="ui green test button">Hover Me</div>
<div class="ui divider"></div>
<img class="medium ui test image" src="/images/demo/photo.jpg">
</div>
<div class="inline example">
<h3 class="ui header">Inline or relative to page</h3>
<p>A popup can either be inserted directly after an element, or added as a child element to the page's <code>body</code>.</p>
<div class="ui positive message">
@ -252,11 +310,11 @@ themes : ['Default']
}
</div>
<div class="evaluated code">
$('.inline.icon')
.popup({
inline: true
})
;
$('.inline.icon')
.popup({
inline: true
})
;
</div>
<i class="heart circular icon link" data-content="This is a child element to the page's body and will not be styled" ></i>
<i class="mail inline circular icon link" data-content="This popup was inserted inline and will be styled" ></i>

4
server/documents/views/list.html.eco

@ -176,7 +176,7 @@ themes : ['Default']
<div class="example">
<h4 class="ui header">Icon</h4>
<p>A list item can have an icon</p>
<p>A list item can contain an icon</p>
<div class="ui list">
<a class="item">
<i class="help icon"></i>
@ -205,7 +205,7 @@ themes : ['Default']
<div class="example">
<h4 class="ui header">Image</h4>
<p>A list can contain an image</p>
<p>A list item can contain an image</p>
<div class="ui list">
<div class="item">
<div class="ui avatar image">

7
server/files/javascript/popup.js

@ -18,6 +18,13 @@ semantic.popup.ready = function() {
})
;
$('.fluid.example .button')
.popup({
inline: true
})
;
};

2
server/files/stylesheets/semantic.css

@ -605,7 +605,7 @@ body.guide .main.container > * {
height: 175px;
}
#example.popup .example .popup {
#example.popup .inline.example .popup {
color: #FF0000;
}
#example .position.example .icon {

9
src/definitions/modules/popup.js

@ -70,7 +70,7 @@ $.fn.popup = function(parameters) {
module.refresh();
if(settings.on == 'click') {
$module
.on('click', module.toggle)
.on('click' + eventNamespace, module.toggle)
;
}
else if( module.get.startEvent() ) {
@ -277,7 +277,7 @@ $.fn.popup = function(parameters) {
if(!$popup) {
return false;
}
if(settings.inline) {
if(settings.inline || settings.popup) {
return ( $popup.size() !== 0 );
}
else {
@ -396,6 +396,7 @@ $.fn.popup = function(parameters) {
offstage = {},
offstagePositions = []
;
console.log($popup.width());
if(popup.position) {
offstage = {
top : (popup.position.top < boundary.top),
@ -464,7 +465,7 @@ $.fn.popup = function(parameters) {
distanceAway = settings.distanceAway,
offset = (settings.inline)
offset = (settings.inline || settings.popup)
? $target.position()
: $target.offset(),
@ -474,7 +475,7 @@ $.fn.popup = function(parameters) {
position = position || $module.data(metadata.position) || settings.position;
arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset;
// adjust for margin when inline
if(settings.inline) {
if(settings.inline || settings.popup) {
if(position == 'left center' || position == 'right center') {
arrowOffset += parseInt( window.getComputedStyle(element).getPropertyValue('margin-top'), 10);
distanceAway += -parseInt( window.getComputedStyle(element).getPropertyValue('margin-left'), 10);

25
src/definitions/modules/popup.less

@ -204,6 +204,31 @@
Variations
*******************************/
/*--------------
Wide
---------------*/
.ui.wide.popup {
width: @wideWidth;
max-width: @wideWidth;
}
.ui.very.wide.popup {
width: @veryWideWidth;
max-width: @veryWideWidth;
}
/*--------------
Fluid
---------------*/
.ui.fluid.popup {
width: 100%;
max-width: 99999px;
}
/*--------------
Colors
---------------*/

1
src/themes/packages/default/elements/icon.overrides

@ -605,6 +605,7 @@ i.icon.magic:before { content: "\f0d0"; }
i.icon.truck:before { content: "\f0d1"; }
i.icon.currency:before { content: "\f0d6"; }
i.icon.triangle.down:before { content: "\f0d7"; }
i.icon.dropdown:before { content: "\f0d7"; }
i.icon.triangle.up:before { content: "\f0d8"; }
i.icon.triangle.left:before { content: "\f0d9"; }
i.icon.triangle.right:before { content: "\f0da"; }

4
src/themes/packages/default/modules/popup.variables

@ -67,6 +67,10 @@
Variations
--------------------*/
/* Wide */
@wideWidth: 350px;
@veryWideWidth: 550px;
/* Inverted */
@invertedBackground: @black;
@invertedColor: @white;

Loading…
Cancel
Save