Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Класс для заметок
- function Note($link, $scope) {
- this.$link = $link;
- this.isOpened = false;
- this.scrollListener = this.scrollListener.bind(this);
- var self = this;
- this.$link.on("click", ".cibkpi__title-block", this.clickListener.bind(this));
- $(document).on("closeAllNotes", function (event, triggeredNote) {
- if (triggeredNote !== self && self.isOpened) {
- self.changeState();
- }
- })
- }
- Note.prototype.scrollListener = function () {
- if (this.$content[0].scrollHeight - this.$content.height() === this.$content.scrollTop() || this.$content.height() <= 120) {
- this.$fader.hide();
- } else {
- this.$fader.show();
- }
- }
- Note.prototype.clickListener = function (evt) {
- this.changeState(evt);
- $(document).trigger("closeAllNotes", this);
- }
- Note.prototype.changeState = function (event) {
- this.$content = this.$link.find(".cibkpi__note-content");
- this.$fader = this.$link.find(".cibkpi__fader");
- this.$content.scrollTop(0);
- if (event !== undefined) {
- event.preventDefault();
- event.stopPropagation();
- }
- this.isOpened = !this.isOpened;
- this.$link.find('.cibkpi__note').toggleClass('cibkpi__note--show');
- this.$link.find(".cibkpi__note-btn").toggleClass("cibkpi__note-btn--checked");
- if (this.isOpened) {
- console.log(this.$content.height());
- $scope.anyNoteOpened = true;
- this.scrollListener();
- this.$content.on("scroll", this.scrollListener);
- }
- else {
- this.$content.off("scroll", this.scrollListener);
- $scope.anyNoteOpened = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement