Skip to content

Commit

Permalink
implement #68 #79
Browse files Browse the repository at this point in the history
  • Loading branch information
majsan committed Jun 22, 2021
1 parent 73bfa58 commit faff967
Show file tree
Hide file tree
Showing 17 changed files with 697 additions and 501 deletions.
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ require("./scripts/services.js")
require("./scripts/extended.js")
require("./scripts/struct_services.js")
require("./scripts/directives.js")
require("./scripts/directives/scroll.js")
require("./scripts/filter_directives.js")
require("./scripts/newsdesk.js")

Expand Down
2 changes: 2 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { kwicPagerName, kwicPager } from "./components/pager"
import { sidebarName, sidebarComponent } from "./components/sidebar"
import * as autoc from "./components/autoc"
import * as readingmode from "./components/readingmode"
import * as extendedAddBox from "./components/extended/extended_add_box"
import { setDefaultConfigValues } from "./settings.js"

setDefaultConfigValues()
Expand Down Expand Up @@ -46,6 +47,7 @@ window.korpApp = angular.module("korpApp", [
korpApp.component(kwicPagerName, kwicPager).component(sidebarName, sidebarComponent)
korpApp.component(readingmode.componentName, readingmode.component)
korpApp.component(autoc.componentName, autoc.component)
korpApp.component(extendedAddBox.componentName, extendedAddBox.component)

// load all custom components (imported in index.js)
for(const componentName in window.customComponents) {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/autoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const component = {
'lexicons',
function ($q, lexicons) {
const ctrl = this

ctrl.isError = false

ctrl.$onChanges = () => {
Expand Down
68 changes: 68 additions & 0 deletions app/scripts/components/extended/extended_add_box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** @format */
export const componentName = "addBox"

let html = String.raw
export const component = {
template: html`
<div class="mt-10 mr-14 inline-block" ng-mouseleave="$ctrl.reset()">
<button ng-class="{'fade-out': $ctrl.showStuffSelectButtons}" class="btn btn-sm image_button insert_token border-gray-300 transition duration-200 hover_bg-gray-200" ng-click="$ctrl.addTokenLocal()">
<i class="fa fa-lg fa-plus-circle text-blue-600 mr-1"></i>
<span class="">{{"add_token" | loc:$root.lang}}</span>
</button>
<div class="mt-2">
<button ng-show="!$ctrl.showStuffSelectButtons" class="btn btn-sm image_button insert_token border-gray-300 transition duration-200 hover_bg-gray-200" ng-click="$ctrl.showSelectButtons()">
<i class="fa fa-lg fa-plus-circle text-orange-900 mr-1"></i>
{{ 'add_tag_box' | loc:$root.lang }}
</button>
<div class="pos-buttons" ng-class="{'fade-in': $ctrl.showStuffSelectButtons}">
<button ng-click="$ctrl.addStructTokenLocal()" class="block btn btn-sm image_button insert_token border-gray-300 transition duration-200 hover_bg-gray-200">
<i class="fa fa-arrow-left mr-1"></i>
{{ 'before_token' | loc:$root.lang }}
</button>
<button ng-click="$ctrl.addStructTokenLocal(false)" class="block btn btn-sm image_button insert_token border-gray-300 transition duration-200 hover_bg-gray-200 mt-2">
<i class="fa fa-arrow-right mr-1"></i>
{{ 'after_token' | loc:$root.lang }}
</button>
</div>
</div>
</div>
<style>
.fade-out {
transition: opacity ease-out 0.3s;
opacity: 0.5;
}
.pos-buttons {
display: none;
}
.fade-in {
display: block;
}
</style>
`,
bindings: {
addToken: "&",
addStructToken: "&",
},
controller: function AddBoxCtrl() {
const ctrl = this

ctrl.showStuffSelectButtons = false

ctrl.addTokenLocal = function() {
ctrl.addToken()
}

ctrl.showSelectButtons = function() {
ctrl.showStuffSelectButtons = true
}

ctrl.addStructTokenLocal = function (start = true) {
ctrl.reset()
ctrl.addStructToken({ start })
}

ctrl.reset = function () {
ctrl.showStuffSelectButtons = false
}
},
}
4 changes: 2 additions & 2 deletions app/scripts/components/pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export const kwicPager = {
rotate="false"
></ul>
<div class="page_input">
<span>{{'goto_page' | loc:lang}} </span>
<span>{{'goto_page' | loc:$root.lang}} </span>
<input
ng-model="$ctrl.gotoPage"
ng-keyup="$ctrl.onPageInput($event)"
ng-click="$event.stopPropagation()"
/>
{{'of' | loc:lang}} {{$ctrl.numPages}}
{{'of' | loc:$root.lang}} {{$ctrl.numPages}}
</div>
</div>
`,
Expand Down
Loading

0 comments on commit faff967

Please sign in to comment.