Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c9788bd9
Commit
c9788bd9
authored
May 06, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove jasmine-fixture, use teaspoon fixtures
parent
73440b03
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
491 deletions
+64
-491
spec/javascripts/fixtures/issuable.html.haml
spec/javascripts/fixtures/issuable.html.haml
+2
-0
spec/javascripts/fixtures/issue_note.html.haml
spec/javascripts/fixtures/issue_note.html.haml
+12
-0
spec/javascripts/fixtures/issues_show.html.haml
spec/javascripts/fixtures/issues_show.html.haml
+13
-0
spec/javascripts/fixtures/merge_requests_show.html.haml
spec/javascripts/fixtures/merge_requests_show.html.haml
+13
-0
spec/javascripts/issue_spec.js.coffee
spec/javascripts/issue_spec.js.coffee
+6
-21
spec/javascripts/merge_request_spec.js.coffee
spec/javascripts/merge_request_spec.js.coffee
+8
-21
spec/javascripts/notes_spec.js.coffee
spec/javascripts/notes_spec.js.coffee
+7
-12
spec/javascripts/shortcuts_issuable_spec.js.coffee
spec/javascripts/shortcuts_issuable_spec.js.coffee
+3
-4
vendor/assets/javascripts/jasmine-fixture.js
vendor/assets/javascripts/jasmine-fixture.js
+0
-433
No files found.
spec/javascripts/fixtures/issuable.html.haml
0 → 100644
View file @
c9788bd9
%form
.js-main-target-form
%textarea
#note_note
spec/javascripts/fixtures/issue_note.html.haml
0 → 100644
View file @
c9788bd9
%ul
%li
.note
.js-task-list-container
.note-text
%ul
.task-list
%li
.task-list-item
%input
.task-list-item-checkbox
{
type:
'checkbox'
}
Task List Item
.note-edit-form
%form
%textarea
.js-task-list-field
\- [ ] Task List Item
spec/javascripts/fixtures/issues_show.html.haml
0 → 100644
View file @
c9788bd9
%a
.btn-close
.issue-details
.description.js-task-list-container
.wiki
%ul
.task-list
%li
.task-list-item
%input
.task-list-item-checkbox
{
type:
'checkbox'
}
Task List Item
%textarea
.js-task-list-field
\- [ ] Task List Item
%form
.js-issue-update
{
action:
'/foo'
}
spec/javascripts/fixtures/merge_requests_show.html.haml
0 → 100644
View file @
c9788bd9
%a
.btn-close
.merge-request-details
.description.js-task-list-container
.wiki
%ul
.task-list
%li
.task-list-item
%input
.task-list-item-checkbox
{
type:
'checkbox'
}
Task List Item
%textarea
.js-task-list-field
\- [ ] Task List Item
%form
.js-merge-request-update
{
action:
'/foo'
}
spec/javascripts/issue_spec.js.coffee
View file @
c9788bd9
#= require jquery
#= require jasmine-fixture
#= require issue
#= require issue
describe
'Issue'
,
->
describe
'Issue'
,
->
describe
'task lists'
,
->
describe
'task lists'
,
->
selectors
=
{
fixture
.
preload
(
'issues_show.html'
)
container
:
'.issue-details .description.js-task-list-container'
item
:
'.wiki ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
textarea
:
'.wiki textarea.js-task-list-field{- [ ] Task List Item}'
form
:
'form.js-issue-update[action="/foo"]'
close
:
'a.btn-close'
}
beforeEach
->
beforeEach
->
$container
=
affix
(
selectors
.
container
)
fixture
.
load
(
'issues_show.html'
)
# # These two elements are siblings inside the container
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
item
))
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
textarea
))
# Task lists don't get initialized unless this button exists. Not ideal.
$container
.
append
(
affix
(
selectors
.
close
))
# This form is used to get the `update` URL. Not ideal.
$container
.
append
(
affix
(
selectors
.
form
))
@
issue
=
new
Issue
()
@
issue
=
new
Issue
()
it
'modifies the Markdown field'
,
->
$
(
'input[type=checkbox]'
).
attr
(
'checked'
,
true
).
trigger
(
'change'
)
expect
(
$
(
'.js-task-list-field'
).
val
()).
toBe
(
'- [x] Task List Item'
)
it
'submits an ajax request on tasklist:changed'
,
->
it
'submits an ajax request on tasklist:changed'
,
->
spyOn
(
$
,
'ajax'
).
and
.
callFake
(
req
)
->
spyOn
(
$
,
'ajax'
).
and
.
callFake
(
req
)
->
expect
(
req
.
type
).
toBe
(
'PATCH'
)
expect
(
req
.
type
).
toBe
(
'PATCH'
)
...
...
spec/javascripts/merge_request_spec.js.coffee
View file @
c9788bd9
#= require jquery
#= require jasmine-fixture
#= require merge_request
#= require merge_request
window
.
disableButtonIfEmptyField
=
->
null
describe
'MergeRequest'
,
->
describe
'MergeRequest'
,
->
describe
'task lists'
,
->
describe
'task lists'
,
->
selectors
=
{
fixture
.
preload
(
'merge_requests_show.html'
)
container
:
'.merge-request-details .description.js-task-list-container'
item
:
'.wiki ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
textarea
:
'.wiki textarea.js-task-list-field{- [ ] Task List Item}'
form
:
'form.js-merge-request-update[action="/foo"]'
close
:
'a.btn-close'
}
beforeEach
->
beforeEach
->
$container
=
affix
(
selectors
.
container
)
fixture
.
load
(
'merge_requests_show.html'
)
# # These two elements are siblings inside the container
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
item
))
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
textarea
))
# Task lists don't get initialized unless this button exists. Not ideal.
$container
.
append
(
affix
(
selectors
.
close
))
# This form is used to get the `update` URL. Not ideal.
$container
.
append
(
affix
(
selectors
.
form
))
@
merge
=
new
MergeRequest
({})
@
merge
=
new
MergeRequest
({})
it
'modifies the Markdown field'
,
->
$
(
'input[type=checkbox]'
).
attr
(
'checked'
,
true
).
trigger
(
'change'
)
expect
(
$
(
'.js-task-list-field'
).
val
()).
toBe
(
'- [x] Task List Item'
)
it
'submits an ajax request on tasklist:changed'
,
->
it
'submits an ajax request on tasklist:changed'
,
->
spyOn
(
$
,
'ajax'
).
and
.
callFake
(
req
)
->
spyOn
(
$
,
'ajax'
).
and
.
callFake
(
req
)
->
expect
(
req
.
type
).
toBe
(
'PATCH'
)
expect
(
req
.
type
).
toBe
(
'PATCH'
)
...
...
spec/javascripts/notes_spec.js.coffee
View file @
c9788bd9
#= require jquery
#= require jasmine-fixture
#= require notes
#= require notes
window
.
gon
=
{}
window
.
gon
=
{}
...
@@ -7,21 +5,18 @@ window.disableButtonIfEmptyField = -> null
...
@@ -7,21 +5,18 @@ window.disableButtonIfEmptyField = -> null
describe
'Notes'
,
->
describe
'Notes'
,
->
describe
'task lists'
,
->
describe
'task lists'
,
->
selectors
=
{
fixture
.
preload
(
'issue_note.html'
)
container
:
'li.note .js-task-list-container'
item
:
'.note-text ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
textarea
:
'.note-edit-form form textarea.js-task-list-field{- [ ] Task List Item}'
}
beforeEach
->
beforeEach
->
$container
=
affix
(
selectors
.
container
)
fixture
.
load
(
'issue_note.html'
)
$
(
'form'
).
on
'submit'
,
(
e
)
->
e
.
preventDefault
()
# These two elements are siblings inside the container
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
item
))
$container
.
find
(
'.js-task-list-container'
).
append
(
affix
(
selectors
.
textarea
))
@
notes
=
new
Notes
()
@
notes
=
new
Notes
()
it
'modifies the Markdown field'
,
->
$
(
'input[type=checkbox]'
).
attr
(
'checked'
,
true
).
trigger
(
'change'
)
expect
(
$
(
'.js-task-list-field'
).
val
()).
toBe
(
'- [x] Task List Item'
)
it
'submits the form on tasklist:changed'
,
->
it
'submits the form on tasklist:changed'
,
->
submitted
=
false
submitted
=
false
$
(
'form'
).
on
'submit'
,
(
e
)
->
submitted
=
true
;
e
.
preventDefault
()
$
(
'form'
).
on
'submit'
,
(
e
)
->
submitted
=
true
;
e
.
preventDefault
()
...
...
spec/javascripts/shortcuts_issuable_spec.js.coffee
View file @
c9788bd9
#= require jquery
#= require jasmine-fixture
#= require shortcuts_issuable
#= require shortcuts_issuable
describe
'ShortcutsIssuable'
,
->
describe
'ShortcutsIssuable'
,
->
fixture
.
preload
(
'issuable.html'
)
beforeEach
->
beforeEach
->
fixture
.
load
(
'issuable.html'
)
@
shortcut
=
new
ShortcutsIssuable
()
@
shortcut
=
new
ShortcutsIssuable
()
describe
'#replyWithSelectedText'
,
->
describe
'#replyWithSelectedText'
,
->
...
@@ -14,7 +14,6 @@ describe 'ShortcutsIssuable', ->
...
@@ -14,7 +14,6 @@ describe 'ShortcutsIssuable', ->
beforeEach
->
beforeEach
->
@
selector
=
'form.js-main-target-form textarea#note_note'
@
selector
=
'form.js-main-target-form textarea#note_note'
affix
(
@
selector
)
describe
'with empty selection'
,
->
describe
'with empty selection'
,
->
it
'does nothing'
,
->
it
'does nothing'
,
->
...
...
vendor/assets/javascripts/jasmine-fixture.js
deleted
100755 → 0
View file @
73440b03
/* jasmine-fixture - 1.3.1
* Makes injecting HTML snippets into the DOM easy & clean!
* https://github.com/searls/jasmine-fixture
*/
(
function
()
{
var
createHTMLBlock
,
__slice
=
[].
slice
;
(
function
(
$
)
{
var
ewwSideEffects
,
jasmineFixture
,
originalAffix
,
originalJasmineDotFixture
,
originalJasmineFixture
,
root
,
_
,
_ref
;
root
=
(
1
,
eval
)(
'
this
'
);
originalJasmineFixture
=
root
.
jasmineFixture
;
originalJasmineDotFixture
=
(
_ref
=
root
.
jasmine
)
!=
null
?
_ref
.
fixture
:
void
0
;
originalAffix
=
root
.
affix
;
_
=
function
(
list
)
{
return
{
inject
:
function
(
iterator
,
memo
)
{
var
item
,
_i
,
_len
,
_results
;
_results
=
[];
for
(
_i
=
0
,
_len
=
list
.
length
;
_i
<
_len
;
_i
++
)
{
item
=
list
[
_i
];
_results
.
push
(
memo
=
iterator
(
memo
,
item
));
}
return
_results
;
}
};
};
root
.
jasmineFixture
=
function
(
$
)
{
var
$whatsTheRootOf
,
affix
,
create
,
jasmineFixture
,
noConflict
;
affix
=
function
(
selectorOptions
)
{
return
create
.
call
(
this
,
selectorOptions
,
true
);
};
create
=
function
(
selectorOptions
,
attach
)
{
var
$top
;
$top
=
null
;
_
(
selectorOptions
.
split
(
/
[
](?![^\{]
*
\})(?=[^\]]
*
?(?:\[
|$
))
/
)).
inject
(
function
(
$parent
,
elementSelector
)
{
var
$el
;
if
(
elementSelector
===
"
>
"
)
{
return
$parent
;
}
$el
=
createHTMLBlock
(
$
,
elementSelector
);
if
(
attach
||
$top
)
{
$el
.
appendTo
(
$parent
);
}
$top
||
(
$top
=
$el
);
return
$el
;
},
$whatsTheRootOf
(
this
));
return
$top
;
};
noConflict
=
function
()
{
var
currentJasmineFixture
,
_ref1
;
currentJasmineFixture
=
jasmine
.
fixture
;
root
.
jasmineFixture
=
originalJasmineFixture
;
if
((
_ref1
=
root
.
jasmine
)
!=
null
)
{
_ref1
.
fixture
=
originalJasmineDotFixture
;
}
root
.
affix
=
originalAffix
;
return
currentJasmineFixture
;
};
$whatsTheRootOf
=
function
(
that
)
{
if
(
that
.
jquery
!=
null
)
{
return
that
;
}
else
if
(
$
(
'
#jasmine_content
'
).
length
>
0
)
{
return
$
(
'
#jasmine_content
'
);
}
else
{
return
$
(
'
<div id="jasmine_content"></div>
'
).
appendTo
(
'
body
'
);
}
};
jasmineFixture
=
{
affix
:
affix
,
create
:
create
,
noConflict
:
noConflict
};
ewwSideEffects
(
jasmineFixture
);
return
jasmineFixture
;
};
ewwSideEffects
=
function
(
jasmineFixture
)
{
var
_ref1
;
if
((
_ref1
=
root
.
jasmine
)
!=
null
)
{
_ref1
.
fixture
=
jasmineFixture
;
}
$
.
fn
.
affix
=
root
.
affix
=
jasmineFixture
.
affix
;
return
afterEach
(
function
()
{
return
$
(
'
#jasmine_content
'
).
remove
();
});
};
if
(
$
)
{
return
jasmineFixture
=
root
.
jasmineFixture
(
$
);
}
else
{
return
root
.
affix
=
function
()
{
var
nowJQueryExists
;
nowJQueryExists
=
window
.
jQuery
||
window
.
$
;
if
(
nowJQueryExists
!=
null
)
{
jasmineFixture
=
root
.
jasmineFixture
(
nowJQueryExists
);
return
affix
.
call
.
apply
(
affix
,
[
this
].
concat
(
__slice
.
call
(
arguments
)));
}
else
{
throw
new
Error
(
"
jasmine-fixture requires jQuery to be defined at window.jQuery or window.$
"
);
}
};
}
})(
window
.
jQuery
||
window
.
$
);
createHTMLBlock
=
(
function
()
{
var
bindData
,
bindEvents
,
parseAttributes
,
parseClasses
,
parseContents
,
parseEnclosure
,
parseReferences
,
parseVariableScope
,
regAttr
,
regAttrDfn
,
regAttrs
,
regCBrace
,
regClass
,
regClasses
,
regData
,
regDatas
,
regEvent
,
regEvents
,
regExclamation
,
regId
,
regReference
,
regTag
,
regTagNotContent
,
regZenTagDfn
;
createHTMLBlock
=
function
(
$
,
ZenObject
,
data
,
functions
,
indexes
)
{
var
ZenCode
,
arr
,
block
,
blockAttrs
,
blockClasses
,
blockHTML
,
blockId
,
blockTag
,
blocks
,
el
,
el2
,
els
,
forScope
,
indexName
,
inner
,
len
,
obj
,
origZenCode
,
paren
,
result
,
ret
,
zc
,
zo
;
if
(
$
.
isPlainObject
(
ZenObject
))
{
ZenCode
=
ZenObject
.
main
;
}
else
{
ZenCode
=
ZenObject
;
ZenObject
=
{
main
:
ZenCode
};
}
origZenCode
=
ZenCode
;
if
(
indexes
===
undefined
)
{
indexes
=
{};
}
if
(
ZenCode
.
charAt
(
0
)
===
"
!
"
||
$
.
isArray
(
data
))
{
if
(
$
.
isArray
(
data
))
{
forScope
=
ZenCode
;
}
else
{
obj
=
parseEnclosure
(
ZenCode
,
"
!
"
);
obj
=
obj
.
substring
(
obj
.
indexOf
(
"
:
"
)
+
1
,
obj
.
length
-
1
);
forScope
=
parseVariableScope
(
ZenCode
);
}
while
(
forScope
.
charAt
(
0
)
===
"
@
"
)
{
forScope
=
parseVariableScope
(
"
!for:!
"
+
parseReferences
(
forScope
,
ZenObject
));
}
zo
=
ZenObject
;
zo
.
main
=
forScope
;
el
=
$
();
if
(
ZenCode
.
substring
(
0
,
5
)
===
"
!for:
"
||
$
.
isArray
(
data
))
{
if
(
!
$
.
isArray
(
data
)
&&
obj
.
indexOf
(
"
:
"
)
>
0
)
{
indexName
=
obj
.
substring
(
0
,
obj
.
indexOf
(
"
:
"
));
obj
=
obj
.
substr
(
obj
.
indexOf
(
"
:
"
)
+
1
);
}
arr
=
(
$
.
isArray
(
data
)
?
data
:
data
[
obj
]);
zc
=
zo
.
main
;
if
(
$
.
isArray
(
arr
)
||
$
.
isPlainObject
(
arr
))
{
$
.
map
(
arr
,
function
(
value
,
index
)
{
var
next
;
zo
.
main
=
zc
;
if
(
indexName
!==
undefined
)
{
indexes
[
indexName
]
=
index
;
}
if
(
!
$
.
isPlainObject
(
value
))
{
value
=
{
value
:
value
};
}
next
=
createHTMLBlock
(
$
,
zo
,
value
,
functions
,
indexes
);
if
(
el
.
length
!==
0
)
{
return
$
.
each
(
next
,
function
(
index
,
value
)
{
return
el
.
push
(
value
);
});
}
});
}
if
(
!
$
.
isArray
(
data
))
{
ZenCode
=
ZenCode
.
substr
(
obj
.
length
+
6
+
forScope
.
length
);
}
else
{
ZenCode
=
""
;
}
}
else
if
(
ZenCode
.
substring
(
0
,
4
)
===
"
!if:
"
)
{
result
=
parseContents
(
"
!
"
+
obj
+
"
!
"
,
data
,
indexes
);
if
(
result
!==
"
undefined
"
||
result
!==
"
false
"
||
result
!==
""
)
{
el
=
createHTMLBlock
(
$
,
zo
,
data
,
functions
,
indexes
);
}
ZenCode
=
ZenCode
.
substr
(
obj
.
length
+
5
+
forScope
.
length
);
}
ZenObject
.
main
=
ZenCode
;
}
else
if
(
ZenCode
.
charAt
(
0
)
===
"
(
"
)
{
paren
=
parseEnclosure
(
ZenCode
,
"
(
"
,
"
)
"
);
inner
=
paren
.
substring
(
1
,
paren
.
length
-
1
);
ZenCode
=
ZenCode
.
substr
(
paren
.
length
);
zo
=
ZenObject
;
zo
.
main
=
inner
;
el
=
createHTMLBlock
(
$
,
zo
,
data
,
functions
,
indexes
);
}
else
{
blocks
=
ZenCode
.
match
(
regZenTagDfn
);
block
=
blocks
[
0
];
if
(
block
.
length
===
0
)
{
return
""
;
}
if
(
block
.
indexOf
(
"
@
"
)
>=
0
)
{
ZenCode
=
parseReferences
(
ZenCode
,
ZenObject
);
zo
=
ZenObject
;
zo
.
main
=
ZenCode
;
return
createHTMLBlock
(
$
,
zo
,
data
,
functions
,
indexes
);
}
block
=
parseContents
(
block
,
data
,
indexes
);
blockClasses
=
parseClasses
(
$
,
block
);
if
(
regId
.
test
(
block
))
{
blockId
=
regId
.
exec
(
block
)[
1
];
}
blockAttrs
=
parseAttributes
(
block
,
data
);
blockTag
=
(
block
.
charAt
(
0
)
===
"
{
"
?
"
span
"
:
"
div
"
);
if
(
ZenCode
.
charAt
(
0
)
!==
"
#
"
&&
ZenCode
.
charAt
(
0
)
!==
"
.
"
&&
ZenCode
.
charAt
(
0
)
!==
"
{
"
)
{
blockTag
=
regTag
.
exec
(
block
)[
1
];
}
if
(
block
.
search
(
regCBrace
)
!==
-
1
)
{
blockHTML
=
block
.
match
(
regCBrace
)[
1
];
}
blockAttrs
=
$
.
extend
(
blockAttrs
,
{
id
:
blockId
,
"
class
"
:
blockClasses
,
html
:
blockHTML
});
el
=
$
(
"
<
"
+
blockTag
+
"
>
"
,
blockAttrs
);
el
.
attr
(
blockAttrs
);
el
=
bindEvents
(
block
,
el
,
functions
);
el
=
bindData
(
block
,
el
,
data
);
ZenCode
=
ZenCode
.
substr
(
blocks
[
0
].
length
);
ZenObject
.
main
=
ZenCode
;
}
if
(
ZenCode
.
length
>
0
)
{
if
(
ZenCode
.
charAt
(
0
)
===
"
>
"
)
{
if
(
ZenCode
.
charAt
(
1
)
===
"
(
"
)
{
zc
=
parseEnclosure
(
ZenCode
.
substr
(
1
),
"
(
"
,
"
)
"
);
ZenCode
=
ZenCode
.
substr
(
zc
.
length
+
1
);
}
else
if
(
ZenCode
.
charAt
(
1
)
===
"
!
"
)
{
obj
=
parseEnclosure
(
ZenCode
.
substr
(
1
),
"
!
"
);
forScope
=
parseVariableScope
(
ZenCode
.
substr
(
1
));
zc
=
obj
+
forScope
;
ZenCode
=
ZenCode
.
substr
(
zc
.
length
+
1
);
}
else
{
len
=
Math
.
max
(
ZenCode
.
indexOf
(
"
+
"
),
ZenCode
.
length
);
zc
=
ZenCode
.
substring
(
1
,
len
);
ZenCode
=
ZenCode
.
substr
(
len
);
}
zo
=
ZenObject
;
zo
.
main
=
zc
;
els
=
$
(
createHTMLBlock
(
$
,
zo
,
data
,
functions
,
indexes
));
els
.
appendTo
(
el
);
}
if
(
ZenCode
.
charAt
(
0
)
===
"
+
"
)
{
zo
=
ZenObject
;
zo
.
main
=
ZenCode
.
substr
(
1
);
el2
=
createHTMLBlock
(
$
,
zo
,
data
,
functions
,
indexes
);
$
.
each
(
el2
,
function
(
index
,
value
)
{
return
el
.
push
(
value
);
});
}
}
ret
=
el
;
return
ret
;
};
bindData
=
function
(
ZenCode
,
el
,
data
)
{
var
datas
,
i
,
split
;
if
(
ZenCode
.
search
(
regDatas
)
===
0
)
{
return
el
;
}
datas
=
ZenCode
.
match
(
regDatas
);
if
(
datas
===
null
)
{
return
el
;
}
i
=
0
;
while
(
i
<
datas
.
length
)
{
split
=
regData
.
exec
(
datas
[
i
]);
if
(
split
[
3
]
===
undefined
)
{
$
(
el
).
data
(
split
[
1
],
data
[
split
[
1
]]);
}
else
{
$
(
el
).
data
(
split
[
1
],
data
[
split
[
3
]]);
}
i
++
;
}
return
el
;
};
bindEvents
=
function
(
ZenCode
,
el
,
functions
)
{
var
bindings
,
fn
,
i
,
split
;
if
(
ZenCode
.
search
(
regEvents
)
===
0
)
{
return
el
;
}
bindings
=
ZenCode
.
match
(
regEvents
);
if
(
bindings
===
null
)
{
return
el
;
}
i
=
0
;
while
(
i
<
bindings
.
length
)
{
split
=
regEvent
.
exec
(
bindings
[
i
]);
if
(
split
[
2
]
===
undefined
)
{
fn
=
functions
[
split
[
1
]];
}
else
{
fn
=
functions
[
split
[
2
]];
}
$
(
el
).
bind
(
split
[
1
],
fn
);
i
++
;
}
return
el
;
};
parseAttributes
=
function
(
ZenBlock
,
data
)
{
var
attrStrs
,
attrs
,
i
,
parts
;
if
(
ZenBlock
.
search
(
regAttrDfn
)
===
-
1
)
{
return
undefined
;
}
attrStrs
=
ZenBlock
.
match
(
regAttrDfn
);
attrs
=
{};
i
=
0
;
while
(
i
<
attrStrs
.
length
)
{
parts
=
regAttr
.
exec
(
attrStrs
[
i
]);
attrs
[
parts
[
1
]]
=
""
;
if
(
parts
[
3
]
!==
undefined
)
{
attrs
[
parts
[
1
]]
=
parseContents
(
parts
[
3
],
data
);
}
i
++
;
}
return
attrs
;
};
parseClasses
=
function
(
$
,
ZenBlock
)
{
var
classes
,
clsString
,
i
;
ZenBlock
=
ZenBlock
.
match
(
regTagNotContent
)[
0
];
if
(
ZenBlock
.
search
(
regClasses
)
===
-
1
)
{
return
undefined
;
}
classes
=
ZenBlock
.
match
(
regClasses
);
clsString
=
""
;
i
=
0
;
while
(
i
<
classes
.
length
)
{
clsString
+=
"
"
+
regClass
.
exec
(
classes
[
i
])[
1
];
i
++
;
}
return
$
.
trim
(
clsString
);
};
parseContents
=
function
(
ZenBlock
,
data
,
indexes
)
{
var
html
;
if
(
indexes
===
undefined
)
{
indexes
=
{};
}
html
=
ZenBlock
;
if
(
data
===
undefined
)
{
return
html
;
}
while
(
regExclamation
.
test
(
html
))
{
html
=
html
.
replace
(
regExclamation
,
function
(
str
,
str2
)
{
var
begChar
,
fn
,
val
;
begChar
=
""
;
if
(
str
.
indexOf
(
"
!for:
"
)
>
0
||
str
.
indexOf
(
"
!if:
"
)
>
0
)
{
return
str
;
}
if
(
str
.
charAt
(
0
)
!==
"
!
"
)
{
begChar
=
str
.
charAt
(
0
);
str
=
str
.
substring
(
2
,
str
.
length
-
1
);
}
fn
=
new
Function
(
"
data
"
,
"
indexes
"
,
"
var r=undefined;
"
+
"
with(data){try{r=
"
+
str
+
"
;}catch(e){}}
"
+
"
with(indexes){try{if(r===undefined)r=
"
+
str
+
"
;}catch(e){}}
"
+
"
return r;
"
);
val
=
unescape
(
fn
(
data
,
indexes
));
return
begChar
+
val
;
});
}
html
=
html
.
replace
(
/
\\
./g
,
function
(
str
)
{
return
str
.
charAt
(
1
);
});
return
unescape
(
html
);
};
parseEnclosure
=
function
(
ZenCode
,
open
,
close
,
count
)
{
var
index
,
ret
;
if
(
close
===
undefined
)
{
close
=
open
;
}
index
=
1
;
if
(
count
===
undefined
)
{
count
=
(
ZenCode
.
charAt
(
0
)
===
open
?
1
:
0
);
}
if
(
count
===
0
)
{
return
;
}
while
(
count
>
0
&&
index
<
ZenCode
.
length
)
{
if
(
ZenCode
.
charAt
(
index
)
===
close
&&
ZenCode
.
charAt
(
index
-
1
)
!==
"
\\
"
)
{
count
--
;
}
else
{
if
(
ZenCode
.
charAt
(
index
)
===
open
&&
ZenCode
.
charAt
(
index
-
1
)
!==
"
\\
"
)
{
count
++
;
}
}
index
++
;
}
ret
=
ZenCode
.
substring
(
0
,
index
);
return
ret
;
};
parseReferences
=
function
(
ZenCode
,
ZenObject
)
{
ZenCode
=
ZenCode
.
replace
(
regReference
,
function
(
str
)
{
var
fn
;
str
=
str
.
substr
(
1
);
fn
=
new
Function
(
"
objs
"
,
"
var r=
\"\"
;
"
+
"
with(objs){try{
"
+
"
r=
"
+
str
+
"
;
"
+
"
}catch(e){}}
"
+
"
return r;
"
);
return
fn
(
ZenObject
,
parseReferences
);
});
return
ZenCode
;
};
parseVariableScope
=
function
(
ZenCode
)
{
var
forCode
,
rest
,
tag
;
if
(
ZenCode
.
substring
(
0
,
5
)
!==
"
!for:
"
&&
ZenCode
.
substring
(
0
,
4
)
!==
"
!if:
"
)
{
return
undefined
;
}
forCode
=
parseEnclosure
(
ZenCode
,
"
!
"
);
ZenCode
=
ZenCode
.
substr
(
forCode
.
length
);
if
(
ZenCode
.
charAt
(
0
)
===
"
(
"
)
{
return
parseEnclosure
(
ZenCode
,
"
(
"
,
"
)
"
);
}
tag
=
ZenCode
.
match
(
regZenTagDfn
)[
0
];
ZenCode
=
ZenCode
.
substr
(
tag
.
length
);
if
(
ZenCode
.
length
===
0
||
ZenCode
.
charAt
(
0
)
===
"
+
"
)
{
return
tag
;
}
else
if
(
ZenCode
.
charAt
(
0
)
===
"
>
"
)
{
rest
=
""
;
rest
=
parseEnclosure
(
ZenCode
.
substr
(
1
),
"
(
"
,
"
)
"
,
1
);
return
tag
+
"
>
"
+
rest
;
}
return
undefined
;
};
regZenTagDfn
=
/
([
#
\.\@]?[\w
-
]
+|
\[([\w
-!?=:"'
]
+
(
="
([^
"
]
|
\\
"
)
+"
)?
{0,})
+
\]
|
\~[\w
$
]
+=
[\w
$
]
+|&
[\w
$
]
+
(
=
[\w
$
]
+
)?
|
[
#
\.\@]?
!
([^
!
]
|
\\
!
)
+!
){0,}(\{([^\}]
|
\\\})
+
\})?
/i
;
regTag
=
/
(\w
+
)
/i
;
regId
=
/
(?:
^|
\b)
#
([\w
-!
]
+
)
/i
;
regTagNotContent
=
/
((([
#
\.]?[\w
-
]
+
)?(\[([\w
!
]
+
(
="
([^
"
]
|
\\
"
)
+"
)?
{0,})
+
\])?)
+
)
/i
;
/*
See lookahead syntax (?!) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
*/
regClasses
=
/
(\.[\w
-
]
+
)(?![
"
\w])
/g
;
regClass
=
/
\.([\w
-
]
+
)
/i
;
regReference
=
/
(
@
[\w
$_
][\w
$_
\d]
+
)
/i
;
regAttrDfn
=
/
(\[([\w
-!
]
+
(
="
?([^
"
]
|
\\
"
)
+"
?)?
{0,})
+
\])
/ig
;
regAttrs
=
/
([\w
-!
]
+
(
="
([^
"
]
|
\\
"
)
+"
)?)
/g
;
regAttr
=
/
([\w
-!
]
+
)(
="
?((([\w]
+
(\[
.*
?\])
+
)
|
[^
"
\]]
|
\\
"
)
+
)
"
?)?
/i
;
regCBrace
=
/
\{(([^\}]
|
\\\})
+
)\}
/i
;
regExclamation
=
/
(?:([^\\]
|^
))
!
([^
!
]
|
\\
!
)
+!/g
;
regEvents
=
/
\~[\w
$
]
+
(
=
[\w
$
]
+
)?
/g
;
regEvent
=
/
\~([\w
$
]
+
)
=
([\w
$
]
+
)
/i
;
regDatas
=
/&
[\w
$
]
+
(
=
[\w
$
]
+
)?
/g
;
regData
=
/&
([\w
$
]
+
)(
=
([\w
$
]
+
))?
/i
;
return
createHTMLBlock
;
})();
}).
call
(
this
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment