Skip to content
Code-Schnipsel Gruppen Projekte
Commit 7d534e1e erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

style: codestyle

Übergeordneter 7be193b1
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
/**
* A panel where you can set bookmarks
*
......@@ -24,8 +23,7 @@ define('qui/controls/bookmarks/Panel', [
'css!qui/controls/bookmarks/Panel.css'
], function(QUI, QUIPanel, QUIButton, Utils)
{
], function (QUI, QUIPanel, QUIButton, Utils) {
"use strict";
/**
......@@ -35,46 +33,44 @@ define('qui/controls/bookmarks/Panel', [
*/
return new Class({
Extends : QUIPanel,
Type : 'qui/controls/bookmarks/Panel',
Extends: QUIPanel,
Type : 'qui/controls/bookmarks/Panel',
Binds : [
Binds: [
'$create',
'$clickRemoveButton',
'$onItemMouseEnter',
'$onItemMouseLeave'
],
initialize: function(options)
{
initialize: function (options) {
this.$bookmarks = [];
this.setAttributes({
title : 'Bookmarks',
icon : 'icon-book',
footer : false
title : 'Bookmarks',
icon : 'icon-book fa fa-bookmark',
footer: false
});
this.addEvent( 'onCreate', this.$create );
this.parent( options );
this.addEvent('onCreate', this.$create);
this.parent(options);
},
/**
* resize the bookmark panels
*/
resize : function()
{
resize: function () {
this.parent();
var size = this.$Content.getSize(),
width = size.x - 150;
if ( width <= 0 ) {
if (width <= 0) {
return;
}
this.$Content.getElements('.qui-bookmark-text').each(function(Text) {
Text.setStyle( 'width', width );
this.$Content.getElements('.qui-bookmark-text').each(function (Text) {
Text.setStyle('width', width);
});
},
......@@ -84,42 +80,38 @@ define('qui/controls/bookmarks/Panel', [
* @method qui/controls/bookmarks/Panel#serialize
* @return {Object} data
*/
serialize : function()
{
serialize: function () {
var i, len, icon, clsName, Icon, Bookmark;
var bookmarks = [];
for ( i = 0, len = this.$bookmarks.length; i < len; i++ )
{
Bookmark = this.$bookmarks[ i ];
Icon = Bookmark.getElement( '.qui-bookmark-icon' );
for (i = 0, len = this.$bookmarks.length; i < len; i++) {
Bookmark = this.$bookmarks[i];
Icon = Bookmark.getElement('.qui-bookmark-icon');
icon = '';
if ( Icon.getElement( 'img' ) )
{
icon = Icon.getElement( 'img' ).src;
} else
{
clsName = Icon.className.replace( 'qui-bookmark-icon', '' );
if (Icon.getElement('img')) {
icon = Icon.getElement('img').src;
} else {
clsName = Icon.className.replace('qui-bookmark-icon', '');
clsName = clsName.trim();
if ( clsName ) {
if (clsName) {
icon = clsName;
}
}
bookmarks.push({
text : Bookmark.getElement( '.qui-bookmark-text' ).get( 'text' ),
icon : icon,
click : Bookmark.get( 'data-click' ),
path : Bookmark.get( 'data-path' )
text : Bookmark.getElement('.qui-bookmark-text').get('text'),
icon : icon,
click: Bookmark.get('data-click'),
path : Bookmark.get('data-path')
});
}
return {
attributes : this.getAttributes(),
type : this.getType(),
bookmarks : bookmarks
attributes: this.getAttributes(),
type : this.getType(),
bookmarks : bookmarks
};
},
......@@ -130,12 +122,10 @@ define('qui/controls/bookmarks/Panel', [
* @param {Object} data
* @return {Object} this (qui/controls/bookmarks/Panel)
*/
unserialize : function(data)
{
this.setAttributes( data.attributes );
unserialize: function (data) {
this.setAttributes(data.attributes);
if ( !this.$Container )
{
if (!this.$Container) {
this.$serialize = data;
return this;
}
......@@ -143,21 +133,20 @@ define('qui/controls/bookmarks/Panel', [
var i, len, Bookmark;
var bookmarks = data.bookmarks;
if ( !bookmarks ) {
if (!bookmarks) {
return this;
}
for ( i = 0, len = bookmarks.length; i < len; i++ )
{
Bookmark = bookmarks[ i ];
for (i = 0, len = bookmarks.length; i < len; i++) {
Bookmark = bookmarks[i];
this.$bookmarks.push(
this.$createEntry({
text : Bookmark.text,
icon : Bookmark.icon,
click : Bookmark.click,
path : Bookmark.path
}).inject( this.$Container )
text : Bookmark.text,
icon : Bookmark.icon,
click: Bookmark.click,
path : Bookmark.path
}).inject(this.$Container)
);
}
......@@ -171,22 +160,21 @@ define('qui/controls/bookmarks/Panel', [
*
* @method qui/controls/bookmarks/Panel#$create
*/
$create : function()
{
this.$Container = new Element( 'div' ).inject(
$create: function () {
this.$Container = new Element('div').inject(
this.getBody()
);
if ( typeof this.$serialize !== 'undefined' ) {
this.unserialize( this.$serialize );
if (typeof this.$serialize !== 'undefined') {
this.unserialize(this.$serialize);
}
// qui-contextitem items can be droped
this.getElm()
.addClass( 'qui-contextitem-dropable' )
.addClass( 'qui-sitemap-entry-dropable' );
.addClass('qui-contextitem-dropable')
.addClass('qui-sitemap-entry-dropable');
this.fireEvent( 'load', [ this ] );
this.fireEvent('load', [this]);
},
/**
......@@ -196,39 +184,35 @@ define('qui/controls/bookmarks/Panel', [
* @param {Object} Item - qui/controls/Control, A QUI control
* @return {Object} this (qui/controls/bookmarks/Panel)
*/
appendChild : function(Item)
{
if ( !this.$Container ) {
appendChild: function (Item) {
if (!this.$Container) {
return this;
}
var Child;
// parse qui/controls/contextmenu/Item to an Bookmark
if ( Item.getType() == 'qui/controls/contextmenu/Item' )
{
if (Item.getType() == 'qui/controls/contextmenu/Item') {
var path = Item.getPath();
Child = this.$createEntry({
text : Item.getAttribute( 'text' ),
icon : Item.getAttribute( 'icon' ),
path : path
}).inject( this.$Container );
} else
{
text: Item.getAttribute('text'),
icon: Item.getAttribute('icon'),
path: path
}).inject(this.$Container);
} else {
Child = this.$createEntry({
text : Item.getAttribute( 'text' ),
icon : Item.getAttribute( 'icon' ),
click : Item.getAttribute( 'bookmark' ),
path : ''
}).inject( this.$Container );
text : Item.getAttribute('text'),
icon : Item.getAttribute('icon'),
click: Item.getAttribute('bookmark'),
path : ''
}).inject(this.$Container);
}
this.$bookmarks.push( Child );
this.$bookmarks.push(Child);
this.resize();
this.fireEvent( 'appendChild', [ this, Child ] );
this.fireEvent('appendChild', [this, Child]);
return this;
},
......@@ -238,8 +222,7 @@ define('qui/controls/bookmarks/Panel', [
*
* @method qui/controls/desktop/panels/Bookmarks#remove
*/
remove : function()
{
remove: function () {
},
......@@ -250,8 +233,7 @@ define('qui/controls/bookmarks/Panel', [
* @param {Object} params - {text, icon, click}
* @return {HTMLElement}
*/
$createEntry : function(params)
{
$createEntry: function (params) {
var BookmarkPanel = this;
params.text = params.text || '';
......@@ -260,73 +242,66 @@ define('qui/controls/bookmarks/Panel', [
params.path = params.path || '';
var Bookmark = new Element('div', {
'class' : 'qui-bookmark box smooth',
'html' : '<span class="qui-bookmark-icon"></span>' +
'<span class="qui-bookmark-text">'+ params.text +'</span>',
'data-click' : params.click,
'data-path' : params.path,
title : params.text,
events :
{
click : function()
{
var click = this.get( 'data-click' ),
path = this.get( 'data-path' );
if ( path )
{
if ( BookmarkPanel.$clickMenuItem( path ) ) {
'class' : 'qui-bookmark box smooth',
'html' : '<span class="qui-bookmark-icon"></span>' +
'<span class="qui-bookmark-text">' + params.text + '</span>',
'data-click': params.click,
'data-path' : params.path,
title : params.text,
events : {
click: function () {
var click = this.get('data-click'),
path = this.get('data-path');
if (path) {
if (BookmarkPanel.$clickMenuItem(path)) {
return;
}
}
if ( typeof click === 'undefined' ) {
if (typeof click === 'undefined') {
return;
}
var e = eval( '('+ click +')' );
var e = eval('(' + click + ')');
if ( typeof e === 'function' ) {
if (typeof e === 'function') {
e();
}
},
mouseleave : this.$onItemMouseLeave,
mouseenter : this.$onItemMouseEnter
mouseleave: this.$onItemMouseLeave,
mouseenter: this.$onItemMouseEnter
}
});
var Remove = new QUIButton({
icon : 'icon-remove',
icon : 'icon-remove fa fa-close',
'class' : 'qui-bookmark-button btn-red',
styles : {
'float' : 'right',
display : 'none'
styles : {
'float': 'right',
display: 'none'
},
events : {
onClick : this.$clickRemoveButton
events : {
onClick: this.$clickRemoveButton
},
Bookmark : Bookmark
}).inject( Bookmark );
Bookmark: Bookmark
}).inject(Bookmark);
Remove.getElm().removeClass( 'qui-button' );
Remove.getElm().removeClass('qui-button');
if ( params.icon )
{
var Icon = Bookmark.getElement( '.qui-bookmark-icon' );
if (params.icon) {
var Icon = Bookmark.getElement('.qui-bookmark-icon');
if ( Utils.isFontAwesomeClass( params.icon ) )
{
Icon.addClass( params.icon );
} else
{
if (Utils.isFontAwesomeClass(params.icon)) {
Icon.addClass(params.icon);
} else {
new Element('img.qui-button-image', {
src : params.icon,
styles : {
'display' : 'block' // only image, fix
src : params.icon,
styles: {
'display': 'block' // only image, fix
}
}).inject( Icon );
}).inject(Icon);
}
}
......@@ -340,24 +315,22 @@ define('qui/controls/bookmarks/Panel', [
* @param {String} path - Path to the menu item
* @return {Boolean}
*/
$clickMenuItem : function(path)
{
$clickMenuItem: function (path) {
path = path.replace(/^\/|\/$/g, '');
var parts = path.split( '/' ),
Parent = QUI.Controls.get( parts[ 0 ] );
var parts = path.split('/'),
Parent = QUI.Controls.get(parts[0]);
if ( !Parent || !Parent.length ) {
if (!Parent || !Parent.length) {
return false;
}
Parent = Parent[ 0 ];
Parent = Parent[0];
for ( var i = 1, len = parts.length; i < len; i++ )
{
Parent = Parent.getChildren( parts[ i ] );
for (var i = 1, len = parts.length; i < len; i++) {
Parent = Parent.getChildren(parts[i]);
if ( Parent === false ) {
if (Parent === false) {
return false;
}
}
......@@ -373,28 +346,25 @@ define('qui/controls/bookmarks/Panel', [
* @method qui/controls/bookmarks/Panel#$clickRemoveButton
* @param {Object} Btn - qui/controls/buttons/Button
*/
$clickRemoveButton : function(Btn)
{
$clickRemoveButton: function (Btn) {
var i, id, len, list, Bookmark;
list = [];
Bookmark = Btn.getAttribute( 'Bookmark' );
id = Slick.uidOf( Bookmark );
for ( i = 0, len = this.$bookmarks.length; i < len; i++ )
{
if ( Slick.uidOf( this.$bookmarks[ i ] ) != id )
{
list.push( this.$bookmarks[ i ] );
Bookmark = Btn.getAttribute('Bookmark');
id = Slick.uidOf(Bookmark);
for (i = 0, len = this.$bookmarks.length; i < len; i++) {
if (Slick.uidOf(this.$bookmarks[i]) != id) {
list.push(this.$bookmarks[i]);
continue;
}
this.$bookmarks[ i ].destroy();
this.$bookmarks[i].destroy();
}
this.$bookmarks = list;
this.fireEvent( 'removeChild', [ this ] );
this.fireEvent('removeChild', [this]);
},
/**
......@@ -403,13 +373,12 @@ define('qui/controls/bookmarks/Panel', [
* @method qui/controls/bookmarks/Panel#$onItemMouseEnter
* @param {DOMEvent} event
*/
$onItemMouseEnter : function(event)
{
if ( this.getAttribute( 'dragable' ) === false ) {
$onItemMouseEnter: function (event) {
if (this.getAttribute('dragable') === false) {
return;
}
event.target.getElements( 'button' ).setStyle( 'display', null );
event.target.getElements('button').setStyle('display', null);
},
/**
......@@ -418,9 +387,8 @@ define('qui/controls/bookmarks/Panel', [
* @method qui/controls/bookmarks/Panel#$onItemMouseLeave
* @param {DOMEvent} event
*/
$onItemMouseLeave : function(event)
{
event.target.getElements( 'button' ).setStyle( 'display', 'none' );
$onItemMouseLeave: function (event) {
event.target.getElements('button').setStyle('display', 'none');
}
});
});
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren