Skip to content

Commit

Permalink
Refs #2135 Few JS fixes for a cleaner UI/UX
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Apr 24, 2013
1 parent 9769cdd commit 0f3d976
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 99 deletions.
3 changes: 3 additions & 0 deletions plugins/SegmentEditor/SegmentEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ public function getJsFiles($notification)
$jsFiles = & $notification->getNotificationObject();
$jsFiles[] = "plugins/SegmentEditor/templates/jquery.jscrollpane.js";
$jsFiles[] = "plugins/SegmentEditor/templates/Segmentation.js";
$jsFiles[] = "plugins/SegmentEditor/templates/jquery.mousewheel.js";
$jsFiles[] = "plugins/SegmentEditor/templates/mwheelIntent.js";
}

public function getCssFiles($notification)
{
$cssFiles = & $notification->getNotificationObject();
$cssFiles[] = "plugins/SegmentEditor/templates/Segmentation.css";
$cssFiles[] = "plugins/SegmentEditor/templates/jquery.jscrollpane.css";
$cssFiles[] = "plugins/SegmentEditor/templates/scroll.css";
}

This comment has been minimized.

Copy link
@sgiehl

sgiehl Apr 24, 2013

Member

did you forget to add that css file (and the mwheelIntent.js) to git?


}
8 changes: 4 additions & 4 deletions plugins/SegmentEditor/templates/Segmentation.css
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ div.scrollable {
font-weight: normal;
}
.segmentationContainer.visible {
width: 250px;
width: 180px;
}
.segmentationContainer.visible ul.submenu {
display: block;
Expand All @@ -455,7 +455,7 @@ div.scrollable {
span.segmentationTitle {
background: url(../../../themes/default/images/sort_subtable_desc.png) right center no-repeat !important;
padding-right: 20px !important;
width: 230px !important;
width: 160px !important;
display: block !important;
cursor: pointer;
}
Expand Down Expand Up @@ -553,7 +553,7 @@ a.metric_category {
.segmentationSelectorContainer {
margin: 8px;
}
.grayed, .grayed:hover{
color:#BBB6AD !important;
.segmentSelected, .segmentSelected:hover{
font-weight:bold;
}
.ui-autocomplete { position: absolute; cursor: default;z-index:1000 !important;}
32 changes: 21 additions & 11 deletions plugins/SegmentEditor/templates/Segmentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,17 @@ Segmentation = (function($) {
var getListHtml = function() {
var html = $("#SegmentEditor > .listHtml").clone();
var segment, injClass;
var listHtml = '<li data-idsegment="" data-definition=""><span class="segname">All Visits (default)</span></li> ';
if(self.segmentList.length > 0){

var listHtml = '<li data-idsegment="" ' +
(self.currentSegmentsGlobal == "" ? " class='segmentSelected' " : "")
+ ' data-definition=""><span class="segname">All Visits (default)</span></li> ';
if(self.segmentList.length > 0) {
for(var key in self.segmentList)
{
segment = self.segmentList[key];
if(jQuery.inArray(segment.definition, self.currentSegmentsGlobal) > -1){
injClass = 'class="grayed"';
}
else{
injClass = "";
injClass = "";
if( segment.definition == self.currentSegmentsGlobal){
injClass = 'class="segmentSelected"';
}
listHtml += '<li data-idsegment="'+segment.idsegment+'" data-definition=\''+segment.definition+'\' '
+ injClass +' title="'+segment.name+'"><span class="segname">'
Expand Down Expand Up @@ -245,7 +246,7 @@ Segmentation = (function($) {
self.content.find(".add_new_segment").unbind().on("click", function(event){
event.stopPropagation();
closeAllOpenLists();
addForm();
addForm("new");
doDragDropBindings();
});

Expand Down Expand Up @@ -480,6 +481,7 @@ Segmentation = (function($) {
});

$('#closeSegmentationForm').on("click", function() {
$("#segmentList").show();
self.form.remove();
});

Expand Down Expand Up @@ -577,11 +579,13 @@ Segmentation = (function($) {
});

$(self.form).on("click", "a.close", function(e){
$("#segmentList").show();
self.form.unbind().remove();
});

$("body").on("keyup", function(e){
if(e.keyCode == "27"){
$("#segmentList").show();
$(self.form).remove();
}
});
Expand Down Expand Up @@ -745,7 +749,7 @@ Segmentation = (function($) {
});
}

var addForm = function(){
var addForm = function(mode){

$("#segmentEditorPanel").find(".segment-element:visible").unbind().remove();
if(typeof self.form !== "undefined")
Expand All @@ -767,7 +771,13 @@ Segmentation = (function($) {
e.preventDefault();
parseFormAndSave();
});


if(typeof mode !== "undefined" && mode == "new")
{
$(self.form).find(".editSegmentName").trigger('click');
$(self.form).find("#edit_segment_name").val("");
}
$("#segmentList").hide();

}

Expand Down Expand Up @@ -865,7 +875,7 @@ Segmentation = (function($) {
if(!$(e.target).parents(spanId).length && !$(e.target).is(spanId) && !$(e.target).parents(spanId).length
&& !$(e.target).parents(".ui-autocomplete").length && !$(e.target).is(".ui-autocomplete") && !$(e.target).parents(".ui-autocomplete").length
) {
dropList.autocomplete("close");
dropList.autocomplete().autocomplete("close");
}
});
}
Expand Down
1 change: 0 additions & 1 deletion plugins/SegmentEditor/templates/jquery.jscrollpane.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
.jspArrow.jspDisabled
{
cursor: default;
background: #80808d;
}

.jspVerticalBar .jspArrow
Expand Down
166 changes: 83 additions & 83 deletions plugins/SegmentEditor/templates/jquery.mousewheel.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/

(function ($) {

var types = ['DOMMouseScroll', 'mousewheel'];

if ($.event.fixHooks) {
for (var i = types.length; i;) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}

$.event.special.mousewheel = {
setup: function () {
if (this.addEventListener) {
for (var i = types.length; i;) {
this.addEventListener(types[--i], handler, false);
}
} else {
this.onmousewheel = handler;
}
},

teardown: function () {
if (this.removeEventListener) {
for (var i = types.length; i;) {
this.removeEventListener(types[--i], handler, false);
}
} else {
this.onmousewheel = null;
}
}
};

$.fn.extend({
mousewheel: function (fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},

unmousewheel: function (fn) {
return this.unbind("mousewheel", fn);
}
});


function handler(event) {
var orgEvent = event || window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";

// Old school scrollwheel delta
if (orgEvent.wheelDelta) { delta = orgEvent.wheelDelta / 120; }
if (orgEvent.detail) { delta = -orgEvent.detail / 3; }

// New school multidimensional scroll (touchpads) deltas
deltaY = delta;

// Gecko
if (orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
deltaY = 0;
deltaX = -1 * delta;
}

// Webkit
if (orgEvent.wheelDeltaY !== undefined) { deltaY = orgEvent.wheelDeltaY / 120; }
if (orgEvent.wheelDeltaX !== undefined) { deltaX = -1 * orgEvent.wheelDeltaX / 120; }

// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);

return ($.event.dispatch || $.event.handle).apply(this, args);
}

/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6

This comment has been minimized.

Copy link
@sgiehl

sgiehl Apr 24, 2013

Member

Is there a reason for using 3.0.6 and not the latest 3.1.3 (see https://github.com/brandonaaron/jquery-mousewheel/tree/3.1.3)

*
* Requires: 1.2.2+
*/

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}

$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},

teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};

$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},

unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});


function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";

// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }

// New school multidimensional scroll (touchpads) deltas
deltaY = delta;

// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}

// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }

// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);

return ($.event.dispatch || $.event.handle).apply(this, args);
}

})(jQuery);

0 comments on commit 0f3d976

Please sign in to comment.