mirror of
https://github.com/flarum/core.git
synced 2025-08-16 05:14:20 +02:00
Big component restructure/overhaul
This commit is contained in:
24
ember/app/components/ui/controls/action-button.js
Normal file
24
ember/app/components/ui/controls/action-button.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
title: '',
|
||||
icon: '',
|
||||
className: '',
|
||||
action: null,
|
||||
divider: false,
|
||||
active: false,
|
||||
|
||||
classNames: ['btn', 'btn-default'],
|
||||
|
||||
tagName: 'a',
|
||||
attributeBindings: ['href'],
|
||||
classNameBindings: ['className'],
|
||||
href: '#',
|
||||
layout: Ember.Handlebars.compile('{{#if icon}}{{fa-icon icon class="fa-fw"}} {{/if}}<span>{{title}}</span>'),
|
||||
|
||||
click: function(e) {
|
||||
e.preventDefault();
|
||||
// this.sendAction('action');
|
||||
this.get('action')();
|
||||
}
|
||||
});
|
21
ember/app/components/ui/controls/dropdown-button.js
Normal file
21
ember/app/components/ui/controls/dropdown-button.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
items: null, // TaggedArray
|
||||
layoutName: 'components/ui/controls/dropdown-button',
|
||||
classNames: ['dropdown', 'btn-group'],
|
||||
classNameBindings: ['itemCountClass'],
|
||||
|
||||
title: 'Controls',
|
||||
icon: 'ellipsis-v',
|
||||
buttonClass: 'btn-default',
|
||||
menuClass: 'pull-right',
|
||||
|
||||
dropdownMenuClass: function() {
|
||||
return 'dropdown-menu '+this.get('menuClass');
|
||||
}.property('menuClass'),
|
||||
|
||||
itemCountClass: function() {
|
||||
return 'item-count-'+this.get('items.length');
|
||||
}.property('items.length')
|
||||
});
|
33
ember/app/components/ui/controls/dropdown-select.js
Normal file
33
ember/app/components/ui/controls/dropdown-select.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
items: [],
|
||||
layoutName: 'components/ui/controls/dropdown-select',
|
||||
classNames: ['dropdown', 'dropdown-select', 'btn-group'],
|
||||
classNameBindings: ['itemCountClass'],
|
||||
|
||||
buttonClass: 'btn-default',
|
||||
menuClass: 'pull-right',
|
||||
icon: 'ellipsis-v',
|
||||
|
||||
mainButtonClass: function() {
|
||||
return 'btn '+this.get('buttonClass');
|
||||
}.property('buttonClass'),
|
||||
|
||||
dropdownMenuClass: function() {
|
||||
return 'dropdown-menu '+this.get('menuClass');
|
||||
}.property('menuClass'),
|
||||
|
||||
itemCountClass: function() {
|
||||
return 'item-count-'+this.get('items.length');
|
||||
}.property('items.length'),
|
||||
|
||||
activeItem: function() {
|
||||
return this.get('menu.childViews').findBy('active');
|
||||
}.property('menu.childViews.@each.active')
|
||||
|
||||
}).reopenClass({
|
||||
createWithItems: function(items) {
|
||||
return this.create({items: items});
|
||||
}
|
||||
});
|
16
ember/app/components/ui/controls/dropdown-split.js
Normal file
16
ember/app/components/ui/controls/dropdown-split.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
import DropdownButton from './dropdown-button';
|
||||
|
||||
export default DropdownButton.extend({
|
||||
layoutName: 'components/ui/controls/dropdown-split',
|
||||
classNames: ['dropdown', 'dropdown-split', 'btn-group'],
|
||||
|
||||
mainButtonClass: function() {
|
||||
return 'btn '+this.get('buttonClass');
|
||||
}.property('buttonClass'),
|
||||
|
||||
firstItem: function() {
|
||||
return this.get('items').objectAt(0);
|
||||
}.property('items.[]')
|
||||
});
|
20
ember/app/components/ui/controls/item-list.js
Normal file
20
ember/app/components/ui/controls/item-list.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
import ComponentItem from '../items/component-item';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'ul',
|
||||
layoutName: 'components/ui/controls/item-list',
|
||||
|
||||
listItems: function() {
|
||||
if (!this.get('items')) return [];
|
||||
var listItems = [];
|
||||
this.get('items').forEach(function(item) {
|
||||
if (item.tagName != 'li') {
|
||||
item = ComponentItem.extend({component: item});
|
||||
}
|
||||
listItems.push(item);
|
||||
});
|
||||
return listItems;
|
||||
}.property('items.[]')
|
||||
});
|
11
ember/app/components/ui/controls/loading-indicator.js
Normal file
11
ember/app/components/ui/controls/loading-indicator.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ['loading'],
|
||||
|
||||
layout: Ember.Handlebars.compile(' '),
|
||||
|
||||
didInsertElement: function() {
|
||||
this.$().spin(this.get('size'));
|
||||
}
|
||||
});
|
38
ember/app/components/ui/controls/search-input.js
Normal file
38
ember/app/components/ui/controls/search-input.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ['search-input'],
|
||||
classNameBindings: ['active', 'value:clearable'],
|
||||
|
||||
didInsertElement: function() {
|
||||
var self = this;
|
||||
this.$().find('input').on('keydown', function(e) {
|
||||
if (e.which == 27) {
|
||||
self.clear();
|
||||
}
|
||||
});
|
||||
this.$().find('.clear').on('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
}).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
self.clear();
|
||||
})
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.set('value', '');
|
||||
this.sendAction('action', '');
|
||||
this.$().find('input').focus();
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
this.$().find('input').off('keydown');
|
||||
this.$().find('.clear').off('mousedown click');
|
||||
},
|
||||
|
||||
actions: {
|
||||
search: function() {
|
||||
this.sendAction('action', this.get('value'));
|
||||
}
|
||||
}
|
||||
});
|
7
ember/app/components/ui/controls/select-input.js
Normal file
7
ember/app/components/ui/controls/select-input.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.View.extend({
|
||||
tagName: 'span',
|
||||
classNames: ['select'],
|
||||
layout: Ember.Handlebars.compile('{{view "select" content=view.content optionValuePath=view.optionValuePath optionLabelPath=view.optionLabelPath value=view.value}} {{fa-icon "sort"}}')
|
||||
});
|
6
ember/app/components/ui/items/component-item.js
Normal file
6
ember/app/components/ui/items/component-item.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'li',
|
||||
layoutName: 'components/ui/items/component-item'
|
||||
});
|
37
ember/app/components/ui/items/nav-item.js
Normal file
37
ember/app/components/ui/items/nav-item.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
icon: '',
|
||||
title: '',
|
||||
action: null,
|
||||
badge: '',
|
||||
|
||||
tagName: 'li',
|
||||
classNameBindings: ['active'],
|
||||
active: function() {
|
||||
return !! this.get('childViews').anyBy('active');
|
||||
}.property('childViews.@each.active'),
|
||||
|
||||
// init: function() {
|
||||
// var params = this.params;
|
||||
// if (params[params.length - 1].queryParams) {
|
||||
// this.queryParamsObject = {values: params.pop().queryParams};
|
||||
// }
|
||||
|
||||
// this._super();
|
||||
// },
|
||||
|
||||
layout: function() {
|
||||
return Ember.Handlebars.compile('{{#link-to '+this.get('linkTo')+'}}'+this.get('iconTemplate')+' {{title}} <span class="count">{{badge}}</span>{{/link-to}}');
|
||||
}.property('linkTo', 'iconTemplate'),
|
||||
|
||||
iconTemplate: function() {
|
||||
return '{{fa-icon icon}}';
|
||||
}.property(),
|
||||
|
||||
actions: {
|
||||
main: function() {
|
||||
this.get('action')();
|
||||
}
|
||||
}
|
||||
});
|
6
ember/app/components/ui/items/separator-item.js
Normal file
6
ember/app/components/ui/items/separator-item.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'li',
|
||||
classNames: ['divider']
|
||||
});
|
Reference in New Issue
Block a user