abcjs-rails 1.1.1 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,15 +53,43 @@ ABCJS.TuneBook = function(book) {
|
|
53
53
|
directives += line + '\n';
|
54
54
|
});
|
55
55
|
}
|
56
|
+
This.header = directives;
|
57
|
+
|
56
58
|
// Now, the tune ends at a blank line, so truncate it if needed. There may be "intertune" stuff.
|
57
59
|
window.ABCJS.parse.each(This.tunes, function(tune) {
|
58
60
|
var end = tune.abc.indexOf('\n\n');
|
59
61
|
if (end > 0)
|
60
62
|
tune.abc = tune.abc.substring(0, end);
|
63
|
+
tune.pure = tune.abc;
|
61
64
|
tune.abc = directives + tune.abc;
|
65
|
+
|
66
|
+
// for the user's convenience, parse and store the title separately. The title is between the first T: and the next \n
|
67
|
+
var title = tune.pure.split("T:");
|
68
|
+
title = title[1].split("\n");
|
69
|
+
tune.title = title[0].replace(/^\s+|\s+$/g, '');;
|
70
|
+
|
71
|
+
// for the user's convenience, parse and store the id separately. The id is between the first X: and the next \n
|
72
|
+
var id = tune.pure.substring(2,tune.pure.indexOf("\n"));
|
73
|
+
tune.id = id.replace(/^\s+|\s+$/g, '');
|
62
74
|
});
|
63
75
|
};
|
64
76
|
|
77
|
+
ABCJS.TuneBook.prototype.getTuneById = function (id) {
|
78
|
+
for (var i = 0; i < this.tunes.length; i++) {
|
79
|
+
if (this.tunes[i].id === id)
|
80
|
+
return this.tunes[i];
|
81
|
+
}
|
82
|
+
return null;
|
83
|
+
};
|
84
|
+
|
85
|
+
ABCJS.TuneBook.prototype.getTuneByTitle = function (title) {
|
86
|
+
for (var i = 0; i < this.tunes.length; i++) {
|
87
|
+
if (this.tunes[i].title === title)
|
88
|
+
return this.tunes[i];
|
89
|
+
}
|
90
|
+
return null;
|
91
|
+
};
|
92
|
+
|
65
93
|
function renderEngine(callback, output, abc, parserParams, renderParams) {
|
66
94
|
var isArray = function(testObject) {
|
67
95
|
return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
|
@@ -168,6 +168,14 @@ window.ABCJS.data.Tune = function() {
|
|
168
168
|
}
|
169
169
|
}
|
170
170
|
|
171
|
+
// Remove the temporary working variables
|
172
|
+
for (i = 0; i < this.lines.length; i++) {
|
173
|
+
if (this.lines[i].staff) {
|
174
|
+
for (s = 0; s < this.lines[i].staff.length; s++)
|
175
|
+
delete this.lines[i].staff[s].workingClef;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
171
179
|
function cleanUpSlursInLine(line) {
|
172
180
|
var currSlur = [];
|
173
181
|
var x;
|
@@ -403,11 +411,11 @@ window.ABCJS.data.Tune = function() {
|
|
403
411
|
var This = this;
|
404
412
|
var pushNote = function(hp) {
|
405
413
|
if (hp.pitches !== undefined) {
|
406
|
-
var mid = This.lines[This.lineNum].staff[This.staffNum].
|
414
|
+
var mid = This.lines[This.lineNum].staff[This.staffNum].workingClef.verticalPos;
|
407
415
|
window.ABCJS.parse.each(hp.pitches, function(p) { p.verticalPos = p.pitch - mid; });
|
408
416
|
}
|
409
417
|
if (hp.gracenotes !== undefined) {
|
410
|
-
var mid2 = This.lines[This.lineNum].staff[This.staffNum].
|
418
|
+
var mid2 = This.lines[This.lineNum].staff[This.staffNum].workingClef.verticalPos;
|
411
419
|
window.ABCJS.parse.each(hp.gracenotes, function(p) { p.verticalPos = p.pitch - mid2; });
|
412
420
|
}
|
413
421
|
This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum].push(hp);
|
@@ -477,6 +485,9 @@ window.ABCJS.data.Tune = function() {
|
|
477
485
|
|
478
486
|
this.appendStartingElement = function(type, startChar, endChar, hashParams2)
|
479
487
|
{
|
488
|
+
// If we're in the middle of beaming, then end the beam.
|
489
|
+
this.closeLine();
|
490
|
+
|
480
491
|
// We only ever want implied naturals the first time.
|
481
492
|
var impliedNaturals;
|
482
493
|
if (type === 'key') {
|
@@ -487,6 +498,12 @@ window.ABCJS.data.Tune = function() {
|
|
487
498
|
// Clone the object because it will be sticking around for the next line and we don't want the extra fields in it.
|
488
499
|
var hashParams = window.ABCJS.parse.clone(hashParams2);
|
489
500
|
|
501
|
+
// If this is a clef type, then we replace the working clef on the line. This is kept separate from
|
502
|
+
// the clef in case there is an inline clef field. We need to know what the current position for
|
503
|
+
// the note is.
|
504
|
+
if (type === 'clef')
|
505
|
+
this.lines[this.lineNum].staff[this.staffNum].workingClef = hashParams;
|
506
|
+
|
490
507
|
// These elements should not be added twice, so if the element exists on this line without a note or bar before it, just replace the staff version.
|
491
508
|
var voice = this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum];
|
492
509
|
for (var i = 0; i < voice.length; i++) {
|
@@ -607,7 +624,7 @@ window.ABCJS.data.Tune = function() {
|
|
607
624
|
This.appendElement('scale', null, null, { size: params.scale} );
|
608
625
|
};
|
609
626
|
var createStaff = function(params) {
|
610
|
-
This.lines[This.lineNum].staff[This.staffNum] = {voices: [ ], clef: params.clef, key: params.key};
|
627
|
+
This.lines[This.lineNum].staff[This.staffNum] = {voices: [ ], clef: params.clef, key: params.key, workingClef: params.clef };
|
611
628
|
if (params.vocalfont) This.lines[This.lineNum].staff[This.staffNum].vocalfont = params.vocalfont;
|
612
629
|
if (params.bracket) This.lines[This.lineNum].staff[This.staffNum].bracket = params.bracket;
|
613
630
|
if (params.brace) This.lines[This.lineNum].staff[This.staffNum].brace = params.brace;
|
@@ -683,4 +700,4 @@ window.ABCJS.data.Tune = function() {
|
|
683
700
|
this.addMetaTextObj = function(key, value) {
|
684
701
|
this.metaText[key] = value;
|
685
702
|
};
|
686
|
-
}
|
703
|
+
};
|
data/lib/abcjs-rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abcjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|