Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
// Create a new Class that inherits from this class
Class.extend = function(prop) {
var _super = this.prototype;
// Instantiate a base class (but only create the instance,
// don't run the init constructor)
initializing = true;
var prototype = new this();
initializing = false;
// Copy the properties over onto the new prototype
for (var name in prop) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function(name, fn){
return function() {
var tmp = this._super;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
})(name, prop[name]) :
prop[name];
}
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if ( !initializing && this.init )
this.init.apply(this, arguments);
}
// Populate our constructed prototype object
Class.prototype = prototype;
// Enforce the constructor to be what we expect
Class.prototype.constructor = Class;
// And make this class extendable
Class.extend = arguments.callee;
return Class;
};
})();
if (typeof butter === 'undefined') {
butter = {};
}
butter.ajax = {};
butter.ajax.disableElementsOnRequest = function(/* object */ data, /* array of string */ ids) {
var status = data.status;
// console.log(data);
// console.log(ids);
switch (status) {
case "begin": // Before the ajax request is sent.
// console.log('ajax request begin');
for(i=0;i 0) {
this._trySendJsfAjaxRequest();
} else if ($autocomplete.is(":visible") && $autocomplete.find("li").length > 0) {
if (this.$selectedOption === null) {
this._selectResultOptionElement($autocomplete.find("li")[0]);
} else {
this._moveResultOptionElementSelectionCursor(
$autocomplete, event.which === this._keyCodes.arrow_up ? -1 : 1);
}
}
},
_handleEscapeKeyDown: function (event) {
this._stopEvent(event);
this._hideAutocompleteResultList();
},
_trySendJsfAjaxRequest: function () {
var self = this;
if (self.isRequestRunning) {
// console.log("request is active, so remember that changes has been made while request was running");
self.areChangesMadeWhileRequestWasRunning = true;
}
if (self.requestDelayTimerId !== null) {
window.clearTimeout(self.requestDelayTimerId)
}
self.requestDelayTimerId = window.setTimeout(function () {
self.requestDelayTimerId = null;
self._sendJsfAjaxRequest();
}, self.SEARCH_REQUEST_DELAY);
},
_sendJsfAjaxRequest: function () {
var self = this;
if (self.isRequestRunning) {
// console.log("request is running, abort");
return;
}
self.isRequestRunning = true;
self.areChangesMadeWhileRequestWasRunning = false;
self._showLoadingSpinner();
// console.log("starting request");
jsf.ajax.request(self.$input[0], "autocomplete", {
"javax.faces.behavior.event": "autocomplete",
render: self.autocompleteId,
params: self.$input.val(),
onevent: function (data) {
if (data.status === "success") {
// console.log("request finished");
// only show result if input field still has focus
if (self.$input.is(":focus")) {
self._handleAutocompleteResultListVisibility();
}
self._hideLoadingSpinner();
self.isRequestRunning = false;
if (self.areChangesMadeWhileRequestWasRunning) {
// console.log("changes made while request was running, start new request automatically");
self._sendJsfAjaxRequest();
}
}
}
});
},
_handleAutocompleteResultListVisibility: function () {
var self = this;
var $autocomplete = self._getAutocompleteElement();
if ($autocomplete.find("li").length > 0) {
self._initAndShowAutocompleteResultList();
} else {
self._hideAutocompleteResultList();
}
},
_showLoadingSpinner: function () {
$('
')
.appendTo(this.$input.parent());
},
_hideLoadingSpinner: function () {
this.$input.parent().find(".butter-dropdownlist-spinner").remove();
},
_initAndShowAutocompleteResultList: function () {
var self = this;
var $autocomplete = self._getAutocompleteElement();
$autocomplete
.show()
.css({
width: self.$input.innerWidth()
})
.highlight(self.$input.val());
$autocomplete.find("ul")
.on("mouseleave", function () {
self._clearResultOptionSelection();
});
$autocomplete.find("li")
.on("mousedown", function () {
self._setSelectedValue();
})
.on("mouseenter", function () {
self._selectResultOptionElement(this);
});
},
_selectResultOptionElement: function (optionElement) {
this._clearResultOptionSelection();
var $selectedOptionElement = $(optionElement);
$selectedOptionElement.addClass("butter-dropdownlist-resultItem-selected");
this.$selectedOption = $selectedOptionElement;
},
_clearResultOptionSelection: function () {
this.$selectedOption = null;
this._getAutocompleteElement()
.find(".butter-dropdownlist-resultItem-selected")
.removeClass("butter-dropdownlist-resultItem-selected");
},
_moveResultOptionElementSelectionCursor: function ($autocomplete, direction) {
if (direction > 0) {
var $next = this.$selectedOption.next();
if ($next.length > 0) {
this._selectResultOptionElement($next[0]);
} else {
//there is no next
this._selectResultOptionElement($autocomplete.find("li")[0]);
}
} else {
var $prev = this.$selectedOption.prev();
if ($prev.length > 0) {
this._selectResultOptionElement($prev[0]);
} else {
//there is no previous
var resultListOptions = $autocomplete.find("li");
this._selectResultOptionElement(resultListOptions[resultListOptions.length - 1]);
}
}
},
_setSelectedValue: function () {
if (this.$selectedOption !== null) {
this.ignoreKeyupEvent = true;
this.$input
.val(this.$selectedOption.attr("data-select-value"))
.change()
.focus()
.keyup();
this._hideAutocompleteResultList();
}
},
_hideAutocompleteResultList: function () {
if (this.requestDelayTimerId !== null) {
window.clearTimeout(this.requestDelayTimerId)
}
this.$selectedOption = null;
this._getAutocompleteElement().hide();
},
_getAutocompleteElement: function () {
return $(document.getElementById(this.autocompleteId));
},
_stopEvent: function (event) {
event.stopPropagation();
event.preventDefault();
}
});
}(jQuery));
/**
* jQuery-Plugin to handle bootstrap fixes.
* Works with at least jQuery 1.3.2.
*
* How to use:
* jQuery("#someTreeSelector").fixBootstrapDropDown();
*/
(function ($) {
$.fn.fixBootstrapDropDown = function () {
return this.each(function () {
$('.dropdown-menu').on('click', function(e) {
if($(this).hasClass('dropdown-menu-form')) {
e.stopPropagation();
}
});
});
};
}(jQuery));
/**
* butterItemFilterField is a jQuery plugin that filters html element with the css class filterable-item.
* It is applied to the search field.
* If no filter text is entered, then all filterable-items are displayed. Else the search field value is matched against all text contained by a filterable-item.
*
* How to use:
* jQuery("#someInputSelector").butterItemFilterField();
*
* Author: Yann Massard
*/
(function ($) {
var delay = (function () {
var timer = 0;
return function (callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();
// extend jQuery --------------------------------------------------------------------
$.fn.butterItemFilterField = function (filterableItemContainerSelector) {
return this.each(function () {
var $this = $(this);
$this.keyup(function () {
delay(function () {
var filterValue = $this.val();
// find container again every time, because it could have been rerendered.
var $filterableItemContainer;
if (filterableItemContainerSelector) {
$filterableItemContainer = $(filterableItemContainerSelector);
} else {
var containerSelector = $this.attr('data-filterable-item-container');
$filterableItemContainer = $(containerSelector);
}
$filterableItemContainer.find('.filterable-item').each(function () {
var $filterableItem = $(this);
if ($filterableItem.is(':containsIgnoreCase(' + filterValue + ')')) {
$filterableItem.removeClass("hidden");
$filterableItem.highlight(filterValue);
} else {
$filterableItem.addClass("hidden");
}
});
}, 300);
});
});
};
}(jQuery));
(function ($) {
$.expr[":"].containsIgnoreCase = $.expr.createPseudo(function (arg) {
return function (elem) {
return !arg || $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
}(jQuery));
(function ($) {
// extend jQuery --------------------------------------------------------------------
$.fn.butterCombobox = function () {
return this.each(function () {
new FilterableCombobox(this);
});
};
// define objects --------------------------------------------------------------------
/**
* @class
*/
var FilterableComboboxMouseEventListener = Class.extend({
/**
* Is called when a mouse down event is triggered on a result list option. Intended to be overridden.
* @param {String} value the value of the result list option
*/
onResultItemMouseDown: function (value) {
},
/**
* Is called when a mouse enter event is triggered on a result list option. Intended to be overridden.
* @param {String} value the value of the result list option
*/
onResultItemMouseEnter: function (value) {
}
});
/**
* @class
*/
var FilterableComboboxOption = Class.extend({
/**
* @constructs
* @param {HTMLElement} optionElement
* @param {FilterableComboboxMouseEventListener} mouseEventListener
* @param {jQuery} $template
*/
init: function (optionElement, mouseEventListener, $template) {
this._$optionElement = $(optionElement);
this._mouseEventListener = mouseEventListener;
this._$resultElement;
this._initResultItem($template);
},
_initResultItem: function ($template) {
var self = this;
var resultItemHtml = self._$optionElement.text();
if ($template !== undefined) {
var dataFields = self._$optionElement.data();
// for the no selection option there are no data fields. don't take the template in this case!
if(!$.isEmptyObject(dataFields)) {
resultItemHtml = $template;
$template.replace(/\{\{(.*?)\}\}/g, function (group0, group1) {
resultItemHtml = resultItemHtml.replace("{{" + group1 + "}}", dataFields[group1.toLowerCase()] || '')
return;
})
}
}
self._$resultElement = $("
")
.html(resultItemHtml)
.addClass("butter-dropdownlist-resultItem");
if (self._mouseEventListener !== undefined) {
self._$resultElement.
on("mousedown", function () {
self._mouseEventListener.onResultItemMouseDown(self.getValue());
})
.on("mouseenter", function () {
self._mouseEventListener.onResultItemMouseEnter(self.getValue());
});
}
},
/**
* @returns {String} the option's value
*/
getValue: function () {
return this._$optionElement.val();
},
/**
* @returns {String} the option's label text. This is the text between the option tags.
*/
getLabel: function () {
return this._$optionElement.text();
},
/**
* @returns {jQuery} a jQuery extended HTML element
*/
getResultElement: function () {
return this._$resultElement;
}
});
/**
* @class
*/
var FilterableComboboxEmtpyOption = FilterableComboboxOption.extend({
/**
* @constructs
*/
init: function () {
this._$optionElement = $("