/*! * jQuery ComboTree Plugin * Author: Erhan FIRAT * Mail: erhanfirat@gmail.com * Licensed under the MIT license * Version: 1.1 */ ;(function ( $, window, document, undefined ) { // Create the defaults once var comboTreePlugin = 'comboTree', defaults = { source: [], isMultiple: false }; // The actual plugin constructor function ComboTree( element, options ) { this.elemInput = element; this._elemInput = $(element); this.options = $.extend( {}, defaults, options) ; this._defaults = defaults; this._name = comboTreePlugin; this.init(); } ComboTree.prototype.init = function () { // Setting Doms this.comboTreeId = 'comboTree' + Math.floor(Math.random() * 999999); this._elemInput.addClass('comboTreeInputBox'); if (this._elemInput.attr('id') === undefined) this._elemInput.attr('id', this.comboTreeId + 'Input'); this.elemInputId = this._elemInput.attr('id'); this._elemInput.wrap('
'); this._elemInput.wrap('
'); this._elemWrapper = $('#' + this.comboTreeId + 'Wrapper'); this._elemArrowBtn = $(''); this._elemInput.after(this._elemArrowBtn); this._elemWrapper.append('
'); // DORP DOWN AREA this._elemDropDownContainer = $('#' + this.comboTreeId + 'DropDownContainer'); this._elemDropDownContainer.html(this.createSourceHTML()); this._elemItems = this._elemDropDownContainer.find('li'); this._elemItemsTitle = this._elemDropDownContainer.find('span.comboTreeItemTitle'); // VARIABLES this._selectedItem = {}; this._selectedItems = []; this.bindings(); }; // ********************************* // SOURCES CODES // ********************************* ComboTree.prototype.removeSourceHTML = function () { this._elemDropDownContainer.html(''); }; ComboTree.prototype.createSourceHTML = function () { var sourceHTML = ''; if (this.options.isMultiple) sourceHTML = this.createFilterHTMLForMultiSelect(); sourceHTML += this.createSourceSubItemsHTML(this.options.source); return sourceHTML; }; ComboTree.prototype.createFilterHTMLForMultiSelect = function (){ return ''; } ComboTree.prototype.createSourceSubItemsHTML = function (subItems) { var subItemsHtml = '