Ui: Remove spaces, minor adjustments

This commit is contained in:
guerler
2015-03-14 03:30:31 -04:00
parent 0194f99fc3
commit 379098ede8
7 changed files with 393 additions and 417 deletions
@@ -53,11 +53,11 @@ return Backbone.View.extend({
}
}
}
this.current = new_val;
this.$icon.removeClass()
.addClass('icon')
.addClass(this.options.icons[new_val]);
this.options.onchange && this.options.onchange(new_val);
this.current = new_val;
}
return this.current;
},
+27 -27
View File
@@ -23,54 +23,54 @@ return Backbone.View.extend({
visible : true,
tag : ''
},
// optional sub menu
$menu: null,
// initialize
initialize: function (options) {
// get options
this.options = Utils.merge(options, this.optionsDefault);
// add template for tab
this.setElement($(this._template(this.options)));
// find root
var $root = $(this.el).find('.root');
// link head
var self = this;
$root.on('click', function(e) {
// hide all tooltips
$('.tooltip').hide();
// prevent default
e.preventDefault();
// add click event
if(self.options.onclick) {
self.options.onclick();
}
});
// visiblity
if (!this.options.visible)
this.hide();
// add tooltip
$root.tooltip({title: options.tooltip, placement: 'bottom'});
},
// show
show: function() {
$(this.el).show();
},
// hide
hide: function() {
$(this.el).hide();
},
// add menu item
addMenu: function (options) {
// menu option defaults
@@ -83,41 +83,41 @@ return Backbone.View.extend({
icon : null,
cls : 'button-menu btn-group'
}
// get options
menuOptions = Utils.merge(options, menuOptions);
// check if submenu element is available
if (!this.$menu) {
// insert submenu element into root
$(this.el).append(this._templateMenu());
// update element link
this.$menu = $(this.el).find('.menu');
}
// create
var $item = $(this._templateMenuItem(menuOptions));
// add events
$item.on('click', function(e) {
// prevent default
e.preventDefault();
// add click event
if(menuOptions.onclick) {
menuOptions.onclick();
}
});
// append menu
this.$menu.append($item);
// append divider
if (menuOptions.divider)
this.$menu.append($(this._templateDivider()));
},
// fill template header
_templateMenuItem: function (options) {
var tmpl = '<li>' +
@@ -131,16 +131,16 @@ return Backbone.View.extend({
'</li>';
return tmpl;
},
// fill template header
_templateMenu: function () {
return '<ul class="menu dropdown-menu pull-right" role="menu"></ul>';
},
_templateDivider: function() {
return '<li class="divider"></li>';
},
// element
_template: function(options) {
// TODO: width/margin should be set in css
@@ -151,17 +151,17 @@ return Backbone.View.extend({
} else {
margin = 'margin: 0px;';
}
// create base string
var str = '<div id="' + options.id + '" style="float: ' + options.floating + '; ' + width + '" class="dropdown ' + options.cls + '">' +
'<div class="root button dropdown-toggle" data-toggle="dropdown" style="' + margin + '">' +
'<i class="icon fa ' + options.icon + '"/>';
// title
if (options.title) {
str += '&nbsp;<span class="title">' + options.title + '</span>';
}
// finalize
str += '</div>' +
'</div>';
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -53,11 +53,11 @@ return Backbone.View.extend({
}
}
}
this.current = new_val;
this.$icon.removeClass()
.addClass('icon')
.addClass(this.options.icons[new_val]);
this.options.onchange && this.options.onchange(new_val);
this.current = new_val;
}
return this.current;
},
+27 -27
View File
@@ -23,54 +23,54 @@ return Backbone.View.extend({
visible : true,
tag : ''
},
// optional sub menu
$menu: null,
// initialize
initialize: function (options) {
// get options
this.options = Utils.merge(options, this.optionsDefault);
// add template for tab
this.setElement($(this._template(this.options)));
// find root
var $root = $(this.el).find('.root');
// link head
var self = this;
$root.on('click', function(e) {
// hide all tooltips
$('.tooltip').hide();
// prevent default
e.preventDefault();
// add click event
if(self.options.onclick) {
self.options.onclick();
}
});
// visiblity
if (!this.options.visible)
this.hide();
// add tooltip
$root.tooltip({title: options.tooltip, placement: 'bottom'});
},
// show
show: function() {
$(this.el).show();
},
// hide
hide: function() {
$(this.el).hide();
},
// add menu item
addMenu: function (options) {
// menu option defaults
@@ -83,41 +83,41 @@ return Backbone.View.extend({
icon : null,
cls : 'button-menu btn-group'
}
// get options
menuOptions = Utils.merge(options, menuOptions);
// check if submenu element is available
if (!this.$menu) {
// insert submenu element into root
$(this.el).append(this._templateMenu());
// update element link
this.$menu = $(this.el).find('.menu');
}
// create
var $item = $(this._templateMenuItem(menuOptions));
// add events
$item.on('click', function(e) {
// prevent default
e.preventDefault();
// add click event
if(menuOptions.onclick) {
menuOptions.onclick();
}
});
// append menu
this.$menu.append($item);
// append divider
if (menuOptions.divider)
this.$menu.append($(this._templateDivider()));
},
// fill template header
_templateMenuItem: function (options) {
var tmpl = '<li>' +
@@ -131,16 +131,16 @@ return Backbone.View.extend({
'</li>';
return tmpl;
},
// fill template header
_templateMenu: function () {
return '<ul class="menu dropdown-menu pull-right" role="menu"></ul>';
},
_templateDivider: function() {
return '<li class="divider"></li>';
},
// element
_template: function(options) {
// TODO: width/margin should be set in css
@@ -151,17 +151,17 @@ return Backbone.View.extend({
} else {
margin = 'margin: 0px;';
}
// create base string
var str = '<div id="' + options.id + '" style="float: ' + options.floating + '; ' + width + '" class="dropdown ' + options.cls + '">' +
'<div class="root button dropdown-toggle" data-toggle="dropdown" style="' + margin + '">' +
'<i class="icon fa ' + options.icon + '"/>';
// title
if (options.title) {
str += '&nbsp;<span class="title">' + options.title + '</span>';
}
// finalize
str += '</div>' +
'</div>';
File diff suppressed because it is too large Load Diff
@@ -1 +1 @@
define(["utils/utils"],function(a){return Backbone.View.extend({optionsDefault:{icons:["fa fa-square-o","fa fa-minus-square-o","fa fa-check-square-o"],value:0,title:"Select/Unselect all"},initialize:function(c){this.options=a.merge(c,this.optionsDefault);this.setElement(this._template());this.$title=this.$(".title");this.$icon=this.$(".icon");this.value(this.options.value);this.$title.html(this.options.title);var b=this;this.$el.on("click",function(){b.current=(b.current===0&&2)||0;b.value(b.current);b.options.onclick&&b.options.onclick()})},value:function(b,c){if(b!==undefined){if(c){if(b!==0){if(b!==c){b=1}else{b=2}}}this.$icon.removeClass().addClass("icon").addClass(this.options.icons[b]);this.options.onchange&&this.options.onchange(b);this.current=b}return this.current},_template:function(){return'<div class="ui-button-check" ><span class="icon"/><span class="title"/></div>'}})});
define(["utils/utils"],function(a){return Backbone.View.extend({optionsDefault:{icons:["fa fa-square-o","fa fa-minus-square-o","fa fa-check-square-o"],value:0,title:"Select/Unselect all"},initialize:function(c){this.options=a.merge(c,this.optionsDefault);this.setElement(this._template());this.$title=this.$(".title");this.$icon=this.$(".icon");this.value(this.options.value);this.$title.html(this.options.title);var b=this;this.$el.on("click",function(){b.current=(b.current===0&&2)||0;b.value(b.current);b.options.onclick&&b.options.onclick()})},value:function(b,c){if(b!==undefined){if(c){if(b!==0){if(b!==c){b=1}else{b=2}}}this.current=b;this.$icon.removeClass().addClass("icon").addClass(this.options.icons[b]);this.options.onchange&&this.options.onchange(b)}return this.current},_template:function(){return'<div class="ui-button-check" ><span class="icon"/><span class="title"/></div>'}})});