{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-xray/src/components/widgets/lively-code-tip.js"],"names":["Morph","FileIndex","_","preferences","CodeTip","initialize","registerButtons","nextTipButton","style","background","cancelButton","setTitle","setupTipText","startupCheckbox","checked","get","addEventListener","updatePreferences","fa","cls","tips","tipIndex","Math","floor","random","length","generateTipText","onNextTipButton","incrementTipCounter","showOnNextStartup","lively","notify","set","onCancelButton","parentElement","remove","text","title","windowTitle","progressString","innerHTML"],"mappings":";;;;;;;AAAOA,W;;AACAC,e;;AACAC,O;;AAEAC,iB;;;;;;;;;;;AAJAH,gD;;;;;;;;;;;;;AACAC,oD;;;;;;;;;;;;;AACAC,4C;;;;;;;;;;;;;AAEAC,sD;;;;;;;AAEQ,YAAMC,OAAN,SAAsBJ,KAAtB,CAA4B;;AAEzCK,qBAAa;AACX,eAAKC,eAAL;AACA,eAAKC,aAAL,CAAmBC,KAAnB,CAAyBC,UAAzB,GAAsC,SAAtC;AACA,eAAKC,YAAL,CAAkBF,KAAlB,CAAwBC,UAAxB,GAAqC,SAArC;AACA,eAAKE,QAAL,CAAc,gBAAd;;AAEA,eAAKC,YAAL;AACA,eAAKC,eAAL,CAAqBC,OAArB,GAA+BX,YAAYY,GAAZ,CAAgB,aAAhB,CAA/B;;AAEA,eAAKF,eAAL,CAAqBG,gBAArB,CAAsC,OAAtC,EAA+C,MAAM,KAAKC,iBAAL,EAArD;AACD;;AAEDL,uBAAe;AACb,mBAASM,EAAT,CAAYC,GAAZ,EAAiB;AACf,mBAAQ,mBAAkBA,GAAI,2BAA9B;AACD;;AAED,eAAKC,IAAL,GAAY,CACV,0DADU,EAEV,sCAFU,EAGV,iHAHU,EAIV,+EAJU,EAKV,6EALU,EAMV,6FANU,EAOV,4GAPU,EAQV,4DARU,EASV,sFATU,EAUV,oGAVU,EAWV,qCAXU,EAYT,mDAAkDF,GAAG,QAAH,CAAa,kBAAiBA,GAAG,YAAH,CAAiB,8DAA6DA,GAAG,MAAH,CAAW,cAZhK,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sourcesContent":["import Morph from 'src/components/widgets/lively-morph.js';\nimport FileIndex from \"src/client/fileindex.js\";\nimport _ from 'src/external/lodash/lodash.js';\n\nimport preferences from 'src/client/preferences.js';\n\nexport default class CodeTip extends Morph {\n\n  initialize() {\n    this.registerButtons();\n    this.nextTipButton.style.background = \"#54ab5f\";\n    this.cancelButton.style.background = \"#be4441\";\n    this.setTitle(\"Tip of the Day\");\n\n    this.setupTipText();    \n    this.startupCheckbox.checked = preferences.get('TipOfTheDay');\n    \n    this.startupCheckbox.addEventListener(\"click\", () => this.updatePreferences() )\n  }\n\n  setupTipText() {\n    function fa(cls) {\n      return `<i class='fa fa-${cls}' aria-hidden='true'></i>`;\n    }\n\n    this.tips = [\n      \"With 'Alt-M' you can access a powerful refactoring menu.\",\n      \"Press 'Next Tip' to get more advice!\",\n      \"You can get a global context menu by clicking on the background or anywhere there is  not a local context menu.\",\n      \"Make your code simpler to understand with the extract method feature 'Alt+M'.\",\n      \"You can find many useful shortcuts under 'Right-click' --> 'Documentation'.\",\n      \"'that' can be used to reference the last component you used the 'halo-menu' (Alt+Click) on.\",\n      \"'Ctrl+Shift+F' opens the global text search (which allows for regular expressions and is case sensitive!).\",\n      \"This could be your tip! Add new tips in lively-code-tip.js\",\n      \"Use 'Alt+P' to switch between markdown code and its visualization in the codemirror.\",\n      \"When editing a js file, press 'F7' to open the associated HTML file (if it exists) and vice versa.\",\n      \"Press 'F8' to search files by name.\",\n      `You can fav files you frequently edit using the ${fa('star-o')} symbol (under ${fa('ellipsis-h')}) in the browser. Access them from the context menu under '${fa('star')} Favorites'.`\n    ];\n    this.tipIndex = Math.floor(Math.random() * this.tips.length);\n    this.generateTipText();\n  }\n\n  onNextTipButton() {\n    this.incrementTipCounter();\n    this.generateTipText();\n  }\n\n  incrementTipCounter() {\n    this.tipIndex = (this.tipIndex + 1) % this.tips.length;\n  }\n\n  updatePreferences() {\n    const showOnNextStartup = this.startupCheckbox.checked;\n    lively.notify(\"update preference: TipOfTheDay \" +  showOnNextStartup)\n    preferences.set('TipOfTheDay', showOnNextStartup);\n  }\n  \n  onCancelButton() {\n    this.parentElement.remove();\n  }\n\n  get startupCheckbox() {\n    return this.get(\"#startupCheckbox\");\n  }\n\n  get cancelButton() {\n    return this.get(\"#cancelButton\");\n  }\n\n  get nextTipButton() {\n    return this.get(\"#nextTipButton\");\n  }\n\n  get text() {\n    return this.get(\"#text\");\n  }\n\n  setTitle(title) {\n    this.windowTitle = title;\n  }\n\n  progressString() {\n    \n    return `Tip: ${this.tipIndex + 1} / ${this.tips.length}`;\n  }\n  \n  generateTipText() {\n    this.text.innerHTML = this.tips[this.tipIndex] + \"<br /> \" + this.progressString();\n  }\n}"]}