Skip to content

Commit

Permalink
Merge pull request #5 from VAIRIX/development
Browse files Browse the repository at this point in the history
PR development to master
  • Loading branch information
vairix-garbeletche committed Jan 18, 2016
2 parents 83bf102 + ed72b28 commit 5766f8e
Show file tree
Hide file tree
Showing 14 changed files with 844 additions and 15 deletions.
1 change: 1 addition & 0 deletions .ruby-version
@@ -0,0 +1 @@
2.0.0
2 changes: 0 additions & 2 deletions Gemfile
@@ -1,7 +1,5 @@
source 'http://rubygems.org'

ruby '2.2.1'

gem 'rails', '~> 4.1.9'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 2.5.3'
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -11,6 +11,7 @@
//= require backbone
//= require backbone.rails
//= require Markdown.Converter
//= require clipboard
//= require_tree ./templates
//= require_tree ./mixins
//= require_tree ./models
Expand Down
4 changes: 4 additions & 0 deletions app/assets/javascripts/models/story.js
Expand Up @@ -22,6 +22,10 @@ Fulcrum.Story = Backbone.Model.extend({
},

matchesSearch: function(params) {
if (params.id) {
return this.get('id').toString() === params.id;
}

var matchesTags = true;
var matchesText = true;

Expand Down
37 changes: 24 additions & 13 deletions app/assets/javascripts/views/search_view.js
Expand Up @@ -5,6 +5,7 @@ if (typeof Fulcrum == 'undefined') {
Fulcrum.SearchView = Backbone.View.extend({

TAGS_REGEX: /tags:([a-z,]*)/i,
ID_REGEX: /^\s*#([0-9]+)/,

template: JST['templates/search'],

Expand All @@ -19,12 +20,16 @@ Fulcrum.SearchView = Backbone.View.extend({
params = _.queryParams(params);
var search = '';

if (params.tags) {
search = 'tags:' + params.tags + ' ';
}
if (params.id) {
search = '#' + params.id;
} else {
if (params.tags) {
search = 'tags:' + params.tags + ' ';
}

if (params.text) {
search += params.text;
if (params.text) {
search += params.text;
}
}

that.input.val(search);
Expand All @@ -40,19 +45,25 @@ Fulcrum.SearchView = Backbone.View.extend({

search: function() {
var params = this.input.val();
var tags = this.TAGS_REGEX.exec(params);
var id = this.ID_REGEX.exec(params);
var options = {};

if (tags) {
options.tags = tags[1];
params = params.replace(tags[0], '');
}
if (id) {
options.id = id[1];
} else {
var tags = this.TAGS_REGEX.exec(params);

if (params) {
options.text = params.trim();
if (tags) {
options.tags = tags[1];
params = params.replace(tags[0], '');
}

if (params) {
options.text = params.trim();
}
}

if (params || tags) {
if (params || tags || id) {
Fulcrum.appRouter.navigate('search?' + $.param(options), {trigger: true});
} else {
Fulcrum.appRouter.navigate('/', {trigger: true});
Expand Down
42 changes: 42 additions & 0 deletions app/assets/javascripts/views/story_view.js
Expand Up @@ -212,6 +212,9 @@ Fulcrum.StoryView = Fulcrum.FormView.extend({
},

cancelEdit: function() {
if (this.clipboard)
this.clipboard.destroy();

this.model.set({editing: false});

// If the model was edited, but the edits were deemed invalid by the
Expand Down Expand Up @@ -295,6 +298,42 @@ Fulcrum.StoryView = Fulcrum.FormView.extend({
})
);

if (this.model.id) {
var that = this;

this.$el.append(
this.makeFormControl(function (div) {
var copyButton = $('<button class="id-btn">ID</button>');

that.clipboard = new Clipboard(copyButton[0], {
text: function () {
return '#' + that.model.id;
}
});

that.clipboard.on('success', function() {
copyButton.tooltip({
title: I18n.t('copied'),
placement: 'bottom',
trigger: 'manual',
delay: { show: 500 }
});

copyButton.tooltip('show');

setTimeout(function() {
copyButton.tooltip('destroy');
}, 2000);
});

$(div)
.addClass('story-id')
.append(copyButton)
.append('<span>#' + this.model.id + '</span>');
})
);
}

this.$el.append(
this.makeFormControl(function(div) {
$(div).append(this.textField("title", {
Expand Down Expand Up @@ -411,6 +450,9 @@ Fulcrum.StoryView = Fulcrum.FormView.extend({
disableForm: function() {
this.$el.find('input,select,textarea').attr('disabled', 'disabled');
this.$el.find('a.collapse,a.expand').removeClass(/icons-/).addClass('icons-throbber');

if (this.clipboard)
this.clipboard.destroy();
},

enableForm: function() {
Expand Down
21 changes: 21 additions & 0 deletions app/assets/stylesheets/screen.css.scss
Expand Up @@ -293,6 +293,27 @@ div.story-icons {
div.story-controls {
padding: 10px 0;
}

div.story-id {
background-color: #ccc;
border-radius: 2px;
border: 1px solid #828282;
margin-bottom: 8px;

.id-btn {
background-color: #5e5e5e;
border: 0;
color: white;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-right: 5px;
padding: 2px 4px;
user-select: none;
-webkit-user-select: none;
}
}

div.story-title {
margin-left: 50px;
}
Expand Down
1 change: 1 addition & 0 deletions config/locales/el.yml
Expand Up @@ -231,6 +231,7 @@ el:
rejected: απορριφθούν
delivered: παραδοθούν
search: Αναζήτηση ...
copied: Αντιγράφεται!

author unknown: "αγνωστος"
add story: "νέα ιστορία"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -21,6 +21,7 @@ en:
saving: "Saving ..."
expand: "Expand"
search: "Search..."
copied: "Copied!"

author unknown: "Author Unknown"
add story: "Add story"
Expand Down
1 change: 1 addition & 0 deletions config/locales/es.yml
Expand Up @@ -10,6 +10,7 @@ es:
import: "Importa"
export: "Exporta"
search: "Busca..."
copied: "¡Copiado!"

author unknown: "Autor desconocido"

Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Expand Up @@ -21,6 +21,7 @@ ja:
saving: "保存中…"
expand: "広げる"
search: "検索..."
copied: "コピーしました!"

author unknown: "作者不明"
add story: "ストーリー追加"
Expand Down
1 change: 1 addition & 0 deletions config/locales/nl.yml
Expand Up @@ -18,6 +18,7 @@ nl:
saving: "Opslaan ..."
expand: "Uitvouwen"
search: "Zoeken ..."
copied: "Gekopieerd!"

author unknown: "Auteur Onbekend"
add story: "Voeg verhaal toe"
Expand Down
1 change: 1 addition & 0 deletions config/locales/pt-BR.yml
Expand Up @@ -18,6 +18,7 @@ pt-BR:
saving: "Salvando ..."
expand: "Expandir"
search: "Pesquisa..."
copied: "Copiado!"

author unknown: "Autor Desconhecido"
add story: "Adicionar história"
Expand Down

0 comments on commit 5766f8e

Please sign in to comment.