Commit d6b420e1 authored by Joshua Gould's avatar Joshua Gould

scroll lens

parent b2792ab4
This source diff could not be displayed because it is too large. You can view the blob instead.
morpheus.FormBuilder = function(options) {
morpheus.FormBuilder = function (options) {
var that = this;
this.prefix = _.uniqueId('form');
this.$form = $('<form></form>');
......@@ -12,12 +12,12 @@ morpheus.FormBuilder = function(options) {
this.labelClass = 'control-label';
this.titleClass = 'control-label';
}
this.$form.on('submit', function(e) {
this.$form.on('submit', function (e) {
e.preventDefault();
});
this.$form.on(
'dragover',
function(e) {
function (e) {
var node = $(e.originalEvent.srcElement).parent().parent()
.prev();
if (node.is('select') && node.hasClass('file-input')) {
......@@ -28,7 +28,7 @@ morpheus.FormBuilder = function(options) {
}
}).on(
'dragenter',
function(e) {
function (e) {
var node = $(e.originalEvent.srcElement).parent().parent()
.prev();
if (node.is('select') && node.hasClass('file-input')) {
......@@ -37,14 +37,14 @@ morpheus.FormBuilder = function(options) {
e.preventDefault();
e.stopPropagation();
}
}).on('dragleave', function(e) {
}).on('dragleave', function (e) {
var node = $(e.originalEvent.srcElement).parent().parent().prev();
if (node.is('select') && node.hasClass('file-input')) {
$(e.originalEvent.srcElement).parent().css('border', '');
e.preventDefault();
e.stopPropagation();
}
}).on('drop', function(e) {
}).on('drop', function (e) {
var node = $(e.originalEvent.srcElement).parent().parent().prev();
if (node.is('select') && node.hasClass('file-input')) {
var isMultiple = node.data('multiple');
......@@ -58,17 +58,17 @@ morpheus.FormBuilder = function(options) {
var files = e.originalEvent.dataTransfer.files;
that.setValue(name, isMultiple ? files : files[0]);
that.trigger('change', {
name : name,
value : files[0]
name: name,
value: files[0]
});
} else {
var url = e.originalEvent.dataTransfer.getData('URL');
e.preventDefault();
e.stopPropagation();
that.setValue(name, url);
that.setValue(name, isMultiple ? [url] : url);
that.trigger('change', {
name : name,
value : url
name: name,
value: url
});
}
}
......@@ -78,7 +78,7 @@ morpheus.FormBuilder = function(options) {
// this.fieldColumnDef = '8';
};
morpheus.FormBuilder.showProgressBar = function(options) {
morpheus.FormBuilder.showProgressBar = function (options) {
var content = [];
content.push('<div class="container-fluid">');
content.push('<div class="row">');
......@@ -100,16 +100,16 @@ morpheus.FormBuilder.showProgressBar = function(options) {
}
content.push('</div>');
var $content = $(content.join(''));
$content.find('[name=stop]').on('click', function(e) {
$content.find('[name=stop]').on('click', function (e) {
options.stop();
e.preventDefault();
});
return morpheus.FormBuilder.showInDraggableDiv({
title : options.title,
$content : $content
title: options.title,
$content: $content
});
};
morpheus.FormBuilder.showInDraggableDiv = function(options) {
morpheus.FormBuilder.showInDraggableDiv = function (options) {
var width = options.width || '300px';
var html = [];
html
......@@ -125,7 +125,7 @@ morpheus.FormBuilder.showInDraggableDiv = function(options) {
var $div = $(html.join(''));
var $content = $div.find('[name=content]');
$div.find('[name=header]').on('dblclick', function() {
$div.find('[name=header]').on('dblclick', function () {
if ($content.css('display') === 'none') {
$content.css('display', '');
} else {
......@@ -136,25 +136,25 @@ morpheus.FormBuilder.showInDraggableDiv = function(options) {
options.$content.appendTo($content);
$div.css('left', ($(window).width() / 2) - $content.outerWidth() / 2);
$div.draggable({
handle : '[name=header]',
containment : 'document'
handle: '[name=header]',
containment: 'document'
});
// $div.resizable();
$div.appendTo($(document.body));
return $div;
};
morpheus.FormBuilder.promptForDataset = function(cb) {
morpheus.FormBuilder.promptForDataset = function (cb) {
var formBuilder = new morpheus.FormBuilder();
formBuilder.append({
name : 'file',
value : '',
type : 'file',
required : true,
help : morpheus.DatasetUtil.DATASET_FILE_FORMATS
name: 'file',
value: '',
type: 'file',
required: true,
help: morpheus.DatasetUtil.DATASET_FILE_FORMATS
});
var $modal;
formBuilder.on('change', function(e) {
formBuilder.on('change', function (e) {
var value = e.value;
if (value !== '' && value != null) {
$modal.modal('hide');
......@@ -163,24 +163,24 @@ morpheus.FormBuilder.promptForDataset = function(cb) {
}
});
$modal = morpheus.FormBuilder.showInModal({
title : 'Dataset',
html : formBuilder.$form,
close : false
title: 'Dataset',
html: formBuilder.$form,
close: false
});
};
morpheus.FormBuilder.showInModal = function(options) {
morpheus.FormBuilder.showInModal = function (options) {
var $div = morpheus.FormBuilder
._showInModal({
z : options.z,
title : options.title,
html : options.html,
footer : options.close ? ('<button type="button" class="btn btn-default" data-dismiss="modal">'
z: options.z,
title: options.title,
html: options.html,
footer: options.close ? ('<button type="button" class="btn btn-default" data-dismiss="modal">'
+ options.close + '</button>')
: null,
onClose : options.callback,
backdrop : options.backdrop,
size : options.size
onClose: options.callback,
backdrop: options.backdrop,
size: options.size
});
return $div;
// if (options.draggable) {
......@@ -190,9 +190,9 @@ morpheus.FormBuilder.showInModal = function(options) {
// }
};
morpheus.FormBuilder.showOkCancel = function(options) {
morpheus.FormBuilder.showOkCancel = function (options) {
options = $.extend({}, {
ok : true
ok: true
}, options);
var footer = [];
if (options.ok) {
......@@ -206,18 +206,18 @@ morpheus.FormBuilder.showOkCancel = function(options) {
footer
.push('<button name="cancel" type="button" data-dismiss="modal" class="btn btn-default">Cancel</button>');
var $div = morpheus.FormBuilder._showInModal({
title : options.title,
html : options.content,
footer : footer.join(''),
onClose : options.hiddenCallback,
size : options.size
title: options.title,
html: options.content,
footer: footer.join(''),
onClose: options.hiddenCallback,
size: options.size
});
// if (options.align === 'right') {
// $div.css('left', $(window).width()
// - $div.find('.modal-content').width() - 60);
// }
var $ok = $div.find('[name=ok]');
$ok.on('click', function(e) {
$ok.on('click', function (e) {
options.okCallback();
$div.modal('hide');
});
......@@ -227,8 +227,8 @@ morpheus.FormBuilder.showOkCancel = function(options) {
if (options.draggable) {
$div.draggable({
handle : '.modal-header',
containment : 'document'
handle: '.modal-header',
containment: 'document'
});
}
// $div.on('click', '[name=apply]', function(e) {
......@@ -237,7 +237,7 @@ morpheus.FormBuilder.showOkCancel = function(options) {
return $div;
};
morpheus.FormBuilder.hasChanged = function(object, keyToUIElement) {
morpheus.FormBuilder.hasChanged = function (object, keyToUIElement) {
var keys = _.keys(keyToUIElement);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
......@@ -249,7 +249,7 @@ morpheus.FormBuilder.hasChanged = function(object, keyToUIElement) {
}
return false;
};
morpheus.FormBuilder.getValue = function($element) {
morpheus.FormBuilder.getValue = function ($element) {
var list = $element.data('morpheus.checkbox-list');
if (list != null) {
return list.val();
......@@ -265,10 +265,10 @@ morpheus.FormBuilder.getValue = function($element) {
: $element.val();
};
morpheus.FormBuilder._showInModal = function(options) {
morpheus.FormBuilder._showInModal = function (options) {
var html = [];
options = $.extend({}, {
size : ''
size: ''
}, options);
html.push('<div class="modal" role="dialog" aria-hidden="false"');
if (options.z) {
......@@ -295,14 +295,14 @@ morpheus.FormBuilder._showInModal = function(options) {
html.push('</div>');
html.push('</div>');
var $div = $(html.join(''));
$div.on('mousewheel', function(e) {
$div.on('mousewheel', function (e) {
e.stopPropagation();
});
$div.find('.modal-body').html(options.html);
$div.prependTo($(document.body));
$div.modal({
backdrop : options.backdrop === true ? true : false,
}).on('hidden.bs.modal', function(e) {
backdrop: options.backdrop === true ? true : false,
}).on('hidden.bs.modal', function (e) {
$div.remove();
if (options.onClose) {
options.onClose();
......@@ -332,10 +332,10 @@ morpheus.FormBuilder._showInModal = function(options) {
// return id;
// };
morpheus.FormBuilder.prototype = {
appendContent : function($content) {
appendContent: function ($content) {
this.$form.append($content);
},
addSeparator : function() {
addSeparator: function () {
var html = [];
html.push('<div class="form-group">');
if (!this.vertical) {
......@@ -348,7 +348,7 @@ morpheus.FormBuilder.prototype = {
html.push('</div>');
this.$form.append(html.join(''));
},
_append : function(html, field, isFieldStart) {
_append: function (html, field, isFieldStart) {
var that = this;
var required = field.required;
var name = field.name;
......@@ -394,7 +394,7 @@ morpheus.FormBuilder.prototype = {
if ('radio' === type) {
if (field.options) {
_.each(field.options,
function(choice) {
function (choice) {
var isChoiceObject = _.isObject(choice)
&& choice.value !== undefined;
var optionValue = isChoiceObject ? choice.value
......@@ -462,7 +462,7 @@ morpheus.FormBuilder.prototype = {
html.push(' multiple');
}
html.push('>');
_.each(field.options, function(choice) {
_.each(field.options, function (choice) {
if (choice && choice.divider) {
html.push('<option data-divider="true"></option>');
} else {
......@@ -493,18 +493,18 @@ morpheus.FormBuilder.prototype = {
+ '_all" href="#">All</a>&nbsp;|&nbsp;<a name="' + name
+ '_none" href="#">None</a></p>');
that.$form.on('click', '[name=' + name + '_all]',
function(evt) {
function (evt) {
evt.preventDefault();
var $select = that.$form
.find('[name=' + name + ']');
$select.selectpicker('val', $.map($select
.find('option'), function(o) {
.find('option'), function (o) {
return $(o).val();
}));
$select.trigger('change');
});
that.$form.on('click', '[name=' + name + '_none]',
function(evt) {
function (evt) {
evt.preventDefault();
var $select = that.$form
.find('[name=' + name + ']');
......@@ -563,7 +563,7 @@ morpheus.FormBuilder.prototype = {
if (typeof Dropbox !== 'undefined') {
options.push('Dropbox');
}
_.each(options, function(choice, index) {
_.each(options, function (choice, index) {
var isChoiceObject = _.isObject(choice)
&& choice.value !== undefined;
var optionValue = isChoiceObject ? choice.value : choice;
......@@ -606,27 +606,26 @@ morpheus.FormBuilder.prototype = {
.on(
'change',
'[name=' + name + '_picker]',
function(evt) {
function (evt) {
var $this = $(this);
var val = $this.val();
var showTextInput = val === 'URL';
if ('Dropbox' === val) {
var options = {
success : function(results) {
success: function (results) {
var val = !isMultiple ? results[0].link
: results.map(function(
result) {
: results.map(function (result) {
return result.link;
});
that.setValue(name, val);
that.trigger('change', {
name : name,
value : val
name: name,
value: val
});
},
linkType : 'direct',
multiselect : isMultiple
linkType: 'direct',
multiselect: isMultiple
};
Dropbox.choose(options);
} else if ('My Computer' === val) {
......@@ -638,23 +637,29 @@ morpheus.FormBuilder.prototype = {
showTextInput ? '' : 'none');
});
// URL
that.$form.on('keyup', '[name=' + name + '_text]', function(evt) {
that.$form.on('keyup', '[name=' + name + '_text]', function (evt) {
var text = $.trim($(this).val());
if (isMultiple) {
text = text.split(',').filter(function (t) {
t = $.trim(t);
return t !== '';
});
}
that.setValue(name, text);
if (evt.which === 13) {
that.trigger('change', {
name : name,
value : text
name: name,
value: text
});
}
});
// browse file selected
that.$form.on('change', '[name=' + name + '_file]', function(evt) {
that.$form.on('change', '[name=' + name + '_file]', function (evt) {
var files = evt.target.files; // FileList object
that.setValue(name, isMultiple ? files : files[0]);
that.trigger('change', {
name : name,
value : files[0]
name: name,
value: files[0]
});
});
} else {
......@@ -689,15 +694,15 @@ morpheus.FormBuilder.prototype = {
html.push('</span>');
}
},
append : function(fields) {
append: function (fields) {
var html = [];
var that = this;
var isArray = morpheus.Util.isArray(fields);
if (!isArray) {
fields = [ fields ];
fields = [fields];
}
html.push('<div class="form-group">');
_.each(fields, function(field, index) {
_.each(fields, function (field, index) {
that._append(html, field, index === 0);
});
html.push('</div>');
......@@ -707,13 +712,13 @@ morpheus.FormBuilder.prototype = {
var checkBoxLists = $div.find('.checkbox-list');
if (checkBoxLists.length > 0) {
var checkBoxIndex = 0;
_.each(fields, function(field) {
_.each(fields, function (field) {
// needs to already be in dom
if (field.type === 'checkbox-list') {
var list = new morpheus.CheckBoxList({
responsive : false,
$el : $(checkBoxLists[checkBoxIndex]),
items : field.options
responsive: false,
$el: $(checkBoxLists[checkBoxIndex]),
items: field.options
});
$(checkBoxLists[checkBoxIndex]).data(
......@@ -723,22 +728,22 @@ morpheus.FormBuilder.prototype = {
});
}
$div.find('.selectpicker').selectpicker({
iconBase : 'fa',
tickIcon : 'fa-check',
style : 'btn-default btn-sm'
iconBase: 'fa',
tickIcon: 'fa-check',
style: 'btn-default btn-sm'
});
},
clear : function() {
clear: function () {
this.$form.empty();
},
getValue : function(name) {
getValue: function (name) {
var $v = this.$form.find('[name=' + name + ']');
if ($v.length === 0) {
$v = this.$form.find('[name=' + name + '_picker]');
}
return morpheus.FormBuilder.getValue($v);
},
setOptions : function(name, options, selectFirst) {
setOptions: function (name, options, selectFirst) {
var $select = this.$form.find('[name=' + name + ']');
var checkBoxList = $select.data('morpheus.checkbox-list');
if (checkBoxList) {
......@@ -746,7 +751,7 @@ morpheus.FormBuilder.prototype = {
} else {
var html = [];
var selection = $select.val();
_.each(options, function(choice) {
_.each(options, function (choice) {
html.push('<option value="');
var isChoiceObject = _.isObject(choice)
&& choice.value !== undefined;
......@@ -773,14 +778,14 @@ morpheus.FormBuilder.prototype = {
}
}
},
find : function(name) {
find: function (name) {
return this.$form.find('[name=' + name + ']');
},
setHelpText : function(name, value) {
setHelpText: function (name, value) {
var v = this.$form.find('[name=' + name + '_help]');
v.html(value);
},
setValue : function(name, value) {
setValue: function (name, value) {
var v = this.$form.find('[name=' + name + ']');
if (v.length === 0) {
v = this.$form.find('[name=' + name + '_picker]');
......@@ -808,7 +813,7 @@ morpheus.FormBuilder.prototype = {
}
},
setVisible : function(name, visible) {
setVisible: function (name, visible) {
var $div = this.$form.find('[name=' + name + ']')
.parents('.form-group');
if (visible) {
......@@ -817,12 +822,12 @@ morpheus.FormBuilder.prototype = {
$div.hide();
}
},
remove : function(name) {
remove: function (name) {
var $div = this.$form.find('[name=' + name + ']')
.parents('.form-group');
$div.remove();
},
setEnabled : function(name, enabled) {
setEnabled: function (name, enabled) {
var $div = this.$form.find('[name=' + name + ']');
$div.attr('disabled', !enabled);
if (!enabled) {
......
......@@ -2177,6 +2177,7 @@ morpheus.HeatMap.prototype = {
canvas.height = heatMapHeight * morpheus.CanvasUtil.BACKING_SCALE;
canvas.style.height = heatMapHeight + 'px';
var context = canvas.getContext('2d');
morpheus.CanvasUtil.resetTransform(context);
context.save();
context.translate(-this.heatmap.lastClip.x, -startPix);
context.rect(this.heatmap.lastClip.x, startPix, this.heatmap.lastClip.width, this.heatmap.lastClip.height);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment