forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelpCommandHandlers.js
More file actions
1 lines (1 loc) · 4.72 KB
/
HelpCommandHandlers.js
File metadata and controls
1 lines (1 loc) · 4.72 KB
1
define(function(require,exports,module){var AppInit=require("utils/AppInit"),BuildInfoUtils=require("utils/BuildInfoUtils"),CommandManager=require("command/CommandManager"),Commands=require("command/Commands"),Dialogs=require("widgets/Dialogs"),FileUtils=require("file/FileUtils"),NativeApp=require("utils/NativeApp"),Strings=require("strings"),StringUtils=require("utils/StringUtils"),AboutDialogTemplate=require("text!htmlContent/about-dialog.html"),ContributorsTemplate=require("text!htmlContent/contributors-list.html"),Mustache=require("thirdparty/mustache/mustache");require("utils/Global");var CONTRIBUTORS_PER_PAGE=100,buildInfo;function _handleLinkMenuItem(url){return function(){url&&NativeApp.openURLInDefaultBrowser(url)}}function _handleShowExtensionsFolder(){brackets.app.showExtensionsFolder(FileUtils.convertToNativePath(decodeURI(window.location.href)),function(err){})}function _handleAboutDialog(){var templateVars={ABOUT_ICON:brackets.config.about_icon,APP_NAME_ABOUT_BOX:brackets.config.app_name_about,BUILD_TIMESTAMP:brackets.config.build_timestamp,BUILD_INFO:buildInfo||"",Strings:Strings};Phoenix.pro.commitID&&(templateVars.PRO_BUILD_COMMIT=window.Phoenix.pro.commitID),Dialogs.showModalDialogUsingTemplate(Mustache.render(AboutDialogTemplate,templateVars));var $dlg=$(".about-dialog.instance"),$contributors=$dlg.find(".about-contributors"),$spinner=$dlg.find(".spinner"),contributorsUrl=brackets.config.contributors_url,page;function loadContributors(rawUrl,page,contributors,deferred){deferred=deferred||new $.Deferred,contributors=contributors||[];var url=StringUtils.format(rawUrl,CONTRIBUTORS_PER_PAGE,page);return $.ajax({url:url,dataType:"json",cache:!1}).done(function(response){contributors=contributors.concat(response||[]),page&&response.length===CONTRIBUTORS_PER_PAGE?loadContributors(rawUrl,page+1,contributors,deferred):deferred.resolve(contributors)}).fail(function(){contributors.length?deferred.resolve(contributors):deferred.reject()}),deferred.promise()}-1!==contributorsUrl.indexOf("{1}")&&(page=1),$spinner.addClass("spin"),loadContributors(contributorsUrl,page).done(function(allContributors){var totalContributors=allContributors.length,contributorsCount=0;allContributors.forEach(function(contributor){contributor.avatar_url=contributor.avatar_url.split("?")[0]}),$contributors.html(Mustache.render(ContributorsTemplate,allContributors)),$contributors.find("img").one("load",function(){$(this).css("opacity",1),++contributorsCount>=totalContributors&&$spinner.removeClass("spin")}).each(function(){this.complete&&$(this).trigger("load")})}).fail(function(){$spinner.removeClass("spin"),$contributors.html(Mustache.render("<p class='dialog-message'>{{ABOUT_TEXT_LINE6}}</p>",Strings))})}function _openLicenseLink(){brackets.config.license_url&&NativeApp.openURLInDefaultBrowser(brackets.config.license_url)}AppInit.appReady(function(){BuildInfoUtils.getBracketsSHA().done(function(branch,sha,isRepo){sha=sha?sha.substr(0,9):"",(branch||sha)&&(buildInfo=StringUtils.format("({0} {1})",branch,sha).trim())})});const getProString=`${Strings.CMD_GET_PRO}<i class='fa fa-feather' style='margin-left: 4px;'></i>`;CommandManager.register(Strings.CMD_HOW_TO_USE_BRACKETS,Commands.HELP_HOW_TO_USE_BRACKETS,_handleLinkMenuItem(brackets.config.how_to_use_url)),CommandManager.register(Strings.CMD_DOCS,Commands.HELP_DOCS,_handleLinkMenuItem(brackets.config.docs_url)),CommandManager.register(Strings.CMD_SUPPORT,Commands.HELP_SUPPORT,_handleLinkMenuItem(brackets.config.support_url)),CommandManager.register(Strings.CMD_GET_PRO,Commands.HELP_GET_PRO,_handleLinkMenuItem(brackets.config.purchase_url),{htmlName:getProString}),CommandManager.register(Strings.CMD_VIEW_LICENSE,Commands.HELP_VIEW_LICENSE,_openLicenseLink),CommandManager.register(Strings.CMD_SUGGEST,Commands.HELP_SUGGEST,_handleLinkMenuItem(brackets.config.suggest_feature_url)),CommandManager.register(Strings.CMD_REPORT_ISSUE,Commands.HELP_REPORT_ISSUE,_handleLinkMenuItem(brackets.config.report_issue_url)),CommandManager.register(Strings.CMD_RELEASE_NOTES,Commands.HELP_RELEASE_NOTES,_handleLinkMenuItem(brackets.config.release_notes_url)),CommandManager.register(Strings.CMD_GET_INVOLVED,Commands.HELP_GET_INVOLVED,_handleLinkMenuItem(brackets.config.get_involved_url)),CommandManager.register(Strings.CMD_SHOW_EXTENSIONS_FOLDER,Commands.HELP_SHOW_EXT_FOLDER,_handleShowExtensionsFolder),CommandManager.register(Strings.CMD_HOMEPAGE,Commands.HELP_HOMEPAGE,_handleLinkMenuItem(brackets.config.homepage_url)),CommandManager.register(Strings.CMD_TWITTER,Commands.HELP_TWITTER,_handleLinkMenuItem(brackets.config.twitter_url)),CommandManager.register(Strings.CMD_YOUTUBE,Commands.HELP_YOUTUBE,_handleLinkMenuItem(brackets.config.youtube_url)),CommandManager.register(Strings.CMD_ABOUT,Commands.HELP_ABOUT,_handleAboutDialog)});