code
stringlengths 10
343k
| docstring
stringlengths 36
21.9k
| func_name
stringlengths 1
3.35k
| language
stringclasses 1
value | repo
stringlengths 7
58
| path
stringlengths 4
131
| url
stringlengths 44
195
| license
stringclasses 5
values |
---|---|---|---|---|---|---|---|
function _isLabelExists(categoryName, labelName){
return (_getCategoryElement(categoryName).find('[data-label-name="' + labelName + '"]').length > 0);
} | Returns whether the label exists which is specified category and name.
@param categoryName
@param labelName
@returns {boolean}
@private | _isLabelExists ( categoryName , labelName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _addLabelIntoCategory(label){
if(_isNewCategory(label.category)){
vars.categories.push(label.category);
_addCategoryIntoEditFormSelect(label.categoryId, label.category);
}
_reloadLabelList();
} | Add specified label into category.
append label name to typeahead source,
and render list which the label has added.
@param label
@private | _addLabelIntoCategory ( label ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _addCategoryIntoEditFormSelect(categoryId, categoryName){
var option = $('<option value="' + categoryId + '">' + categoryName + '</option>');
elements.editLabelCategory.append(option);
} | Add new category option into select on edit label form
@param label
@private | _addCategoryIntoEditFormSelect ( categoryId , categoryName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _reloadLabelList(){
document.location.reload(true);
} | Refresh element.list as PJAX style after add label.
@private | _reloadLabelList ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onFocusInputName(){
elements.colorsWrap.show();
var categoryName = elements.inputCategory.val().trim();
var labelColor = _isNewCategory(categoryName) ? _getRandomColorCodeInPreset()
: _getFirstItemColorInCategory(categoryName);
if(elements.inputColor.val().length === 0){
elements.inputColor.val(labelColor);
_updateInputBySelectedColor(elements.inputName, elements.inputColor, labelColor);
}
} | "focus" event handler of inputName
Shows preset color buttons, and fills inputColor with color code if it is empty.
Random color if entered category name is not exists before,
or color of first item in category if the category exists.
@private | _onFocusInputName ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _getRandomColorCodeInPreset(){
var presetColors = elements.colorsWrap.find(".btn-preset-color");
var randomIndex = (new Date().getTime()) % presetColors.length;
var color = presetColors.get(randomIndex).style.backgroundColor;
return _getRefinedHexColor(color);
} | Returns random color code in preset colors.
@private
@returns {String} | _getRandomColorCodeInPreset ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _getFirstItemColorInCategory(categoryName){
var targetItem = _getCategoryElement(categoryName).find(".issue-label:first");
var color = targetItem.css("background-color");
return _getRefinedHexColor(color);
} | Returns background-color of first .issue-label in specified {@code categoryName}
@param categoryName
@returns {String}
@private | _getFirstItemColorInCategory ( categoryName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnPresetColor(evt){
var targetButton = $(evt.target);
var targetColor = _getRefinedHexColor(targetButton.css('background-color'));
elements.inputColor.val(targetColor);
elements.inputColor.focus();
elements.colorsWrap.find(".btn-preset-color").removeClass("active");
targetButton.addClass("active");
_updateInputBySelectedColor(elements.inputName, elements.inputColor, targetColor);
} | "click" event handler of preset color button
@param evt
@private | _onClickBtnPresetColor ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onBlurInputColor(){
var typedColor = elements.inputColor.val();
if(typedColor.length < 1){
return;
}
if(!_isValidColorExpr(typedColor)){
$yobi.alert(Messages("label.error.color", typedColor), function(){
elements.inputColor.focus();
});
return;
}
_updateInputBySelectedColor(elements.inputName,
elements.inputColor,
_getRefinedHexColor(typedColor));
} | "blur" event handler of inputColor
@private | _onBlurInputColor ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _getRefinedHexColor(color){
var rgb = new RGBColor(color || "");
return rgb && rgb.ok ? rgb.toHex() : false;
} | Get color code in HEX.
Returns false if given color expression is cannot be covered by RGBColor.
@require lib/rgbcolor.js
@param color
@returns {*}
@private | _getRefinedHexColor ( color ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _updateInputBySelectedColor(inputName, inputColor, color){
if(!color){
return;
}
var boxShadowCSS = _getPrefixedCSSText("box-shadow: inset 25px 0 0 " + color + " !important");
inputColor.css("cssText", boxShadowCSS);
inputName.css("background-color", color);
inputName.removeClass("dimgray white").addClass($yobi.getContrastColor(color));
} | Update inputColor and inputName style with given color expression
@require common/yobi.Common.js
@param color
@private | _updateInputBySelectedColor ( inputName , inputColor , color ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _getPrefixedCSSText(cssText){
var result = [];
var prefixes = ["", "-moz-", "-webkit-"];
prefixes.forEach(function(prefix){
result.push(prefix + cssText);
});
return result.join(";");
} | Returns CSS Text prefixed with -moz-, -webkit-.
@param cssText
@returns {string}
@private
@example
_getPrefixedCSSText('text-shadow: 1px 1px 0 #000');
// Returns string below:
// text-shadow: 1px 1px 0 #000; -moz-text-shadow: 1px 1px 0 #000; -webkit-text-shadow: 1px 1px 0 #000; | _getPrefixedCSSText ( cssText ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnDeleteLabel(evt){
$yobi.confirm(Messages("label.confirm.delete"), function(data){
if(data.nButtonIndex === 1){
_requestRemoveLabel(evt.target);
}
});
} | "click" event handler of label delete button
Show confirm to delete and send request to remove label.
@param evt
@private | _onClickBtnDeleteLabel ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _requestRemoveLabel(target){
var targetButton = $(target);
$.ajax(targetButton.data("deleteUri"), {
"method": "post",
"data" : {"_method": "delete"}
})
.done(function(){
_removeLabel(targetButton.data("categoryName"), targetButton.data("labelId"));
});
} | Send AJAX request to remove label with specified delete button
@param target
@private | _requestRemoveLabel ( target ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _removeLabel(categoryName, labelId){
$('tr[data-label-id="' + labelId + '"]').remove();
if(_isEmptyCategory(categoryName)){
_removeCategory(categoryName);
}
} | Remove specified label from list
@param categoryName
@param labelId
@private | _removeLabel ( categoryName , labelId ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _isEmptyCategory(categoryName){
return (_getCategoryElement(categoryName).find("tr[data-label-id]").length === 0);
} | Returns whether given category is empty in list.
@param categoryName
@returns {boolean}
@private | _isEmptyCategory ( categoryName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _removeCategory(categoryName){
_getCategoryElement(categoryName).remove();
} | Remove specified category from list
@param categoryName
@private | _removeCategory ( categoryName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _getCategoryElement(categoryName){
return $('div.category-wrap[data-category-name="' + categoryName + '"]');
} | Returns category wrapper jQuery HTMLElement
This function used when to remove category, determine the category is empty
or other DOM traversal/manipulations.
@param categoryName
@returns {*|jQuery|HTMLElement}
@private | _getCategoryElement ( categoryName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnEditCategory(evt){
var target = $(evt.currentTarget);
elements.editCategoryForm.data(target.data());
elements.editCategoryName.val(target.data("categoryName"));
elements.editCategoryForm.find("[name=isExclusive]").data("select2").val(target.data("categoryIsExclusive") + "");
elements.editCategoryForm.modal("show");
} | "click" event handler of edit category button.
Shows modal dialog element.editCategoryForm with .data() of clicked button.
@param evt
@private | _onClickBtnEditCategory ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnEditLabel(evt){
var target = $(evt.currentTarget);
elements.editLabelForm.data(target.data());
elements.editLabelName.val(target.data("labelName"));
elements.editLabelColor.val(target.data("labelColor"));
elements.editLabelCategory.data("select2").val(target.data("categoryId"));
elements.editLabelForm.modal("show");
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
target.data("labelColor"));
} | "click" event handler of edit label button.
Shows modal dialog element.editLabelForm with .data() of clicked button.
@param evt
@private | _onClickBtnEditLabel ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnSubmitEditLabel(){
var requestData = {
"name" : $.trim(elements.editLabelName.val()),
"color": $.trim(elements.editLabelColor.val()),
"category.id": elements.editLabelCategory.val()
};
// Check is label with same name exists on new category
var categoryName = elements.editLabelCategory.data("select2").data().text;
var initialLabelName = elements.editLabelForm.data("labelName");
var isLabelNameChanged = (requestData.name != initialLabelName);
if(isLabelNameChanged && _isLabelExists(categoryName, requestData.name)){
_popoverMessageOn(Messages("label.error.duplicated.in.category", categoryName), elements.editLabelName);
return false;
}
// Check is entered color valid
if(!_isValidColorExpr(requestData.color)){
_popoverMessageOn(Messages("label.error.color", requestData.color), elements.editLabelColor);
return false;
}
NProgress.start();
$.ajax(elements.editLabelForm.data("updateUri"), {
"method": "put",
"data" : requestData
}).done(function(){
_reloadLabelList();
}).fail(function(res){
_showError(res, "label.edit");
}).always(function(){
elements.editLabelForm.modal("hide");
NProgress.done();
});
} | "click" event handler of submit button on edit label form.
Send update label request to "labelUpdateUri".
@private | _onClickBtnSubmitEditLabel ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnPresetColorOnEditForm(evt){
var targetButton = $(evt.target);
var targetColor = _getRefinedHexColor(targetButton.css('background-color'));
elements.editLabelColor.focus();
elements.editLabelColor.val(targetColor);
elements.editLabelColorsWrap.find(".btn-preset-color").removeClass("active");
targetButton.addClass("active");
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
targetColor);
} | "click" event handler of preset color buttons on editLabel form.
@param evt
@private | _onClickBtnPresetColorOnEditForm ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onBlurEditColor(){
var refinedColor = _getRefinedHexColor(elements.editLabelColor.val());
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
refinedColor);
} | "blur" event handler of color input on editLabel form.
@private | _onBlurEditColor ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _isValidColorExpr(colorExpr){
// As RGBColor.js is too generous to validate HEX color expression,
// Check length of colorExpr if it starts with '#' which means HEX.
if(colorExpr.indexOf('#') === 0 &&
!(colorExpr.length === 4 || colorExpr.length === 7)){
return false;
}
var rgb = new RGBColor(colorExpr);
return (rgb && rgb.ok);
} | Returns whether given color expression is valid
@param colorExpr
@returns {boolean}
@private | _isValidColorExpr ( colorExpr ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _popoverMessageOn(message, element){
element.popover("destroy");
element.popover({
"placement": "bottom",
"content" : message
}).popover("show");
} | Show {@code message} bottom of {@code element}
@param message
@param element
@private | _popoverMessageOn ( message , element ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onClickBtnSubmitEditCategory(){
var requestData = {
"id" : elements.editCategoryForm.data("categoryId"),
"name": $.trim(elements.editCategoryName.val()),
"isExclusive": elements.editCategoryExclusive.val(),
"project.id" : elements.editCategoryForm.data("projectId")
};
NProgress.start();
$.ajax(elements.editCategoryForm.data("categoryUpdateUri"), {
"method": "put",
"data" : requestData
}).done(function(){
_reloadLabelList();
}).fail(function(res){
_showError(res, "label.category.edit");
}).always(function(){
elements.editCategoryForm.modal("hide");
NProgress.done();
});
}
/**
* "click" event handler of edit label button.
* Shows modal dialog element.editLabelForm with .data() of clicked button.
*
* @param evt
* @private
*/
function _onClickBtnEditLabel(evt){
var target = $(evt.currentTarget);
elements.editLabelForm.data(target.data());
elements.editLabelName.val(target.data("labelName"));
elements.editLabelColor.val(target.data("labelColor"));
elements.editLabelCategory.data("select2").val(target.data("categoryId"));
elements.editLabelForm.modal("show");
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
target.data("labelColor"));
}
/**
* "click" event handler of submit button on edit label form.
* Send update label request to "labelUpdateUri".
*
* @private
*/
function _onClickBtnSubmitEditLabel(){
var requestData = {
"name" : $.trim(elements.editLabelName.val()),
"color": $.trim(elements.editLabelColor.val()),
"category.id": elements.editLabelCategory.val()
};
// Check is label with same name exists on new category
var categoryName = elements.editLabelCategory.data("select2").data().text;
var initialLabelName = elements.editLabelForm.data("labelName");
var isLabelNameChanged = (requestData.name != initialLabelName);
if(isLabelNameChanged && _isLabelExists(categoryName, requestData.name)){
_popoverMessageOn(Messages("label.error.duplicated.in.category", categoryName), elements.editLabelName);
return false;
}
// Check is entered color valid
if(!_isValidColorExpr(requestData.color)){
_popoverMessageOn(Messages("label.error.color", requestData.color), elements.editLabelColor);
return false;
}
NProgress.start();
$.ajax(elements.editLabelForm.data("updateUri"), {
"method": "put",
"data" : requestData
}).done(function(){
_reloadLabelList();
}).fail(function(res){
_showError(res, "label.edit");
}).always(function(){
elements.editLabelForm.modal("hide");
NProgress.done();
});
}
/**
* "click" event handler of preset color buttons on editLabel form.
*
* @param evt
* @private
*/
function _onClickBtnPresetColorOnEditForm(evt){
var targetButton = $(evt.target);
var targetColor = _getRefinedHexColor(targetButton.css('background-color'));
elements.editLabelColor.focus();
elements.editLabelColor.val(targetColor);
elements.editLabelColorsWrap.find(".btn-preset-color").removeClass("active");
targetButton.addClass("active");
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
targetColor);
}
/**
* "blur" event handler of color input on editLabel form.
*
* @private
*/
function _onBlurEditColor(){
var refinedColor = _getRefinedHexColor(elements.editLabelColor.val());
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
refinedColor);
}
function _onKeyUpEditColor(){
if(!_isValidColorExpr(elements.editLabelColor.val())){
return;
}
_updateInputBySelectedColor(elements.editLabelName,
elements.editLabelColor,
elements.editLabelColor.val());
}
/**
* Returns whether given color expression is valid
*
* @param colorExpr
* @returns {boolean}
* @private
*/
function _isValidColorExpr(colorExpr){
// As RGBColor.js is too generous to validate HEX color expression,
// Check length of colorExpr if it starts with '#' which means HEX.
if(colorExpr.indexOf('#') === 0 &&
!(colorExpr.length === 4 || colorExpr.length === 7)){
return false;
}
var rgb = new RGBColor(colorExpr);
return (rgb && rgb.ok);
}
/**
* Show {@code message} bottom of {@code element}
*
* @param message
* @param element
* @private
*/
function _popoverMessageOn(message, element){
element.popover("destroy");
element.popover({
"placement": "bottom",
"content" : message
}).popover("show");
}
_init(options || {});
}; | "click" event handler of submit button on edit category form.
Send update category request to "categoryUpdateUri".
@private | _onClickBtnSubmitEditCategory ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.LabelEditor.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.LabelEditor.js | Apache-2.0 |
function _onKeyUpInput(evt){
var keyCode = (evt.keyCode || evt.which);
if(keyCode !== 13){
$(evt.target).data("isUserHasTyped", true)
.off("keyup", _onKeyUpInput);
}
} | "keyup" event handler of inputTitle, inputBody.
Mark as user has typed on this input, and detach this event handler.
Ignore if the pressed key is ENTER.
@param {Wrapped Event} evt | _onKeyUpInput ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _onChangeProject(){
var data = _getFormValue();
location.search = "?fromProjectId=" + data.fromProjectId + "&toProjectId=" + data.toProjectId;
} | Reload page with changed fromProjectId, toProjectId query string.
@private | _onChangeProject ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _onSuccessMergeResult(resultHTML){
elements.commits.html(resultHTML);
vars.mergeResult = _getMergeResultData();
_showMergeResult(vars.mergeResult);
_fillFormTitleBody(vars.mergeResult);
} | On success to load mergeResult
Fill element.commits and form field title/body.
and show result with parsing responded HTML.
@param resultHTML
@private | _onSuccessMergeResult ( resultHTML ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _fillFormTitleBody(data){
var isUserHasTyped = elements.title.data("isUserHasTyped") ||
elements.body.data("isUserHasTyped");
if(!isUserHasTyped){
elements.title.val(data.title);
elements.body.val(data.body);
}
} | Fill form input title and body with merge result data
if user doesn't have typed.
@param data
@private | _fillFormTitleBody ( data ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _onSubmitForm(){
return _validateForm();
} | "submit" event handler of the form.
Returns false if validate fails.
@returns {Boolean}
@private | _onSubmitForm ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _validateForm(){
// Check whether is commit exists to send
if(!vars.mergeResult.numOfCommits){
$yobi.alert(Messages("pullRequest.diff.noChanges"));
return false;
}
// Show confirm dialog in case of conflict
if(vars.mergeResult.isConflict && !vars.mergeResult.forceSubmit){
$yobi.confirm(Messages("pullRequest.ignore.conflict"), function(data){
if(data.nButtonIndex === 1){
vars.mergeResult.forceSubmit = true;
elements.form.submit();
}
});
return false;
}
// Check whether required field is empty
var requiredField = _getFormValue();
for(var fieldName in requiredField){
if(requiredField[fieldName].length === 0){
$yobi.alert(Messages("pullRequest." + fieldName + ".required"));
return false;
}
}
return true;
} | Validate form before submit
@returns {boolean}
@private | _validateForm ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.Write.js | Apache-2.0 |
function _initShortcutKey(htKeyMap){
yobi.ShortcutKey.setKeymapLink(htKeyMap);
} | @param {Hash Table} htKeyMap
@require yobi.ShortcutKey | _initShortcutKey ( htKeyMap ) | javascript | yona-projects/yona | public/javascripts/service/yobi.project.Global.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.project.Global.js | Apache-2.0 |
function _initFormValidator(){
var aRules = [
{"name": 'password', "rules": 'required|min_length[4]'},
{"name": 'retypedPassword', "rules": 'required|matches[password]'}
];
htVar.oValidator = new FormValidator('passwordReset', aRules, _onFormValidate);
// set error message
htVar.oValidator.setMessage('required', Messages("validation.required"));
htVar.oValidator.setMessage('min_length', Messages("validation.tooShortPassword"));
htVar.oValidator.setMessage('matches', Messages("validation.passwordMismatch"));
} | initialize FormValidator
@require validate.js | _initFormValidator ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.resetPassword.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.resetPassword.js | Apache-2.0 |
function _onFormValidate(aErrors){
var welTarget;
aErrors.forEach(function(htError){
welTarget = htElement.welForm.find("input[name=" + htError.name + "]");
if(welTarget){
showErrorMessage(welTarget, htError.message);
}
});
} | on validate form
@param {Array} aErrors | _onFormValidate ( aErrors ) | javascript | yona-projects/yona | public/javascripts/service/yobi.resetPassword.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.resetPassword.js | Apache-2.0 |
function _init(htOptions){
_initVar(htOptions);
_attachEvent();
} | Initialize
@param {Hash Table} htOptions | _init ( htOptions ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Nohead.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Nohead.js | Apache-2.0 |
function _initVar(htOptions){
htVar.sPath = 'code/HEAD/!/';
htVar.nInterval = htOptions.nInterval || 5000; // ms
htVar.nTimer = null;
} | initialize variables
@param {Hash Table} htOptions | _initVar ( htOptions ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Nohead.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Nohead.js | Apache-2.0 |
function _showErrors(error){
if(!error){
return;
}
var targetElement;
for(var target in error){
targetElement = htElement.welForm.find("[name=" + target + "]");
if(targetElement.length > 0) {
targetElement.popover({
"trigger" : "manual",
"placement": "left",
"content" : error[target].shift()
}).popover("show");
}
}
}
function _onClickMenuSettingCode() {
var isChecked = $(this).prop("checked");
if (!isChecked) {
htElement.welMenuSettingCode.prop("checked", false);
htElement.welMenuSettingPullRequest.prop("checked", false);
htElement.welMenuSettingReview.prop("checked", false);
htElement.welReviewerCountSettingPanel.hide();
htElement.welDefaultBranceSettingPanel.hide();
htElement.welSubMenuProjectChangeVCS.hide();
}
}
function _onClickMenuSettingPullRequest() {
var isChecked = $(this).prop("checked");
if(isChecked) {
htElement.welMenuSettingCode.prop("checked", true);
} else {
htElement.welReviewerCountSettingPanel.hide();
}
}
function _onClickMenuSettingReview() {
var isChecked = $(this).prop("checked");
if(isChecked) {
htElement.welMenuSettingCode.prop("checked", true);
}
}
_init(htOptions || {});
}; | Show error message on target element with $.popover
@param error
@private | _showErrors ( error ) | javascript | yona-projects/yona | public/javascripts/service/yobi.project.New.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.project.New.js | Apache-2.0 |
(function(ns) {
var oNS = $yobi.createNamespace(ns);
oNS.container[oNS.name] = function(htOptions) {
var htElement = {};
/**
* initialize
*/
function _init() {
_initElement();
_attachEvent();
}
/**
* initialize element variables
*/
function _initElement() {
htElement.welBtnEnroll = $("#enrollBtn");
}
/**
* attach event handlers
*/
function _attachEvent() {
htElement.welBtnEnroll.on('click',_onClickBtnEnroll);
}
/**
* @param {Wrapped Event} weEvt
*/
function _onClickBtnEnroll(weEvt){
var sURL = $(this).attr('href');
$.ajax(sURL, {
"method" : "post",
"success": function(){
document.location.reload();
},
"error": function(){
$yobi.notify("Server Error");
}
})
weEvt.preventDefault();
return false;
}
_init(htOptions || {});
};
})("yobi.organization.Global"); | Yobi, Project Hosting SW
Copyright 2014 NAVER Corp.
http://yobi.io
@author Changsung 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. | (anonymous) ( ns ) | javascript | yona-projects/yona | public/javascripts/service/yobi.organization.Global.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.organization.Global.js | Apache-2.0 |
function _onValidateLoginId(sLoginId){
return htVar.rxLoginId.test(sLoginId);
} | login id validation
@param {String} sLoginId
@return {Boolean} | _onValidateLoginId ( sLoginId ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.SignUp.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.SignUp.js | Apache-2.0 |
function doesExists(welInput, sURL){
$.ajax({
"url": sURL + welInput.val()
}).done(function(htData){
if(htData.isExist === true){
showErrorMessage(welInput, Messages("validation.duplicated"));
} else if (htData.isReserved == true) {
showErrorMessage(welInput, Messages("validation.reservedWord"));
} else {
hideErrorMessage(welInput);
}
});
}
/**
* initialize FormValidator
* @require validate.js
*/
function _initFormValidator(){
var aRules = [
{"name": 'loginId', "rules": 'required|callback_check_loginId'},
{"name": 'email', "rules": 'required|valid_email'},
{"name": 'password', "rules": 'required|min_length[4]'},
{"name": 'retypedPassword', "rules": 'required|matches[password]'}
];
htVar.oValidator = new FormValidator('signup', aRules, _onFormValidate);
htVar.oValidator.registerCallback('check_loginId', _onValidateLoginId);
// set error message
htVar.oValidator.setMessage('check_loginId', Messages("validation.allowedCharsForLoginId"));
htVar.oValidator.setMessage('required', Messages("validation.required"));
htVar.oValidator.setMessage('min_length', Messages("validation.tooShortPassword"));
htVar.oValidator.setMessage('matches', Messages("validation.passwordMismatch"));
htVar.oValidator.setMessage('valid_email', Messages("validation.invalidEmail"));
}
/**
* login id validation
* @param {String} sLoginId
* @return {Boolean}
*/
function _onValidateLoginId(sLoginId){
return htVar.rxLoginId.test(sLoginId);
}
/**
* on validate form
* @param {Array} aErrors
*/
function _onFormValidate(aErrors){
var welTarget;
aErrors.forEach(function(htError){
welTarget = htElement.welForm.find("input[name=" + htError.name + "]");
if(welTarget){
showErrorMessage(welTarget, htError.message);
}
});
}
function showErrorMessage(welInput, sMessage){
welInput.popover({
"trigger": "manual",
"placement": "left",
"content": sMessage
}).popover("show");
}
function hideErrorMessage(welInput){
welInput.popover("hide");
try{
welInput.popover("destroy");
} catch(e){} // to avoid bootstrap bug
}
_init(htOptions || {});
}; | @param {Wrapped Element} welInput
@param {String} sURL | doesExists ( welInput , sURL ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.SignUp.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.SignUp.js | Apache-2.0 |
function _init(options){
_initElement(options || {});
_initVar(options || {});
_attachEvent();
_initFileUploader();
_initFileDownloader();
_initCommentAndCloseButton();
//_setTimelineUpdateTimer();
_affixIssueInfoWrap();
} | Initialize
@param {Hash Table} options | _init ( options ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _initElement(options){
elements.uploader = $("#upload");
elements.textarea = $('textarea[data-editor-mode="comment-body"]');
elements.btnWatch = $('#watch-button');
elements.issueInfoWrap = $(".issue-info");
elements.dueDateStatus = elements.issueInfoWrap.find(".duedate-status");
elements.timelineWrap = $("#timeline");
elements.timelineList = elements.timelineWrap.find(".timeline-list");
elements.dueDate = $("#issueDueDate");
elements.btnVoteComment = $(options.btnVoteComment || '[data-request-type="comment-vote"]');
} | Initialize HTML Element variables
@private | _initElement ( options ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _onChangeDueDate(evt){
var element = $(this);
var dueDate = $.trim(element.val());
// if dueDate is not empty and invalid
if(dueDate && !moment(dueDate).isValid()){
$yobi.notify(Messages("issue.error.invalid.duedate"), 3000);
element.focus();
return;
}
if(element.data("oval") !== element.val()){
element.data("oval", element.val());
}
_requestUpdateIssue(evt, function(res){
elements.dueDateStatus.html("(" + res.dueDateMsg + ")");
if (res.isOverDue) {
elements.dueDateStatus.addClass("overdue");
} else {
elements.dueDateStatus.removeClass("overdue");
}
});
} | on change dueDate input field
@param evt
@private | _onChangeDueDate ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _onChangeIssueInfo(evt){
_requestUpdateIssue(evt);
} | "change" event handler of issue info select2 fields.
@param evt
@private | _onChangeIssueInfo ( evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _getUpdateIssueRequestData(fieldName, fieldValue, evt){
var requestData = {"issues[0].id": vars.issueId};
if(fieldName === "labelIds"){
requestData["attachingLabelIds"] = _getIdProps(evt.added);
requestData["detachingLabelIds"] = _getIdProps(evt.removed);
} else {
requestData[fieldName] = fieldValue;
}
if(fieldName === "dueDate"){
requestData["isDueDateChanged"] = true;
}
return requestData;
} | Returns request data to update issue info.
@param fieldName
@param fieldValue
@param evt
@returns {Hash Table}
@private | _getUpdateIssueRequestData ( fieldName , fieldValue , evt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _getIdProps(source){
var result = [];
if(source instanceof Array){
source.forEach(function(obj){
if(obj && obj.id){
result.push(obj.id);
}
});
} else if(source && source.id){
result.push(source.id);
}
return (result.length > 0) ? result : undefined;
} | Returns "id" properties of given object.
If {@code source} is array, extract "id" property of each object in the array.
@param source
@returns {Array}
@private | _getIdProps ( source ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _onFocusCommentTextarea(){
vars.isTextareaOnFocused = true;
} | "focus" event handler of textarea
_onLoadTimeline references {@code vars.isTextareaOnFocus}
to hold steady scroll position from textarea
@private | _onFocusCommentTextarea ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _onBlurCommentTextarea(){
vars.isTextareaOnFocused = false;
} | "blur" event handler of textarea
@private | _onBlurCommentTextarea ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _initFileDownloader(target){
(target || $(".attachments")).each(function(i, container){
if(!$(container).data("isYobiAttachment")){
(new yobi.Attachments({"elContainer": container}));
}
});
} | Initialize fileDownloader
@param target
@private | _initFileDownloader ( target ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _onLoadTimeline(resultHTML){
if(resultHTML === vars.timelineHTML){ // update only HTML has changed
return;
}
_fixTimelineHeight();
var timelineList = _getRenderedTimeline(resultHTML);
setTimeout(function(){
elements.timelineList.replaceWith(timelineList);
elements.timelineList = timelineList;
vars.timelineHTML = resultHTML;
var isChanged = (vars.timelineItems !== _countTimelineItems());
var isTimelineChangedOnTyping = vars.isTextareaOnFocused && isChanged;
var scrollGap = isTimelineChangedOnTyping ?
(elements.textarea.offset().top - $(document).scrollTop()) : 0;
_unfixTimelineHeight();
if(isTimelineChangedOnTyping){
$(document).scrollTop(elements.textarea.offset().top - scrollGap);
}
}, 500);
} | Render issue timeline on load HTML
@param resultHTML
@private | _onLoadTimeline ( resultHTML ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _fixTimelineHeight(){
elements.timelineWrap.height(elements.timelineWrap.height());
} | fix timeline height with current height
@private | _fixTimelineHeight ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _getRenderedTimeline(timelineHTML){
var timelineList = elements.timelineList.clone();
timelineList.html(timelineHTML);
_initFileDownloader(timelineList.find(".attachments"));
yobi.Markdown.enableMarkdown(timelineList.find("[markdown]"));
timelineList.find("[data-request-method]").requestAs(); // delete button
return timelineList;
} | Get issue timeline element which filled with specified HTML String
@param sHTML
@returns {*}
@private | _getRenderedTimeline ( timelineHTML ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _setTimelineUpdateTimer(){
_unsetTimelineUpdateTimer();
vars.timelineItems = _countTimelineItems();
vars.timelineUpdateTimer = setInterval(function(){
var isEditing = (elements.timelineWrap.find(".comment-update-form:visible").length > 0)
|| _isDockedInspectorOpened();
if(vars.isTimelineUpdating !== true && !isEditing){
_updateTimeline();
}
}, vars.timelineUpdatePeriod);
} | Update timeline automatically with interval timer.
Don't update if visible .comment-update-form exists
or docked inspector is opened.
@private | _setTimelineUpdateTimer ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _unsetTimelineUpdateTimer(){
if(vars.timelineUpdateTimer != null){
clearInterval(vars.timelineUpdateTimer);
}
vars.timelineUpdateTimer = null;
} | Unset IssueTimeline update timer
@private | _unsetTimelineUpdateTimer ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _countTimelineItems(){
return elements.timelineList.find("ul.comments > li").length;
} | Count items in timeline
for detect timeline has updated
@returns {*}
@private | _countTimelineItems ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _initCommentAndCloseButton(){
var commentForm = $("#comment-form");
var dynamicCommentBtn = $("#dynamic-comment-btn");
var withStateTransitionInput = $("<input type='hidden' name='withStateTransition'>");
commentForm.prepend(withStateTransitionInput);
dynamicCommentBtn.removeClass("hidden");
dynamicCommentBtn.html(Messages("button.nextState." + vars.nextState));
dynamicCommentBtn.on("click", function(){
if(elements.textarea.val().length > 0){
withStateTransitionInput.val("true");
commentForm.submit();
} else {
withStateTransitionInput.val("");
location.href = vars.urls.nextState;
}
});
elements.textarea.on("keyup", function(){
if(elements.textarea.val().length > 0){
dynamicCommentBtn.html(Messages("button.commentAndNextState." + vars.nextState));
} else {
dynamicCommentBtn.html(Messages("button.nextState." + vars.nextState));
}
});
// if yobi.ShortcutKey exists
if(yobi.ShortcutKey){
yobi.ShortcutKey.attach("CTRL+SHIFT+ENTER", function(htInfo){
if(htInfo.welTarget.is(elements.textarea)){
dynamicCommentBtn.click();
}
});
}
} | Add "comment & close" like button at comment form
@private | _initCommentAndCloseButton ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.View.js | Apache-2.0 |
function _initVar(htOptions){
htVar.sTplFileItem = $('#tplAttachedFile').text();
htVar.sAction = htOptions.sAction;
htVar.sWatchUrl = htOptions.sWatchUrl;
htVar.sUnwatchUrl = htOptions.sUnwatchUrl;
} | initialize variables except HTML Element | _initVar ( htOptions ) | javascript | yona-projects/yona | public/javascripts/service/yobi.board.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.board.View.js | Apache-2.0 |
function _setStateUpdateTimer(){
if(htVar.nStateUpdateTimer != null){
yobi.Interval.clear(htVar.nStateUpdateTimer);
htVar.nStateUpdateTimer = null;
}
htVar.nStateUpdateTimer = yobi.Interval.set(function(){
if(htVar.bStateUpdating !== true){
_updateState();
}
}, htVar.nStateUpdateInterval);
} | update current state of pullRequest automatically
with interval timer | _setStateUpdateTimer ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.git.View.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.git.View.js | Apache-2.0 |
function _attachEvent(){
htElement.welForm.submit(_onSubmitForm);
temporarySaveHandler(htElement.welTextarea);
htElement.welTextarea.on("focus", function(){
$(window).on("beforeunload", _onBeforeUnload);
});
} | attach event handler : for validate form | _attachEvent ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.board.Write.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.board.Write.js | Apache-2.0 |
(function(ns){
var NO_CONTENT = 204;
var oNS = $yobi.createNamespace(ns);
oNS.container[oNS.name] = function(options){
var elements = {};
/**
* initialize
*/
function _init(options){
_initElement(options);
_attachEvent(options);
}
/**
* initialize element variables
*/
function _initElement(optinos){
elements.acceptChangeVCS = $("#acceptChangeVCS");
elements.btnChangeVCS = $("#btnChangeVCS");
elements.btnChangeVCSExec = $("#btnChangeVCSExec");
}
/**
* attach event handlers
*/
function _attachEvent(options){
elements.btnChangeVCS.on('click', showConfirmPopup);
elements.btnChangeVCSExec.on("click", changeVCS);
}
function showConfirmPopup() {
if(elements.acceptChangeVCS.is(":checked") === false){
$yobi.alert(Messages("project.changeVCS.alert"));
return false;
}
return true;
}
function changeVCS() {
$.ajax(options.sTransferURL, {
"method" : "post",
"success": function(res, status, xhr){
// default action below:
var location = xhr.getResponseHeader("Location");
if(xhr.status === NO_CONTENT && location){
document.location.href = location;
} else {
document.location.reload();
}
},
"error": function(){
$("#alertChangeVCS").modal("hide");
$yobi.alert(Messages("project.changeVCS.error"));
}
});
}
_init(options || {});
};
})("yobi.project.ChangeVCS"); | Yobi, Project Hosting SW
Copyright 2014 NAVER Corp.
http://yobi.io
@author Keesun Baik
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. | (anonymous) ( ns ) | javascript | yona-projects/yona | public/javascripts/service/yobi.project.ChangeVCS.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.project.ChangeVCS.js | Apache-2.0 |
function _initPagination(){
yobi.Pagination.update(htElement.welPagination, htVar.nTotalPages);
} | update Pagination
@requires yobi.Pagination | _initPagination ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.review.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.review.List.js | Apache-2.0 |
(function(ns){
var oNS = $yobi.createNamespace(ns);
oNS.container[oNS.name] = function(htOptions){
var htVar = {};
var htElement = {};
/**
* initialize
*/
function _init(htOptions){
_initVar(htOptions || {})
_initElement();
_attachEvent();
_initPagination();
}
function _initVar(htOptions) {
htVar = htOptions;
htVar.nTotalPages = htOptions.nTotalPages || 1;
}
/**
* initialize element
*/
function _initElement(){
htElement.welPagination = $(htVar.elPagination || "#pagination");
htElement.welIssueListWrap = $('.issue-list-wrap');
htElement.welSearchForm = htVar.welSearchForm;
}
/**
* attach event handlers
*/
function _attachEvent(){
htElement.welIssueListWrap.on('click','[data-toggle="filter"]', _onChangeFilter);
htElement.welIssueListWrap.on('click','[data-toggle="order"]', _onChangeOrder);
}
function _onChangeFilter(weEvent) {
weEvent.preventDefault();
var welElement = $(this);
if(welElement.data('type') === 'state') {
$("input[name='state']").val(welElement.data('value'));
} else {
var sAuthorId = (welElement.data('type') === 'authorId') ? welElement.data('value') : '';
var sParticipantId = (welElement.data('type') ==='participantId') ? welElement.data('value') : '';
$("input[name='authorId']").val(sAuthorId);
$("input[name='participantId']").val(sParticipantId);
}
htElement.welSearchForm.submit();
}
function _onChangeOrder(weEvent) {
weEvent.preventDefault();
var welElement = $(this);
var sOrderField = welElement.data('field');
var sOrderValue = welElement.data('value');
$("input[name='orderBy']").val(sOrderField);
$("input[name='orderDir']").val(sOrderValue);
htElement.welSearchForm.submit();
}
/**
* update Pagination
* @requires yobi.Pagination
*/
function _initPagination(){
yobi.Pagination.update(htElement.welPagination, htVar.nTotalPages);
}
_init(htOptions);
}
})("yobi.review.List"); | Yobi, Project Hosting SW
Copyright 2014 NAVER Corp.
http://yobi.io
@author Deokhong 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. | (anonymous) ( ns ) | javascript | yona-projects/yona | public/javascripts/service/yobi.review.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.review.List.js | Apache-2.0 |
function _onClickWriteEmail() {
// Get project names from labels in #selected-projects div.
var sMailingType = $('[name=mailingType]:checked').val();
var waProjectSpan, aProjects;
if (sMailingType == 'all') {
aProjects = {'all': 'true'}
} else {
waProjectSpan = $('#selected-projects > .label');
aProjects = [];
for (var i = 0; i < waProjectSpan.length; i++) {
aProjects.push(waProjectSpan[i].childNodes[0].nodeValue.trim());
}
}
// Send a request contains project names to get email addresses and
// launch user's mail client with them using mailto scheme.
htElement.welBtnWriteEmail.button('loading');
$yobi.sendForm({
"sURL" : htVar.sURLMailList,
"htOptForm": {"method":"POST"},
"htData" : aProjects,
"sDataType" : "json",
"fOnLoad" : function(data) {
var form = $('<form>');
var mailto = 'mailto:';
for (var i = 0; i < data.length; i++) {
mailto += data[i] + ',';
}
console.log(mailto);
form.attr('method', 'POST');
form.attr('action', mailto);
form.attr('enctype', 'text/plain');
form.submit();
htElement.welBtnWriteEmail.button('reset');
}
});
} | Launch a mail client to write an email. | _onClickWriteEmail ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
function _onClickSelectProject() {
_appendProjectLabel(htElement.welInputProject.val());
htElement.welInputProject.val("");
return false;
} | Add a project, which user types in #input-project element, into
#selected-projects div. | _onClickSelectProject ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
function _onKeyPressInputProject(oEvent) {
if (oEvent.keyCode == 13) {
_appendProjectLabel(htElement.welInputProject.val());
htElement.welInputProject.val("");
return false;
}
} | Same as _onClickSelectProject but triggered by pressing enter.
@param {Object} oEvent | _onKeyPressInputProject ( oEvent ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
function _createProjectLabel(sName) {
var fOnClickUnselect = function() {
welProject.remove();
};
var welProject = $('<span class="label label-info">' + sName + " </span>")
.css('margin-right','5px')
.append($('<a href="javascript:void(0)">x</a>')
.click(fOnClickUnselect));
return welProject;
} | Make a project label by given name.
@param {String} sName | _createProjectLabel ( sName ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
function _appendProjectLabel(sTags) {
htElement.welSelectedProjects.append(_createProjectLabel(sTags));
} | Append the given projects on #selected-projects div to show them.
@param {Object} htProjects | _appendProjectLabel ( sTags ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
(function(ns){
var oNS = $yobi.createNamespace(ns);
oNS.container[oNS.name] = function(htOptions){
var htVar = {};
var htElement = {};
/**
* initialize
*/
function _init(htOptions){
var htOpt = htOptions || {};
_initVar(htOpt);
_initElement(htOpt);
_attachEvent();
}
/**
* initialize variables
*/
function _initVar(htOptions){
htVar.sURLProjects = htOptions.sURLProjects;
htVar.sURLMailList = htOptions.sURLMailList;
}
/**
* initialize element variables
*/
function _initElement(htOptions){
// projects
htElement.welInputProject = $('#input-project');
htElement.welSelectedProjects = $('#selected-projects');
htElement.welBtnSelectProject = $('#select-project');
htElement.welBtnWriteEmail = $('#write-email');
htElement.welProjectList = $('#project-list-wrap')
}
/**
* attach event handlers
*/
function _attachEvent(){
htElement.welInputProject.keypress(_onKeyPressInputProject);
htElement.welBtnSelectProject.click(_onClickSelectProject);
htElement.welBtnWriteEmail.click(_onClickWriteEmail);
new yobi.ui.Typeahead(htElement.welInputProject, {
"sActionURL": htVar.sURLProjects
});
$('.mess-mail-wrap').on('click','[data-toggle="mail-type"]',_clickMailTypeLabel)
}
function _clickMailTypeLabel() {
var sAction = $(this).data('action');
htElement.welSelectedProjects.html("");
htElement.welProjectList[sAction]();
}
/**
* Launch a mail client to write an email.
*/
function _onClickWriteEmail() {
// Get project names from labels in #selected-projects div.
var sMailingType = $('[name=mailingType]:checked').val();
var waProjectSpan, aProjects;
if (sMailingType == 'all') {
aProjects = {'all': 'true'}
} else {
waProjectSpan = $('#selected-projects > .label');
aProjects = [];
for (var i = 0; i < waProjectSpan.length; i++) {
aProjects.push(waProjectSpan[i].childNodes[0].nodeValue.trim());
}
}
// Send a request contains project names to get email addresses and
// launch user's mail client with them using mailto scheme.
htElement.welBtnWriteEmail.button('loading');
$yobi.sendForm({
"sURL" : htVar.sURLMailList,
"htOptForm": {"method":"POST"},
"htData" : aProjects,
"sDataType" : "json",
"fOnLoad" : function(data) {
var form = $('<form>');
var mailto = 'mailto:';
for (var i = 0; i < data.length; i++) {
mailto += data[i] + ',';
}
console.log(mailto);
form.attr('method', 'POST');
form.attr('action', mailto);
form.attr('enctype', 'text/plain');
form.submit();
htElement.welBtnWriteEmail.button('reset');
}
});
}
/**
* Add a project, which user types in #input-project element, into
* #selected-projects div.
*/
function _onClickSelectProject() {
_appendProjectLabel(htElement.welInputProject.val());
htElement.welInputProject.val("");
return false;
}
/**
* Same as _onClickSelectProject but triggered by pressing enter.
*
* @param {Object} oEvent
*/
function _onKeyPressInputProject(oEvent) {
if (oEvent.keyCode == 13) {
_appendProjectLabel(htElement.welInputProject.val());
htElement.welInputProject.val("");
return false;
}
}
/**
* Make a project label by given name.
*
* @param {String} sName
*/
function _createProjectLabel(sName) {
var fOnClickUnselect = function() {
welProject.remove();
};
var welProject = $('<span class="label label-info">' + sName + " </span>")
.css('margin-right','5px')
.append($('<a href="javascript:void(0)">x</a>')
.click(fOnClickUnselect));
return welProject;
}
/**
* Append the given projects on #selected-projects div to show them.
*
* @param {Object} htProjects
*/
function _appendProjectLabel(sTags) {
htElement.welSelectedProjects.append(_createProjectLabel(sTags));
}
_init(htOptions);
};
})("yobi.site.MassMail"); | Yobi, Project Hosting SW
Copyright 2013 NAVER Corp.
http://yobi.io
@author Yi EungJun
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. | (anonymous) ( ns ) | javascript | yona-projects/yona | public/javascripts/service/yobi.site.MassMail.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.site.MassMail.js | Apache-2.0 |
(function(ns){
var oNS = $yobi.createNamespace(ns);
oNS.container[oNS.name] = function(options){
var elements = {};
/**
* Initialize
* @param options
* @private
*/
function _init(options){
_initElement(options);
_initVar(options);
_attachEvent();
}
/**
* Initialize element variables
* @param options
* @private
*/
function _initElement(options){
elements.form = $(options.form);
elements.payloadUrl = elements.form.find('input[name="payloadUrl"]');
}
/**
* Initialize variables
*
* @param options
* @private
*/
function _initVar(options) {
// Reserved for future development
}
/**
* Attach event handlers
* @private
*/
function _attachEvent(){
elements.form.on("submit", _isFormValid);
}
/**
* Returns whether is form valid
* and shows error if invalid.
*
* @returns {boolean}
* @private
*/
function _isFormValid(){
if (elements.payloadUrl.val().length === 0) {
$yobi.alert(Messages("project.webhook.payloadUrl.empty"));
return false;
}
return true;
}
_init(options || {});
};
})("yobi.project.Webhook"); | Yobi, Project Hosting SW
Copyright 2015 NAVER Corp.
http://yobi.io
@author Jihwan Chun
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. | (anonymous) ( ns ) | javascript | yona-projects/yona | public/javascripts/service/yobi.project.Webhook.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.project.Webhook.js | Apache-2.0 |
function _onChangeIssueCheckBox() {
var welCheckBox = $(this);
var welItemWrap = $('#issue-item-' + welCheckBox.data('issueId'));
if(welCheckBox.is(':checked')){
welItemWrap.addClass('active');
} else {
welItemWrap.removeClass('active');
}
} | "change" event of issue-checkbox.
Gets issueId from changed checkbox and
set highlight the issue item has same issue Id.
@private | _onChangeIssueCheckBox ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _onClickListOrder(weEvt) {
weEvt.preventDefault();
var link = $(this);
htElement.welSearchForm.find("input[name=orderBy]").val(link.attr("orderBy"));
htElement.welSearchForm.find("input[name=orderDir]").val(link.attr("orderDir"));
htElement.welSearchForm.submit();
} | "click" event handler of list order link
Fill orderBy and orderDir field value using data attribute,
and submit the search form.
@param weEvt
@private | _onClickListOrder ( weEvt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _onClickStateTab(weEvt) {
weEvt.preventDefault();
htElement.welSearchForm.find("input[name=state]").val($(this).attr("state"));
htElement.welSearchForm.submit();
} | "click" event handler of list state tab
Fill state field value using data attribute and submit the search form.
@param weEvt
@private | _onClickStateTab ( weEvt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _onClickLabelOnList(weEvt) {
weEvt.preventDefault();
var link = $(this);
var targetQuery = "[data-search=labelIds]";
var target = htElement.welSearchForm.find(targetQuery);
var labelId = link.data("labelId");
var newValue;
if(target.prop("multiple")){
newValue = (target.val() || []);
newValue.push(labelId);
} else {
newValue = labelId;
}
target.data("select2").val(newValue, true); // triggerChange=true
} | "click" event handler of labels on issue list.
Add clicked label to search form condition.
@param event
@private | _onClickLabelOnList ( weEvt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _onChangeSearchField() {
htElement.welSearchForm.submit();
} | "change" event handler of search fields.
Submit the form on change event has triggered.
@private | _onChangeSearchField ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _onClickSearchFilter(weEvt) {
weEvt.preventDefault();
var data = $(this).data();
for(var key in data){
htElement.welSearchForm.find('[data-search="' + key + '"]').val(data[key]);
}
htElement.welSearchForm.submit();
} | "click" event handler of quick search links
Find filter from data attribute and fill search form field with its value.
Submits form after fill values.
Relative pages:
- views/issue/partial_list_quicksearch.scala.html
- views/issue/my_partial_search.scala.html
@param weEvt
@private | _onClickSearchFilter ( weEvt ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _initPagination(){
yobi.Pagination.update(htElement.welPagination, htElement.welPagination.data("total"));
} | update Pagination
@requires yobi.Pagination
@private | _initPagination ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _initPjax(){
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
var isSafari = navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
// Workaround for pjax bug result from bfcache
// https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
if(isFirefox || isSafari){
return;
}
var htPjaxOptions = {
"fragment": "div[pjax-container]",
"timeout" : 3000
};
if($.support.pjax) {
$.pjax.defaults.maxCacheLength = 0;
}
// on click pagination
$(document).on("click", "a[pjax-page]", function(weEvt) {
$.pjax.click(weEvt, "div[pjax-container]", htPjaxOptions);
});
// on submit search form
$(document).on("submit", "form[name='search']", function(weEvt) {
$.pjax.submit(weEvt, "div[pjax-container]", htPjaxOptions);
});
// show spinners
$(document).on({
"pjax:send" : _onBeforeLoadIssueList,
"pjax:complete": _onLoadIssueList
});
} | Initialize Pjax
@requires jquery.pjax
@private | _initPjax ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _initSelect2(){
if(typeof yobi.ui.Select2 === "function"){
$('[data-toggle="select2"]').each(function(i, el){
yobi.ui.Select2(el);
});
}
} | Initialize ui.Select2
This function called after redraw issue list HTML using PJAX.
@private | _initSelect2 ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _initCalendar(){
if(typeof yobi.ui.Calendar === "function"){
$('[data-toggle="calendar"]').each(function(i, el){
yobi.ui.Calendar(el, {
"silent": true
});
});
}
} | Initialize ui.Calendar
This function called after redraw issue list HTML using PJAX.
@private | _initCalendar ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.List.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.List.js | Apache-2.0 |
function _appendCommentToggle(welTr, welUl) {
var welTd = $('<td colspan=3>')
.data("line", welTr.data("line"))
.data("side", welTr.data("side"))
.data("path", welTr.data("path"));
if (htVar.bCommentable) {
var welCommentBoxToggleButton = htElement.welEmptyCommentButton.clone()
.text(Messages("code.openCommentBox"))
.attr('data-toggle','commentBoxToggle')
.attr('data-type','open');
welUl.append(welCommentBoxToggleButton);
}
return $('<tr/>',{class:'comments board-comment-wrap'})
.append($('<td colspan="3">').append(welUl));
} | @param {Object} welTr
@param {Object} welUl | _appendCommentToggle ( welTr , welUl ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.SvnDiff.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.SvnDiff.js | Apache-2.0 |
function _renderDiff(sDiff) {
var rxDiff = /^Index: [\S]+\n[=]+\n/igm;
var aMatchDiff = sDiff.match(rxDiff);
var aDiffPath = sDiff.split(rxDiff).slice(1);
var rxHunkHeader = /@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/;
var rxFileHeader = /^(---|\+\+\+) (.+)\t[^\t]+$/; // http://en.wikipedia.org/wiki/Diff#Unified_format
var sPath;
aDiffPath.forEach(function(sDiffRow,nIndex){
var welDiffWrapOuter = $('<div/>',{class:'diff-partial-outer'});
var welDiffWrapInner = $('<div/>',{class:'diff-partial-inner'});
var welDiffMeta = $('<div/>',{class:'diff-partial-meta'});
var welDiffMetaCommit = $('<div/>',{class:'diff-partial-commit'});
var welDiffMetaFile = $('<div/>',{class:'diff-partial-file'});
var welDiffCodeWrap = $('<div/>',{class:'diff-partial-code'});
var welDiffCodeTable = $('<table/>',{class:'diff-container show-comments'});
var welDiffCodeTableBody = $('<tbody/>');
var aLine = sDiffRow.split('\n').slice(0,-1);
var sPath;
var nLineA=1;
var nLineB=1;
var nLastLineA=1;
var nLastLineB=1;
var nCodeLineA;
var nCodeLineB;
if(aLine[0].indexOf('file marked as a binary type') !==-1) {
var sDiffIndex = aMatchDiff[nIndex].split('\n')[0];
var welLineA = $('<td/>',{class:'linenum'}).append($('<div/>',{class:'line-number'}));
var welLineB = welLineA.clone();
sPath = sDiffIndex.substr(7);
welDiffMetaCommit.append($('<div/>',{class:'diff-partial-commit-id'}).html(" "));
welDiffMetaCommit.append(_makeCommitLink(sPath,htVar.sCommitId));
welDiffMetaFile.append($('<span/>',{class:'filename'}).text(sPath));
welDiffCodeTableBody.append(_makeCodeLine(null,null,'binary',Messages('code.isBinary')));
} else {
aLine.forEach(function(sLine){
switch(sLine.substr(0,2)) {
case '--':
case '++':
var aMatch = sLine.match(rxFileHeader);
if(aMatch === null) {
if (sLine.indexOf("---") === 0 || sLine.indexOf("+++") === 0) {
aMatch = ['', sLine.substring(0, 3), sLine.substr(4)];
} else {
return ;
}
}
if(aMatch[1]==='---') {
sPath = aMatch[2];
welDiffCodeTable.attr('data-path-a',sPath);
var welCommit = _makeCommitLink(sPath,htVar.sParentCommitId);
welDiffMetaCommit.append(welCommit);
} else if(aMatch[1]==='+++') {
sPath = aMatch[2] == "/dev/null" ? sPath : aMatch[2];
welDiffCodeTable.attr('data-path-b',sPath);
welDiffCodeTable.attr('data-file-path',sPath);
var welCommit = _makeCommitLink(sPath,htVar.sCommitId);
welDiffMetaCommit.append(welCommit);
welDiffMetaFile.append($('<span>',{class:'filename'}).text(sPath));
}
break;
case '@@' :
var aMatch = sLine.match(rxHunkHeader);
var aHunkRange = aMatch ? jQuery.map(aMatch, function(sVal) {
return parseInt(sVal, 10);
}) : null;
if (aHunkRange == null || aHunkRange.length < 4) {
if (console instanceof Object) {
console.warn("Failed to parse hunk header");
}
} else {
welDiffCodeTableBody.append(_makeCodeLine('...','...','range',sLine));
}
nLineA = aHunkRange[1];
if (isNaN(aHunkRange[2])) {
nLastLineA = nLineA + 1;
} else {
nLastLineA = nLineA + aHunkRange[2];
}
nLineB = aHunkRange[3];
if (isNaN(aHunkRange[4])) {
nLastLineB = nLineB + 1;
} else {
nLastLineB = nLineB + aHunkRange[4];
}
break;
default:
var sLineType = (sLine[0]=='+')
? 'add' : (sLine[0]=='-')
? 'remove' : 'context';
if(sLineType=='add') {
nCodeLineB= nLineB++;
nCodeLineA=null;
} else if(sLineType=='remove') {
nCodeLineB=null;
nCodeLineA = nLineA++;
} else {
nCodeLineA=nLineA++;
nCodeLineB=nLineB++;
}
var welCodeRow = _makeCodeLine(nCodeLineA,nCodeLineB,sLineType,sLine);
welDiffCodeTableBody.append(welCodeRow);
var welCodeReview = _appendCommentThreadOnLine(welCodeRow,sPath);
if(typeof welCodeReview != 'undefined') {
welDiffCodeTableBody.append(welCodeReview);
}
break;
}
});
}
welDiffMeta.append(welDiffMetaCommit);
welDiffMeta.append(welDiffMetaFile);
welDiffCodeTable.append(welDiffCodeTableBody);
welDiffCodeWrap.append(welDiffCodeTable);
welDiffWrapInner.append(welDiffMeta);
welDiffWrapInner.append(welDiffCodeWrap);
welDiffWrapOuter.append(welDiffWrapInner);
$('.diff-body').append(welDiffWrapOuter);
});
} | @param {String} sDiff
@return {Object} 렌더링한 결과로 만들어진 HTML 테이블 | _renderDiff ( sDiff ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.SvnDiff.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.SvnDiff.js | Apache-2.0 |
function _onAvatarBeforeUpload(htData){
if($yobi.isImageFile(htData.oFile) === false){
_onAvatarUploadError(Messages("user.avatar.onlyImage"));
return false;
}
} | @param {Hash Table} htData
@param {File} htData.oFile
@return {Boolean} | _onAvatarBeforeUpload ( htData ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.Setting.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.Setting.js | Apache-2.0 |
function _onAvatarUploading(weEvt, nPosition, nTotal, nPercent){
_setAvatarProgressBar(nPercent);
htElement.welAvatarProgress.css("opacity", 1);
} | @param {Wrapped Event} weEvt
@param {Number} nPosition
@param {Number} | _onAvatarUploading ( weEvt , nPosition , nTotal , nPercent ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.Setting.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.Setting.js | Apache-2.0 |
function _setAvatarProgressBar(nPercent){
nPercent = parseInt(nPercent, 10);
if(nPercent > 0){
htElement.welAvatarProgress.show();
} else {
htElement.welAvatarProgress.hide();
}
htElement.welAvatarProgressBar.css("width", nPercent + "%");
// Hide progress bar 1s after full
if(nPercent >= 100){
setTimeout(function(){
_setAvatarProgressBar(0);
}, 1000);
}
} | Set avatar image upload progress bar with given percent.
@param {Number} nPercent | _setAvatarProgressBar ( nPercent ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.Setting.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.Setting.js | Apache-2.0 |
function _showPopover(welInput, sMessage){
welInput.popover({"trigger": "manual", "placement": "right"});
var oPopover = welInput.data('popover');
oPopover.options.placement = 'right';
oPopover.options.trigger = 'manual';
oPopover.options.content = sMessage;
welInput.popover('show');
} | Bootstrap toolTip function has some limitation.
In this case, toolTip doesn't provide easy way to change title and contents.
So, unfortunately I had to change data value in directly.
@param {Wrapped Element} welInput
@param {String} sMessage | _showPopover ( welInput , sMessage ) | javascript | yona-projects/yona | public/javascripts/service/yobi.user.Setting.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.user.Setting.js | Apache-2.0 |
function _addFormField(welForm, sName, sValue) {
$('<input>').attr({
'type': 'hidden',
'name': sName,
'value': sValue
}).appendTo(welForm);
} | Add a hidden input element into the given form. | _addFormField ( welForm , sName , sValue ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _onCheckIssue(){
var waChecked = $(htVar.sIssueCheckedBoxesSelector);
var bDisabled = (waChecked.length === 0);
htElement.welMassUpdateButtons.attr('disabled', bDisabled);
if(bDisabled){
_restoreLabelList();
} else {
_makeLabelListByChecked(waChecked);
}
} | When check an issue, enable Mass Update dropdowns if only one or
more issues are checked, otherwise disable them. | _onCheckIssue ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _makeLabelListByChecked(waChecked){
var htLabels = _getLabelsByChecked(waChecked);
_restoreLabelList();
_setAttachLabelList(htLabels, waChecked.length);
_setDetachLabelList(htLabels);
} | Make label list by checked issue item
@param {Wrapped Array} waChecked | _makeLabelListByChecked ( waChecked ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _getLabelCategoryVisibility(welList, sCategory){
var welItem;
var bHidden = true;
var waCategoryItems = welList.find('li[data-category="' + sCategory +'"]');
waCategoryItems.each(function(i, el){
welItem = $(el);
if(typeof welItem.data("value") !== "undefined"){
bHidden = bHidden && (welItem.css("display") === "none");
}
});
if(bHidden){
waCategoryItems.hide();
}
return !bHidden;
} | Hide category itself if all items are invisible
@param {Wrapped Element} welList Target Label List
@param {String} sCategory CategoryName
@return {Boolean} Returns does category visible | _getLabelCategoryVisibility ( welList , sCategory ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _setDetachLabelList(htLabels){
var aHTML = [];
var sCategory, sLabelId, htLabel;
var sTpl = $("#labelListItem").text();
// Category
for(sCategory in htLabels){
aHTML.push('<li class="disabled" data-category="' + sCategory + '"><span>' + sCategory + '</span></li>');
// Label
for(sLabelId in htLabels[sCategory]){
htLabel = htLabels[sCategory][sLabelId];
aHTML.push($yobi.tmpl(sTpl, htLabel));
}
aHTML.push('<li class="divider"></li>');
}
if(aHTML.length > 0){
htElement.welDetachLabels.html(aHTML.join("\n"));
} else {
htElement.welBtnDetachingLabel.attr("disabled", true);
}
} | set DetachLabels list
make list with labels on checked issue
make detaching button disabled if no labels on checked issue
@param {Hash Table} htLabels | _setDetachLabelList ( htLabels ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _getLabelsByChecked(waChecked){
var htLabels = {};
var welCheck, sIssueLabels, aIssueLabels, aLabel;
var sCategory, sLabelId, sLabelName, sCategoryId, bExclusiveCategory;
waChecked.each(function(i, el){
welCheck = $(el);
sIssueLabels = welCheck.data("issueLabels");
if(!sIssueLabels){
return;
}
sIssueLabels.split("|").forEach(function(sLabel){
if(sLabel === ""){
return;
}
aLabel = sLabel.split(",");
sCategory = aLabel[0];
sLabelId = aLabel[1];
sLabelName = aLabel[2];
sCategoryId = aLabel[3];
bExclusiveCategory = (aLabel[4] === 'true');
htLabels[sCategory] = htLabels[sCategory] || {}; // category
htLabels[sCategory][sLabelId] = htLabels[sCategory][sLabelId] || {"id":sLabelId, "name":sLabelName, "category":sCategory, "categoryId":sCategoryId, "exclusive":bExclusiveCategory}; // label
htLabels[sCategory][sLabelId].issues = htLabels[sCategory][sLabelId].issues || []; // issues to count
htLabels[sCategory][sLabelId].issues.push(welCheck.data("issue-id"));
});
});
return htLabels;
} | Get labels by checked issue item
@param {Wrapped Array} waChecked
@return {Hash Table} | _getLabelsByChecked ( waChecked ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _onChangeUpdateField(){
var nCnt = 0;
var welForm = htElement.welMassUpdateForm;
var sItemId = _getCurrentItemIdByScrollTop();
if(sItemId){
welForm.attr("action", htVar.sActionURL + "#" + sItemId);
}
$(htVar.sIssueCheckedBoxesSelector).each(function(){
_addFormField(
welForm,
'issues[' + (nCnt++) + '].id',
$(this).data('issue-id')
);
});
welForm.submit();
} | When change the value of any field in the Mass Update form, submit
the form and request to update issues. | _onChangeUpdateField ( ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _setAttachLabelList(htLabels, nLength){
var sCategory, sLabelId, aCategoryIds;
var bVisible = false;
// Reset
htVar.htExclusiveLabels = {};
for(sCategory in htLabels){
for(sLabelId in htLabels[sCategory]){
htLabel = htLabels[sCategory][sLabelId];
if(htLabel.issues.length === nLength){
htElement.welAttachLabels.find('[data-value="' + sLabelId + '"]').hide();
}
if(htLabels[sCategory][sLabelId].exclusive){
aCategoryIds = htVar.htExclusiveLabels[htLabels[sCategory][sLabelId].categoryId] || [];
aCategoryIds.push(sLabelId);
htVar.htExclusiveLabels[htLabels[sCategory][sLabelId].categoryId] = aCategoryIds;
}
} // end-for-label
bVisible = _getLabelCategoryVisibility(htElement.welAttachLabels, sCategory) || bVisible;
} // end-for-category
htElement.welBtnAttachingLabel.attr("disabled", htLabels.hasOwnProperty() ? !bVisible : false);
}
/**
* Hide category itself if all items are invisible
*
* @param {Wrapped Element} welList Target Label List
* @param {String} sCategory CategoryName
*
* @return {Boolean} Returns does category visible
*/
function _getLabelCategoryVisibility(welList, sCategory){
var welItem;
var bHidden = true;
var waCategoryItems = welList.find('li[data-category="' + sCategory +'"]');
waCategoryItems.each(function(i, el){
welItem = $(el);
if(typeof welItem.data("value") !== "undefined"){
bHidden = bHidden && (welItem.css("display") === "none");
}
});
if(bHidden){
waCategoryItems.hide();
}
return !bHidden;
}
/**
* set DetachLabels list
* make list with labels on checked issue
* make detaching button disabled if no labels on checked issue
*
* @param {Hash Table} htLabels
*/
function _setDetachLabelList(htLabels){
var aHTML = [];
var sCategory, sLabelId, htLabel;
var sTpl = $("#labelListItem").text();
// Category
for(sCategory in htLabels){
aHTML.push('<li class="disabled" data-category="' + sCategory + '"><span>' + sCategory + '</span></li>');
// Label
for(sLabelId in htLabels[sCategory]){
htLabel = htLabels[sCategory][sLabelId];
aHTML.push($yobi.tmpl(sTpl, htLabel));
}
aHTML.push('<li class="divider"></li>');
}
if(aHTML.length > 0){
htElement.welDetachLabels.html(aHTML.join("\n"));
} else {
htElement.welBtnDetachingLabel.attr("disabled", true);
}
}
/**
* Get labels by checked issue item
*
* @param {Wrapped Array} waChecked
* @return {Hash Table}
*/
function _getLabelsByChecked(waChecked){
var htLabels = {};
var welCheck, sIssueLabels, aIssueLabels, aLabel;
var sCategory, sLabelId, sLabelName, sCategoryId, bExclusiveCategory;
waChecked.each(function(i, el){
welCheck = $(el);
sIssueLabels = welCheck.data("issueLabels");
if(!sIssueLabels){
return;
}
sIssueLabels.split("|").forEach(function(sLabel){
if(sLabel === ""){
return;
}
aLabel = sLabel.split(",");
sCategory = aLabel[0];
sLabelId = aLabel[1];
sLabelName = aLabel[2];
sCategoryId = aLabel[3];
bExclusiveCategory = (aLabel[4] === 'true');
htLabels[sCategory] = htLabels[sCategory] || {}; // category
htLabels[sCategory][sLabelId] = htLabels[sCategory][sLabelId] || {"id":sLabelId, "name":sLabelName, "category":sCategory, "categoryId":sCategoryId, "exclusive":bExclusiveCategory}; // label
htLabels[sCategory][sLabelId].issues = htLabels[sCategory][sLabelId].issues || []; // issues to count
htLabels[sCategory][sLabelId].issues.push(welCheck.data("issue-id"));
});
});
return htLabels;
}
/**
* When change the value of any field in the Mass Update form, submit
* the form and request to update issues.
*/
function _onChangeUpdateField(){
var nCnt = 0;
var welForm = htElement.welMassUpdateForm;
var sItemId = _getCurrentItemIdByScrollTop();
if(sItemId){
welForm.attr("action", htVar.sActionURL + "#" + sItemId);
}
$(htVar.sIssueCheckedBoxesSelector).each(function(){
_addFormField(
welForm,
'issues[' + (nCnt++) + '].id',
$(this).data('issue-id')
);
});
welForm.submit();
}
function _getCurrentItemIdByScrollTop(){
var nScrollTop = $(window).scrollTop();
var sItemId = $(".post-item").filter(function(i,el){
return ($(el).offset().top > nScrollTop);
}).first().prev().attr("id");
return sItemId;
}
function _setMassUpdateFormAffixed(){
$('.mass-update-wrap').affix({
offset: {top:$('.mass-update-wrap').offset().top - 15}
});
}
function _onChangeAttachingLabelField(sLabelId){
var aDetachLabels = htVar.htExclusiveLabels[htElement.welAttachLabels.find('[data-value="' + sLabelId + '"]').data('category')] || [];
for(var i = 0; i < aDetachLabels.length; i++) {
if(sLabelId !== aDetachLabels[i]){
_addFormField(
htElement.welMassUpdateForm,
htVar.detachingLabelName,
aDetachLabels[i]
);
}
}
_onChangeUpdateField.apply(this, arguments);
}
_init(htOptions);
};
})("yobi.issue.MassUpdate"); | set AttachLabels list
make list without labels on checked issue
@param {Hash Table} htLabels
@param {Number} nLength Numbers of checked issues | _setAttachLabelList ( htLabels , nLength ) | javascript | yona-projects/yona | public/javascripts/service/yobi.issue.MassUpdate.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.issue.MassUpdate.js | Apache-2.0 |
function _appendFolderList(welTarget, sTargetPath){
var sURL = _getCorrectedPath(htVar.sMetaInfoURL, sTargetPath);
var nParentDepth = welTarget.closest(".list-wrap").data("depth") || 0;
var nNewDepth = nParentDepth + 1;
_setIndentByDepth(nNewDepth);
NProgress.start();
$.ajax(sURL, {
"success": function(oRes){
if(_isListExistsByPath(sTargetPath)){
NProgress.done();
return;
}
var aHTML = _getListHTML(oRes.data, sTargetPath);
var welTargetItem = $('.listitem[data-path="' + sTargetPath + '"]');
var welList = $('<div class="list-wrap" data-listPath="' + sTargetPath + '"></div>');
welList.data("depth", nNewDepth);
welList.addClass("depth-" + nNewDepth);
welList.css("display", "none");
welList.html(aHTML);
welTargetItem.after(welList);
htVar.aWelList.push(welList);
if(htVar.aPathQueue.length > 0){
_requestFolderList();
} else {
_setCurrentPathBold(sTargetPath);
htVar.aWelList.forEach(function(welList){
welList.css("display", "block");
});
}
NProgress.done();
},
"error" : function(){
NProgress.done();
}
});
} | @param {Wrapped Element} welTarget
@param {String} sTargetPath | _appendFolderList ( welTarget , sTargetPath ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
function _isListExistsByPath(sTargetPath){
return ($('[data-listpath="' + sTargetPath + '"]').length > 0);
} | @param sTargetPath
@returns {boolean}
@private | _isListExistsByPath ( sTargetPath ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
function _getListHTML(htData, sTargetPath){
var aHTML = [];
// 폴더 먼저/ 파일 나중 순으로 만들기
var htSortedData = _getSortedList(htData);
var aProcessOrder = ["folder", "file"];
aProcessOrder.forEach(function(sType){
if(htSortedData[sType] instanceof Array){
htSortedData[sType].forEach(function(htFile){
htFile = _getFileInfoForTpl(htFile, sTargetPath);
aHTML.push($yobi.tmpl(htVar.sTplListItem, htFile));
});
}
});
return aHTML;
} | @param {Hash Table} htData
@param {String} sTargetPath
@return {Array} | _getListHTML ( htData , sTargetPath ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
function _getSortedList(htData){
var sType;
var htListByType = {};
// 타입별로 정리
for(var sFileName in htData){
htFileInfo = htData[sFileName];
htFileInfo.fileName = sFileName;
sType = htFileInfo.type;
htListByType[sType] = htListByType[sType] || [];
htListByType[sType].push(htData[sFileName]);
}
return htListByType;
} | @param {Hash Table} htData
@return {Hash Table} | _getSortedList ( htData ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
function _getFileInfoForTpl(htFile, sTargetPath){
var sAuthorURL = (htFile.userLoginId) ? '/'+ htFile.userLoginId : 'javascript:void(0); return false;';
htFile.commitDate = (typeof htFile.createdDate !=='undefined') ? (moment(new Date(htFile.createdDate)).fromNow()) : '';
htFile.fileClass = (htFile.fileName ==='..') ? 'updir' : (htFile.type === "folder" ? 'dynatree-ico-cf' : 'dynatree-ico-c');
htFile.avatarImg = (typeof htFile.avatar !== 'undefined') ? '<a href="'+ sAuthorURL + '" class="avatar-wrap smaller"><img src="' + htFile.avatar + '"></a>' : '';
htFile.commitMsg = $yobi.htmlspecialchars(htFile.msg || '');
htFile.listPath = sTargetPath;
htFile.targetPath = _getCorrectedPath(sTargetPath, htFile.fileName);
htFile.path = _getCorrectedPath(htVar.sBasePathURL, htFile.targetPath);
if(htFile.type === "folder"){
htFile.path += ("#cb-" + sTargetPath + htFile.fileName);
}
return htFile;
} | @param {Hash Table} htFile
@param {String} sTargetPath | _getFileInfoForTpl ( htFile , sTargetPath ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
function _addCSSRule(sSelector, sRule){
var elStyle = htVar.elStyle;
if(elStyle.addRule){ // Chrome, IE
elStyle.addRule(sSelector, sRule);
} else if(htVar.elStyle.insertRule){ // Firefox
elStyle.insertRule(sSelector + ' { ' + sRule + ' }', elStyle.cssRules.length);
}
} | @param {String} sSelector
@param {String} sRule | _addCSSRule ( sSelector , sRule ) | javascript | yona-projects/yona | public/javascripts/service/yobi.code.Browser.js | https://github.com/yona-projects/yona/blob/master/public/javascripts/service/yobi.code.Browser.js | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.