• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcepublicjavascriptscommonyobi.ui.Dropdown.js
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
bootstrap
Source Code Upload
02-04
help
Source Code Upload
02-04
images
Source Code Upload
02-04
javascripts
Source Code Upload
02-04
stylesheets
Source Code Upload
02-04
compiler.jar
Source Code Upload
02-04
File name
Commit message
Commit date
common
Source Code Upload
02-04
lib
Source Code Upload
02-04
service
Source Code Upload
02-04
template
Source Code Upload
02-04
yona-common.js
Source Code Upload
02-04
yona-layout.js
Source Code Upload
02-04
yona-lib.js
Source Code Upload
02-04
File name
Commit message
Commit date
yobi.Attachments.js
Source Code Upload
02-04
yobi.CodeCommentBlock.js
Source Code Upload
02-04
yobi.CodeCommentBox.js
Source Code Upload
02-04
yobi.Comment.js
Source Code Upload
02-04
yobi.CommentForm.js
Source Code Upload
02-04
yobi.Common.js
Source Code Upload
02-04
yobi.Files.js
Source Code Upload
02-04
yobi.Interval.js
Source Code Upload
02-04
yobi.LoginDialog.js
Source Code Upload
02-04
yobi.Markdown.js
Source Code Upload
02-04
yobi.Mention.js
Source Code Upload
02-04
yobi.OriginalMessage.js
Source Code Upload
02-04
yobi.Pagination.js
Source Code Upload
02-04
yobi.ShortcutKey.js
Source Code Upload
02-04
yobi.WatcherList.js
Source Code Upload
02-04
yobi.ui.Calendar.js
Source Code Upload
02-04
yobi.ui.Dialog.js
Source Code Upload
02-04
yobi.ui.Dropdown.js
Source Code Upload
02-04
yobi.ui.Mergely.js
Source Code Upload
02-04
yobi.ui.Select2.js
Source Code Upload
02-04
yobi.ui.Tabs.js
Source Code Upload
02-04
yobi.ui.Toast.js
Source Code Upload
02-04
yobi.ui.Typeahead.js
Source Code Upload
02-04
yona.CommentAttachmentsUpdate.js
Source Code Upload
02-04
yona.KeyControl.js
Source Code Upload
02-04
yona.ReceiverList.js
Source Code Upload
02-04
yona.Sha1.js
Source Code Upload
02-04
yona.SubComment.js
Source Code Upload
02-04
yona.Subtask.js
Source Code Upload
02-04
yona.Tasklist.js
Source Code Upload
02-04
yona.TitleHeadAutoCompletion.js
Source Code Upload
02-04
yona.Usermenu.js
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * Yobi, Project Hosting SW * * Copyright 2013 NAVER Corp. * http://yobi.io * * @author Jihan Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @example * var oSelect = new yobi.Dropdown({ * "elContainer": ".btn-group", * "fOnChange" : function(){}, * " * }); * * @require bootstrap-dropdown.js */ (function(ns){ var oNS = $yobi.createNamespace(ns); oNS.container[oNS.name] = function(htOptions){ var htVar = {"sValue":""}; var htElement = {}; function _init(htOptions){ _initElement(htOptions); _attachEvent(); htVar.fOnChange = htOptions.fOnChange; _selectDefault(); } function _initElement(htOptions){ htElement.welContainer = $(htOptions.elContainer); htElement.welSelectedLabel = htElement.welContainer.find(".d-label"); htElement.welList = htElement.welContainer.find(".dropdown-menu"); htElement.waItems = htElement.welList.find("li"); } function _attachEvent(){ htElement.welList.on("click", "li", _onClickItem); htElement.welList.on("mousewheel", _onScrollList); } /** * @param weEvt * @returns {boolean} * @private */ function _onScrollList(weEvt){ if((weEvt.originalEvent.deltaY > 0 && _isScrollEndOfList()) || (weEvt.originalEvent.deltaY < 0 && _isScrollTopOfList())){ weEvt.preventDefault(); weEvt.stopPropagation(); return false; } } /** * @returns {boolean} * @private */ function _isScrollTopOfList(){ return (htElement.welList.scrollTop() === 0); } /** * @returns {boolean} * @private */ function _isScrollEndOfList(){ return (htElement.welList.scrollTop() + htElement.welList.height() === htElement.welList.get(0).scrollHeight); } /** * @param {Wrapped Event} weEvt */ function _onClickItem(weEvt){ // set welTarget to <li> item var welCurrent = $(weEvt.target); var welTarget = (weEvt.target.tagName === "LI") ? welCurrent : $(welCurrent.parents("li")[0]); // ignore click event if item doesn't have data-value attribute if(welTarget.length === 0 || typeof welTarget.attr("data-value") === "undefined"){ weEvt.stopPropagation(); weEvt.preventDefault(); return false; } _setItemSelected(welTarget); // display _setFormValue(welTarget); // set form value _onChange(); // fireEvent } /** * @param {Wrapped Element} welTarget */ function _setItemSelected(welTarget){ htElement.welSelectedLabel.html(welTarget.html()); htElement.waItems.removeClass("active"); welTarget.addClass("active"); } /** * @param {Wrapped Element} welTarget */ function _setFormValue(welTarget){ var sFieldValue = welTarget.attr("data-value"); var sFieldName = htElement.welContainer.attr("data-name"); htVar.sName = sFieldName; htVar.sValue = sFieldValue; if(typeof sFieldName === "undefined"){ return; } var welInput = htElement.welContainer.find("input[name='" + sFieldName +"']"); if(welInput.length === 0){ welInput = $('<input type="hidden" name="' + sFieldName + '">'); htElement.welContainer.append(welInput); } welInput.val(sFieldValue); } function _onChange(){ if(typeof htVar.fOnChange == "function"){ setTimeout(function(){ htVar.fOnChange(_getValue()); }, 0); } } /** * @param {Function} fOnChange */ function _setOnChange(fOnChange){ htVar.fOnChange = fOnChange; return true; } /** * @return {String} */ function _getValue(){ return htVar.sValue; } function _selectDefault(){ return _selectItem("li[data-selected=true]"); } /** * @param {String} sValue */ function _selectByValue(sValue){ return _selectItem("li[data-value='" + sValue + "']"); } /** * @param {String} sQuery */ function _selectItem(sQuery){ var waFind = htElement.welContainer.find(sQuery); if(waFind.length <= 0){ return false; // no item matches } var welTarget = $(waFind[0]); _setItemSelected(welTarget); _setFormValue(welTarget); return true; } _init(htOptions); return { "getValue": _getValue, "onChange": _setOnChange, "selectByValue": _selectByValue, "selectItem" : _selectItem }; }; })("yobi.ui.Dropdown");

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up