[WIP] Working on uploader
This commit is contained in:
487
build/js/include/plugins/toolbar/jquery.toolbar.css
Normal file
487
build/js/include/plugins/toolbar/jquery.toolbar.css
Normal file
@@ -0,0 +1,487 @@
|
||||
.tool-container, .tool-item, .btn-toolbar {
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.btn-toolbar {
|
||||
background: #364347;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
display: block;
|
||||
transition: none;
|
||||
}
|
||||
.btn-toolbar > i {
|
||||
color: #02baf2;
|
||||
font-size: 16px;
|
||||
}
|
||||
.btn-toolbar:hover {
|
||||
background: #02baf2;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-toolbar:hover > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-primary {
|
||||
background-color: #009dcd;
|
||||
}
|
||||
.btn-toolbar-primary.pressed {
|
||||
background-color: #02baf2;
|
||||
}
|
||||
.btn-toolbar-primary:hover {
|
||||
background-color: #02baf2;
|
||||
}
|
||||
.btn-toolbar-primary > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-danger {
|
||||
background-color: #cc0000;
|
||||
}
|
||||
.btn-toolbar-danger.pressed {
|
||||
background-color: #f84545;
|
||||
}
|
||||
.btn-toolbar-danger:hover {
|
||||
background-color: #f84545;
|
||||
}
|
||||
.btn-toolbar-danger > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-warning {
|
||||
background-color: #f3bc65;
|
||||
}
|
||||
.btn-toolbar-warning.pressed {
|
||||
background-color: #fad46b;
|
||||
}
|
||||
.btn-toolbar-warning:hover {
|
||||
background-color: #fad46b;
|
||||
}
|
||||
.btn-toolbar-warning > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-info {
|
||||
background-color: #e96300;
|
||||
}
|
||||
.btn-toolbar-info.pressed {
|
||||
background-color: #f58410;
|
||||
}
|
||||
.btn-toolbar-info:hover {
|
||||
background-color: #f58410;
|
||||
}
|
||||
.btn-toolbar-info > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-success {
|
||||
background-color: #28948c;
|
||||
}
|
||||
.btn-toolbar-success.pressed {
|
||||
background-color: #3eb5ac;
|
||||
}
|
||||
.btn-toolbar-success:hover {
|
||||
background-color: #3eb5ac;
|
||||
}
|
||||
.btn-toolbar-success > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-info-o {
|
||||
background-color: #9175bd;
|
||||
}
|
||||
.btn-toolbar-info-o.pressed {
|
||||
background-color: #a88cd5;
|
||||
}
|
||||
.btn-toolbar-info-o:hover {
|
||||
background-color: #a88cd5;
|
||||
}
|
||||
.btn-toolbar-info-o > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-light {
|
||||
background-color: #b2c6cd;
|
||||
}
|
||||
.btn-toolbar-light.pressed {
|
||||
background-color: #d6e1e5;
|
||||
}
|
||||
.btn-toolbar-light:hover {
|
||||
background-color: #d6e1e5;
|
||||
}
|
||||
.btn-toolbar-light > i {
|
||||
color: white;
|
||||
}
|
||||
.btn-toolbar-dark {
|
||||
background-color: #364347;
|
||||
}
|
||||
.btn-toolbar-dark.pressed {
|
||||
background-color: #5e696d;
|
||||
}
|
||||
.btn-toolbar-dark:hover {
|
||||
background-color: #5e696d;
|
||||
}
|
||||
.btn-toolbar-dark > i {
|
||||
color: white;
|
||||
}
|
||||
.tool-container {
|
||||
background-color: #5e696d;
|
||||
background-size: 100% 100%;
|
||||
border-radius: 6px;
|
||||
position: absolute;
|
||||
}
|
||||
.tool-container.tool-top,
|
||||
.tool-container.tool-bottom {
|
||||
height: 40px;
|
||||
border-bottom: 0px solid #beb8b8;
|
||||
}
|
||||
.tool-container.tool-top .tool-item,
|
||||
.tool-container.tool-bottom .tool-item {
|
||||
float: left;
|
||||
border-right: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
.tool-item {
|
||||
height: 100%;
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
transition: none;
|
||||
}
|
||||
.tool-item > .fa {
|
||||
color: #b2c6cd;
|
||||
}
|
||||
.tool-item.selected,
|
||||
.tool-item:hover {
|
||||
background: #02baf2;
|
||||
}
|
||||
.tool-item.selected > .fa,
|
||||
.tool-item:hover > .fa {
|
||||
color: white;
|
||||
}
|
||||
.tool-top .tool-item:first-child:hover,
|
||||
.tool-bottom .tool-item:first-child:hover {
|
||||
border-top-left-radius: 6px;
|
||||
border-bottom-left-radius: 6px;
|
||||
}
|
||||
.tool-top .tool-item:last-child:hover,
|
||||
.tool-bottom .tool-item:last-child:hover {
|
||||
border-top-right-radius: 6px;
|
||||
border-bottom-right-radius: 6px;
|
||||
}
|
||||
.tool-vertical-top .tool-item:first-child:hover,
|
||||
.tool-vertical-bottom .tool-item:first-child:hover,
|
||||
.tool-right .tool-item:first-child:hover,
|
||||
.tool-left .tool-item:first-child:hover {
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
}
|
||||
.tool-vertical-top .tool-item:last-child:hover,
|
||||
.tool-vertical-bottom .tool-item:last-child:hover,
|
||||
.tool-right .tool-item:last-child:hover,
|
||||
.tool-left .tool-item:last-child:hover {
|
||||
border-bottom-left-radius: 6px;
|
||||
border-bottom-right-radius: 6px;
|
||||
}
|
||||
.tool-container .arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
border-width: 7px;
|
||||
border-style: solid;
|
||||
}
|
||||
.tool-container.tool-top .arrow {
|
||||
border-color: #5e696d transparent transparent;
|
||||
left: 50%;
|
||||
bottom: -14px;
|
||||
margin-left: -7px;
|
||||
}
|
||||
.tool-container.tool-bottom .arrow {
|
||||
border-color: transparent transparent #5e696d;
|
||||
left: 50%;
|
||||
top: -14px;
|
||||
margin-left: -7px;
|
||||
}
|
||||
.tool-container.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #5e696d;
|
||||
top: 50%;
|
||||
right: -14px;
|
||||
margin-top: -7px;
|
||||
}
|
||||
.tool-container.tool-right .arrow {
|
||||
border-color: transparent #5e696d transparent transparent;
|
||||
top: 50%;
|
||||
left: -14px;
|
||||
margin-top: -7px;
|
||||
}
|
||||
.toolbar-primary {
|
||||
background-color: #02baf2;
|
||||
}
|
||||
.toolbar-primary.tool-top .arrow {
|
||||
border-color: #02baf2 transparent transparent;
|
||||
}
|
||||
.toolbar-primary.tool-bottom .arrow {
|
||||
border-color: transparent transparent #02baf2;
|
||||
}
|
||||
.toolbar-primary.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #02baf2;
|
||||
}
|
||||
.toolbar-primary.tool-right .arrow {
|
||||
border-color: transparent #02baf2 transparent transparent;
|
||||
}
|
||||
.toolbar-primary .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-primary .tool-item.selected,
|
||||
.toolbar-primary .tool-item:hover {
|
||||
background: #009dcd;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-danger {
|
||||
background-color: #f84545;
|
||||
}
|
||||
.toolbar-danger.tool-top .arrow {
|
||||
border-color: #f84545 transparent transparent;
|
||||
}
|
||||
.toolbar-danger.tool-bottom .arrow {
|
||||
border-color: transparent transparent #f84545;
|
||||
}
|
||||
.toolbar-danger.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #f84545;
|
||||
}
|
||||
.toolbar-danger.tool-right .arrow {
|
||||
border-color: transparent #f84545 transparent transparent;
|
||||
}
|
||||
.toolbar-danger .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-danger .tool-item.selected,
|
||||
.toolbar-danger .tool-item:hover {
|
||||
background: #cc0000;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-warning {
|
||||
background-color: #f3bc65;
|
||||
}
|
||||
.toolbar-warning.tool-top .arrow {
|
||||
border-color: #f3bc65 transparent transparent;
|
||||
}
|
||||
.toolbar-warning.tool-bottom .arrow {
|
||||
border-color: transparent transparent #f3bc65;
|
||||
}
|
||||
.toolbar-warning.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #f3bc65;
|
||||
}
|
||||
.toolbar-warning.tool-right .arrow {
|
||||
border-color: transparent #f3bc65 transparent transparent;
|
||||
}
|
||||
.toolbar-warning .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-warning .tool-item.selected,
|
||||
.toolbar-warning .tool-item:hover {
|
||||
background: #fad46b;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-info {
|
||||
background-color: #e96300;
|
||||
}
|
||||
.toolbar-info.tool-top .arrow {
|
||||
border-color: #e96300 transparent transparent;
|
||||
}
|
||||
.toolbar-info.tool-bottom .arrow {
|
||||
border-color: transparent transparent #e96300;
|
||||
}
|
||||
.toolbar-info.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #e96300;
|
||||
}
|
||||
.toolbar-info.tool-right .arrow {
|
||||
border-color: transparent #e96300 transparent transparent;
|
||||
}
|
||||
.toolbar-info .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-info .tool-item.selected,
|
||||
.toolbar-info .tool-item:hover {
|
||||
background: #f58410;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-success {
|
||||
background-color: #28948c;
|
||||
}
|
||||
.toolbar-success.tool-top .arrow {
|
||||
border-color: #28948c transparent transparent;
|
||||
}
|
||||
.toolbar-success.tool-bottom .arrow {
|
||||
border-color: transparent transparent #28948c;
|
||||
}
|
||||
.toolbar-success.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #28948c;
|
||||
}
|
||||
.toolbar-success.tool-right .arrow {
|
||||
border-color: transparent #28948c transparent transparent;
|
||||
}
|
||||
.toolbar-success .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-success .tool-item.selected,
|
||||
.toolbar-success .tool-item:hover {
|
||||
background: #3eb5ac;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-info-o {
|
||||
background-color: #9175bd;
|
||||
}
|
||||
.toolbar-info-o.tool-top .arrow {
|
||||
border-color: #9175bd transparent transparent;
|
||||
}
|
||||
.toolbar-info-o.tool-bottom .arrow {
|
||||
border-color: transparent transparent #9175bd;
|
||||
}
|
||||
.toolbar-info-o.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #9175bd;
|
||||
}
|
||||
.toolbar-info-o.tool-right .arrow {
|
||||
border-color: transparent #9175bd transparent transparent;
|
||||
}
|
||||
.toolbar-info-o .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-info-o .tool-item.selected,
|
||||
.toolbar-info-o .tool-item:hover {
|
||||
background: #a88cd5;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-light {
|
||||
background-color: #b2c6cd;
|
||||
}
|
||||
.toolbar-light.tool-top .arrow {
|
||||
border-color: #b2c6cd transparent transparent;
|
||||
}
|
||||
.toolbar-light.tool-bottom .arrow {
|
||||
border-color: transparent transparent #b2c6cd;
|
||||
}
|
||||
.toolbar-light.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #b2c6cd;
|
||||
}
|
||||
.toolbar-light.tool-right .arrow {
|
||||
border-color: transparent #b2c6cd transparent transparent;
|
||||
}
|
||||
.toolbar-light .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-light .tool-item.selected,
|
||||
.toolbar-light .tool-item:hover {
|
||||
background: #d6e1e5;
|
||||
color: white;
|
||||
}
|
||||
.toolbar-dark {
|
||||
background-color: #364347;
|
||||
}
|
||||
.toolbar-dark.tool-top .arrow {
|
||||
border-color: #364347 transparent transparent;
|
||||
}
|
||||
.toolbar-dark.tool-bottom .arrow {
|
||||
border-color: transparent transparent #364347;
|
||||
}
|
||||
.toolbar-dark.tool-left .arrow {
|
||||
border-color: transparent transparent transparent #364347;
|
||||
}
|
||||
.toolbar-dark.tool-right .arrow {
|
||||
border-color: transparent #364347 transparent transparent;
|
||||
}
|
||||
.toolbar-dark .tool-item > .fa {
|
||||
color: white;
|
||||
}
|
||||
.toolbar-dark .tool-item.selected,
|
||||
.toolbar-dark .tool-item:hover {
|
||||
background: #5e696d;
|
||||
color: white;
|
||||
}
|
||||
.animate-standard {
|
||||
-webkit-animation: standardAnimate 0.3s 1 ease;
|
||||
}
|
||||
.animate-flyin {
|
||||
-webkit-animation: rotateAnimate 0.5s 1 ease;
|
||||
}
|
||||
.animate-grow {
|
||||
-webkit-animation: growAnimate 0.4s 1 ease;
|
||||
}
|
||||
.animate-flip {
|
||||
-webkit-animation: flipAnimate 0.4s 1 ease;
|
||||
}
|
||||
.animate-bounce {
|
||||
-webkit-animation: bounceAnimate 0.4s 1 ease-out;
|
||||
}
|
||||
@-webkit-keyframes rotateAnimate {
|
||||
from {
|
||||
transform: rotate(180deg) translate(-120px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: rotate(0deg) translate(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes standardAnimate {
|
||||
from {
|
||||
transform: translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes growAnimate {
|
||||
0% {
|
||||
transform: scale(0) translateY(40px);
|
||||
opacity: 0;
|
||||
}
|
||||
70% {
|
||||
transform: scale(1.5) translate(0px);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1) translate(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes rotate2Animate {
|
||||
from {
|
||||
transform: rotate(-90deg);
|
||||
transform-origin: 0% 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: rotate(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes flipAnimate {
|
||||
from {
|
||||
transform: rotate3d(2, 2, 2, 180deg);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: rotate3d(0, 0, 0, 0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes bounceAnimate {
|
||||
0% {
|
||||
transform: translateY(40px);
|
||||
opacity: 0;
|
||||
}
|
||||
30% {
|
||||
transform: translateY(-40px);
|
||||
}
|
||||
70% {
|
||||
transform: translateY(20px);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
307
build/js/include/plugins/toolbar/jquery.toolbar.js
Normal file
307
build/js/include/plugins/toolbar/jquery.toolbar.js
Normal file
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* Toolbar.js
|
||||
*
|
||||
* @fileoverview jQuery plugin that creates tooltip style toolbars.
|
||||
* @link http://paulkinzett.github.com/toolbar/
|
||||
* @author Paul Kinzett (http://kinzett.co.nz/)
|
||||
* @version 1.1.0
|
||||
* @requires jQuery 1.7+
|
||||
*
|
||||
* @license jQuery Toolbar Plugin v1.1.0
|
||||
* http://paulkinzett.github.com/toolbar/
|
||||
* Copyright 2013 - 2015 Paul Kinzett (http://kinzett.co.nz/)
|
||||
* Released under the MIT license.
|
||||
* <https://raw.github.com/paulkinzett/toolbar/master/LICENSE.txt>
|
||||
*/
|
||||
|
||||
if ( typeof Object.create !== 'function' ) {
|
||||
Object.create = function( obj ) {
|
||||
function F() {}
|
||||
F.prototype = obj;
|
||||
return new F();
|
||||
};
|
||||
}
|
||||
|
||||
(function( $, window, document, undefined ) {
|
||||
|
||||
var ToolBar = {
|
||||
init: function( options, elem ) {
|
||||
var self = this;
|
||||
self.elem = elem;
|
||||
self.$elem = $( elem );
|
||||
self.options = $.extend( {}, $.fn.toolbar.options, options );
|
||||
self.metadata = self.$elem.data();
|
||||
self.overrideOptions();
|
||||
self.toolbar = $('<div class="tool-container" />')
|
||||
.addClass('tool-'+self.options.position)
|
||||
.addClass('toolbar-'+self.options.style)
|
||||
.append('<div class="tool-items" />')
|
||||
.append('<div class="arrow" />')
|
||||
.appendTo('body')
|
||||
.css('opacity', 0)
|
||||
.hide();
|
||||
self.toolbar_arrow = self.toolbar.find('.arrow');
|
||||
self.initializeToolbar();
|
||||
},
|
||||
|
||||
overrideOptions: function() {
|
||||
var self = this;
|
||||
$.each( self.options, function( $option ) {
|
||||
if (typeof(self.$elem.data('toolbar-'+$option)) != "undefined") {
|
||||
self.options[$option] = self.$elem.data('toolbar-'+$option);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
initializeToolbar: function() {
|
||||
var self = this;
|
||||
self.populateContent();
|
||||
self.setTrigger();
|
||||
self.toolbarWidth = self.toolbar.width();
|
||||
},
|
||||
|
||||
setTrigger: function() {
|
||||
var self = this;
|
||||
|
||||
if (self.options.event != 'click') {
|
||||
|
||||
var moveTime;
|
||||
function decideTimeout () {
|
||||
if (self.$elem.hasClass('pressed')) {
|
||||
moveTime = setTimeout(function() {
|
||||
self.hide();
|
||||
}, 150);
|
||||
} else {
|
||||
clearTimeout(moveTime);
|
||||
};
|
||||
};
|
||||
|
||||
self.$elem.on({
|
||||
mouseenter: function(event) {
|
||||
if (self.$elem.hasClass('pressed')) {
|
||||
clearTimeout(moveTime);
|
||||
} else {
|
||||
self.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.$elem.parent().on({
|
||||
mouseleave: function(event){ decideTimeout(); }
|
||||
});
|
||||
|
||||
$('.tool-container').on({
|
||||
mouseenter: function(event){ clearTimeout(moveTime); },
|
||||
mouseleave: function(event){ decideTimeout(); }
|
||||
});
|
||||
}
|
||||
|
||||
if (self.options.event == 'click') {
|
||||
self.$elem.on('click', function(event) {
|
||||
event.preventDefault();
|
||||
if(self.$elem.hasClass('pressed')) {
|
||||
self.hide();
|
||||
} else {
|
||||
self.show();
|
||||
}
|
||||
});
|
||||
|
||||
if (self.options.hideOnClick) {
|
||||
$('html').on("click.toolbar", function ( event ) {
|
||||
if (event.target != self.elem &&
|
||||
self.$elem.has(event.target).length === 0 &&
|
||||
self.toolbar.has(event.target).length === 0 &&
|
||||
self.toolbar.is(":visible")) {
|
||||
self.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (self.options.hover) {
|
||||
var moveTime;
|
||||
|
||||
function decideTimeout () {
|
||||
if (self.$elem.hasClass('pressed')) {
|
||||
moveTime = setTimeout(function() {
|
||||
self.hide();
|
||||
}, 150);
|
||||
} else {
|
||||
clearTimeout(moveTime);
|
||||
};
|
||||
};
|
||||
|
||||
self.$elem.on({
|
||||
mouseenter: function(event) {
|
||||
if (self.$elem.hasClass('pressed')) {
|
||||
clearTimeout(moveTime);
|
||||
} else {
|
||||
self.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.$elem.parent().on({
|
||||
mouseleave: function(event){ decideTimeout(); }
|
||||
});
|
||||
|
||||
$('.tool-container').on({
|
||||
mouseenter: function(event){ clearTimeout(moveTime); },
|
||||
mouseleave: function(event){ decideTimeout(); }
|
||||
});
|
||||
}
|
||||
|
||||
$(window).resize(function( event ) {
|
||||
event.stopPropagation();
|
||||
if ( self.toolbar.is(":visible") ) {
|
||||
self.toolbarCss = self.getCoordinates(self.options.position, 20);
|
||||
self.collisionDetection();
|
||||
self.toolbar.css( self.toolbarCss );
|
||||
self.toolbar_arrow.css( self.arrowCss );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
populateContent: function() {
|
||||
var self = this;
|
||||
var location = self.toolbar.find('.tool-items');
|
||||
var content = $(self.options.content).clone( true ).find('a').addClass('tool-item');
|
||||
location.html(content);
|
||||
location.find('.tool-item').on('click', function(event) {
|
||||
event.preventDefault();
|
||||
self.$elem.trigger('toolbarItemClick', this);
|
||||
});
|
||||
},
|
||||
|
||||
calculatePosition: function() {
|
||||
var self = this;
|
||||
self.arrowCss = {};
|
||||
self.toolbarCss = self.getCoordinates(self.options.position, self.options.adjustment);
|
||||
self.toolbarCss.position = 'absolute';
|
||||
self.toolbarCss.zIndex = self.options.zIndex;
|
||||
self.collisionDetection();
|
||||
self.toolbar.css(self.toolbarCss);
|
||||
self.toolbar_arrow.css(self.arrowCss);
|
||||
},
|
||||
|
||||
getCoordinates: function( position, adjustment ) {
|
||||
var self = this;
|
||||
self.coordinates = self.$elem.offset();
|
||||
|
||||
if (self.options.adjustment && self.options.adjustment[self.options.position]) {
|
||||
adjustment = self.options.adjustment[self.options.position] + adjustment;
|
||||
}
|
||||
|
||||
switch(self.options.position) {
|
||||
case 'top':
|
||||
return {
|
||||
left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
|
||||
top: self.coordinates.top-self.$elem.outerHeight()-adjustment,
|
||||
right: 'auto'
|
||||
};
|
||||
case 'left':
|
||||
return {
|
||||
left: self.coordinates.left-(self.toolbar.width()/2)-(self.$elem.outerWidth()/2)-adjustment,
|
||||
top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
|
||||
right: 'auto'
|
||||
};
|
||||
case 'right':
|
||||
return {
|
||||
left: self.coordinates.left+(self.toolbar.width()/2)+(self.$elem.outerWidth()/2)+adjustment,
|
||||
top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
|
||||
right: 'auto'
|
||||
};
|
||||
case 'bottom':
|
||||
return {
|
||||
left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
|
||||
top: self.coordinates.top+self.$elem.outerHeight()+adjustment,
|
||||
right: 'auto'
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
collisionDetection: function() {
|
||||
var self = this;
|
||||
var edgeOffset = 20;
|
||||
if(self.options.position == 'top' || self.options.position == 'bottom') {
|
||||
self.arrowCss = {left: '50%', right: '50%'};
|
||||
if( self.toolbarCss.left < edgeOffset ) {
|
||||
self.toolbarCss.left = edgeOffset;
|
||||
self.arrowCss.left = self.$elem.offset().left + self.$elem.width()/2-(edgeOffset);
|
||||
}
|
||||
else if(($(window).width() - (self.toolbarCss.left + self.toolbarWidth)) < edgeOffset) {
|
||||
self.toolbarCss.right = edgeOffset;
|
||||
self.toolbarCss.left = 'auto';
|
||||
self.arrowCss.left = 'auto';
|
||||
self.arrowCss.right = ($(window).width()-self.$elem.offset().left)-(self.$elem.width()/2)-(edgeOffset)-5;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
var self = this;
|
||||
self.$elem.addClass('pressed');
|
||||
self.calculatePosition();
|
||||
self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
|
||||
self.$elem.trigger('toolbarShown');
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
var self = this;
|
||||
var animation = {'opacity': 0};
|
||||
|
||||
self.$elem.removeClass('pressed');
|
||||
|
||||
switch(self.options.position) {
|
||||
case 'top':
|
||||
animation.top = '+=20';
|
||||
break;
|
||||
case 'left':
|
||||
animation.left = '+=20';
|
||||
break;
|
||||
case 'right':
|
||||
animation.left = '-=20';
|
||||
break;
|
||||
case 'bottom':
|
||||
animation.top = '-=20';
|
||||
break;
|
||||
}
|
||||
|
||||
self.toolbar.animate(animation, 200, function() {
|
||||
self.toolbar.hide();
|
||||
});
|
||||
|
||||
self.$elem.trigger('toolbarHidden');
|
||||
},
|
||||
|
||||
getToolbarElement: function () {
|
||||
return this.toolbar.find('.tool-items');
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.toolbar = function( options ) {
|
||||
if ($.isPlainObject( options )) {
|
||||
return this.each(function() {
|
||||
var toolbarObj = Object.create( ToolBar );
|
||||
toolbarObj.init( options, this );
|
||||
$(this).data('toolbarObj', toolbarObj);
|
||||
});
|
||||
} else if ( typeof options === 'string' && options.indexOf('_') !== 0 ) {
|
||||
var toolbarObj = $(this).data('toolbarObj');
|
||||
var method = toolbarObj[options];
|
||||
return method.apply(toolbarObj, $.makeArray(arguments).slice(1));
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.toolbar.options = {
|
||||
content: '#myContent',
|
||||
position: 'top',
|
||||
hideOnClick: false,
|
||||
zIndex: 120,
|
||||
hover: false,
|
||||
style: 'default',
|
||||
animation: 'standard',
|
||||
adjustment: 10
|
||||
};
|
||||
|
||||
}) ( jQuery, window, document );
|
||||
Reference in New Issue
Block a user