quick_script 0.7.0 → 0.8.0
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.
- data/lib/quick_script/version.rb +1 -1
- data/vendor/assets/javascripts/quick_script/classes.js.coffee +4 -0
- data/vendor/assets/javascripts/quick_script/framework.js.coffee +102 -74
- data/vendor/assets/javascripts/quick_script/jquery.history.js +1 -195
- data/vendor/assets/javascripts/quick_script/jquery.history.old.js +195 -0
- data/vendor/assets/stylesheets/quick_script/elements.css.sass +2 -0
- metadata +5 -4
data/lib/quick_script/version.rb
CHANGED
@@ -27,6 +27,10 @@ String.prototype.truncate = (val)->
|
|
27
27
|
ret = ret + "..." if this.length > val
|
28
28
|
return ret
|
29
29
|
|
30
|
+
History.getRelativeUrl = ->
|
31
|
+
url = History.getState().url
|
32
|
+
"/#{url.replace(History.getRootUrl(), '')}"
|
33
|
+
|
30
34
|
class @SelectOpts
|
31
35
|
constructor : ->
|
32
36
|
@options = []
|
@@ -25,6 +25,10 @@
|
|
25
25
|
action.call(viewModel)
|
26
26
|
return false
|
27
27
|
|
28
|
+
ko.bindingHandlers.touchstart =
|
29
|
+
init : (element, valueAccessor, bindingsAccessor, viewModel) ->
|
30
|
+
element.addEventListener('touchstart', valueAccessor().bind(viewModel))
|
31
|
+
|
28
32
|
ko.bindingHandlers.validate =
|
29
33
|
init : (element, valueAccessor) ->
|
30
34
|
opts = valueAccessor()
|
@@ -70,34 +74,38 @@
|
|
70
74
|
|
71
75
|
ko.bindingHandlers.carousel =
|
72
76
|
init : (element, valueAccessor, bindingsAccessor, viewModel) ->
|
77
|
+
setTimeout ->
|
73
78
|
idx = viewModel.getViewBoxIndex(viewModel.task())
|
74
|
-
new_el = $(element).find('.slide-item-' + idx)
|
75
|
-
new_el.addClass('active')
|
79
|
+
new_el = $(element).find('.slide-item-' + idx).first()
|
80
|
+
#new_el.addClass('active')
|
81
|
+
, 0
|
76
82
|
update : (element, valueAccessor, bindingsAccessor, viewModel) ->
|
77
83
|
opts = viewModel.transition.opts
|
78
84
|
if viewModel.task() != null
|
79
|
-
idx = viewModel.getViewBoxIndex(viewModel.task())
|
80
|
-
console.log('updating slider to ' + idx)
|
81
|
-
old_idx = opts.slide_index()
|
82
|
-
new_el = $(element).find('.slide-item-' + idx)
|
83
|
-
old_el = $(element).find('.slide-item-' + old_idx)
|
84
|
-
if idx > old_idx
|
85
|
-
new_el.addClass('next')
|
86
|
-
new_el[0].offsetWidth if new_el[0]?
|
87
|
-
new_el.addClass('left')
|
88
|
-
old_el.addClass('left')
|
89
|
-
else
|
90
|
-
new_el.addClass('prev')
|
91
|
-
new_el[0].offsetWidth if new_el[0]?
|
92
|
-
new_el.addClass('right')
|
93
|
-
old_el.addClass('right')
|
94
85
|
setTimeout ->
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
new_el.
|
99
|
-
|
100
|
-
|
86
|
+
idx = viewModel.getViewBoxIndex(viewModel.task())
|
87
|
+
console.log(viewModel.name + ': updating slider to ' + idx)
|
88
|
+
old_idx = opts.slide_index()
|
89
|
+
new_el = $(element).find('.slide-item-' + idx).first()
|
90
|
+
old_el = $(element).find('.slide-item-' + old_idx).first()
|
91
|
+
if idx > old_idx
|
92
|
+
new_el.addClass('next')
|
93
|
+
new_el[0].offsetWidth if new_el[0]?
|
94
|
+
old_el.addClass('left')
|
95
|
+
new_el.addClass('left')
|
96
|
+
else
|
97
|
+
new_el.addClass('prev')
|
98
|
+
new_el[0].offsetWidth if new_el[0]?
|
99
|
+
old_el.addClass('right')
|
100
|
+
new_el.addClass('right')
|
101
|
+
setTimeout ->
|
102
|
+
new_el.removeClass('next left prev right')
|
103
|
+
old_el.removeClass('next left prev right')
|
104
|
+
old_el.removeClass('active')
|
105
|
+
new_el.addClass('active')
|
106
|
+
, 600
|
107
|
+
opts.slide_index(idx)
|
108
|
+
, 0
|
101
109
|
|
102
110
|
ko.bindingHandlers.bindelem =
|
103
111
|
init : (element, valueAccessor, bindingsAccessor, viewModel) ->
|
@@ -346,13 +354,13 @@ jQuery.ajax_qs = (opts)->
|
|
346
354
|
resp = eval("(" + req.responseText + ")")
|
347
355
|
opts.success(resp)
|
348
356
|
else
|
349
|
-
opts.error() if opts.error?
|
357
|
+
opts.error(req.status) if opts.error?
|
350
358
|
req.upload.addEventListener('error', opts.error) if opts.error?
|
351
359
|
if opts.progress?
|
352
360
|
req.upload.addEventListener 'progress', (ev)->
|
353
361
|
opts.progress(ev, Math.floor( ev.loaded / ev.total * 100 ))
|
354
362
|
req.open opts.type, opts.url, true
|
355
|
-
req.setRequestHeader 'X-CSRF-Token', jQuery
|
363
|
+
req.setRequestHeader 'X-CSRF-Token', jQuery.CSRF_TOKEN
|
356
364
|
req.send(data)
|
357
365
|
return req
|
358
366
|
|
@@ -427,9 +435,11 @@ class @Model
|
|
427
435
|
success : (resp)=>
|
428
436
|
@handleData(resp.data)
|
429
437
|
callback(resp) if callback?
|
430
|
-
error : =>
|
431
|
-
|
438
|
+
error : (err)=>
|
439
|
+
err = err || 'unknown'
|
440
|
+
console.log("Save error encountered [" + err + "]")
|
432
441
|
@model_state(ko.modelStates.READY)
|
442
|
+
callback({meta : 500, data : ['An error occurred']}) if callback?
|
433
443
|
@model_state(ko.modelStates.SAVING)
|
434
444
|
reset : ->
|
435
445
|
#@model_state(ko.modelStates.LOADING)
|
@@ -508,11 +518,11 @@ class @FileModel extends @Model
|
|
508
518
|
@input = {}
|
509
519
|
@input.files = ko.observable([])
|
510
520
|
@input.file_uri = ko.observable('')
|
511
|
-
@input.files.subscribe (val)
|
512
|
-
if val.length > 0
|
521
|
+
@input.files.subscribe (val)=>
|
522
|
+
if val.length > 0 && FileReader?
|
513
523
|
@input.file_uri('')
|
514
524
|
reader = new FileReader()
|
515
|
-
reader.
|
525
|
+
reader.onloadend = (ev)=>
|
516
526
|
console.log('input loaded')
|
517
527
|
@input.file_uri(ev.target.result)
|
518
528
|
reader.readAsDataURL(val[0])
|
@@ -527,10 +537,10 @@ class @FileModel extends @Model
|
|
527
537
|
if @input.present() then @input.file().name else ""
|
528
538
|
, this
|
529
539
|
@input.is_image = ko.computed ->
|
530
|
-
if @input.present() then @input.file().type.match('image.*') else false
|
540
|
+
if (@input.present() && @input.file().type?) then @input.file().type.match('image.*') else false
|
531
541
|
, this
|
532
542
|
@input.clear = => @input.files([])
|
533
|
-
reset :
|
543
|
+
reset : =>
|
534
544
|
super
|
535
545
|
@input.files([])
|
536
546
|
toAPI : =>
|
@@ -589,6 +599,9 @@ class @Collection
|
|
589
599
|
@hasItems = ko.dependentObservable ->
|
590
600
|
@items().length > 0
|
591
601
|
, this
|
602
|
+
@length = ko.computed ->
|
603
|
+
@items().length
|
604
|
+
, this
|
592
605
|
@init()
|
593
606
|
setScope : (scp, args) =>
|
594
607
|
opts = args
|
@@ -698,6 +711,9 @@ class @Collection
|
|
698
711
|
@page(1)
|
699
712
|
@items([])
|
700
713
|
@views([])
|
714
|
+
absorb : (model) =>
|
715
|
+
@reset()
|
716
|
+
@handleData(model.toJS())
|
701
717
|
toJS : =>
|
702
718
|
objs = []
|
703
719
|
for item in @items()
|
@@ -816,12 +832,13 @@ class @View
|
|
816
832
|
@views[keys[idx]]
|
817
833
|
afterRender : =>
|
818
834
|
if @transition.type == 'slide'
|
835
|
+
return
|
819
836
|
setTimeout =>
|
820
837
|
console.log('after render')
|
821
838
|
idx = @getViewBoxIndex(@task())
|
822
839
|
new_el = $(@element).find('.slide-item-' + idx)
|
823
840
|
new_el.addClass('active')
|
824
|
-
500
|
841
|
+
, 500
|
825
842
|
showAsOverlay : (tmp, opts, cls)=>
|
826
843
|
Overlay.add(this, tmp, opts, cls)
|
827
844
|
hideOverlay : =>
|
@@ -832,42 +849,35 @@ class @ModelAdapter
|
|
832
849
|
@save_url = null
|
833
850
|
@load_url = null
|
834
851
|
@index_url = null
|
852
|
+
@host = ''
|
835
853
|
for prop,val of opts
|
836
854
|
@[prop] = val
|
837
855
|
load : (opts)->
|
838
856
|
opts.data["_cv"] = Date.now() if opts.data?
|
839
|
-
$.getJSON @load_url, opts.data, (resp)->
|
857
|
+
$.getJSON (@host + @load_url), opts.data, (resp)->
|
840
858
|
opts.success(resp)
|
841
859
|
index : (opts)->
|
842
860
|
opts.data["_cv"] = Date.now() if opts.data?
|
843
|
-
$.getJSON (@index_url || @load_url), opts.data, (resp)->
|
861
|
+
$.getJSON (@host + (@index_url || @load_url)), opts.data, (resp)->
|
844
862
|
opts.success(resp)
|
845
863
|
save_old : (opts)->
|
846
864
|
$.ajax
|
847
865
|
type : 'POST'
|
848
|
-
url : @save_url
|
866
|
+
url : @host + @save_url
|
849
867
|
data : opts.data
|
850
868
|
success : opts.success
|
851
869
|
error : opts.error
|
852
870
|
save : (opts)->
|
853
|
-
|
854
|
-
|
855
|
-
url : @save_url
|
856
|
-
data : opts.data
|
857
|
-
progress : opts.progress
|
858
|
-
success : opts.success
|
859
|
-
error : opts.error
|
871
|
+
opts.url = @save_url
|
872
|
+
@send opts
|
860
873
|
send : (opts)->
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
data : opts.data
|
865
|
-
success : opts.success
|
866
|
-
error : opts.error
|
874
|
+
opts.type = 'POST' if !opts.type?
|
875
|
+
opts.url = @host + opts.url
|
876
|
+
$.ajax_qs opts
|
867
877
|
delete : (opts)->
|
868
878
|
$.ajax
|
869
879
|
type : 'DELETE'
|
870
|
-
url : @save_url
|
880
|
+
url : @host + @save_url
|
871
881
|
data : opts.data
|
872
882
|
success : opts.success
|
873
883
|
error : opts.error
|
@@ -876,33 +886,43 @@ class @ModelAdapter
|
|
876
886
|
|
877
887
|
class @AccountAdapter
|
878
888
|
constructor : (opts)->
|
879
|
-
@login_url = "/account/login"
|
880
|
-
@
|
881
|
-
@
|
882
|
-
@
|
883
|
-
@
|
884
|
-
@
|
889
|
+
@login_url = "/api/account/login"
|
890
|
+
@logout_url = "/api/account/logout"
|
891
|
+
@register_url = "/api/account/register"
|
892
|
+
@enter_code_url = "/api/account/enter_code"
|
893
|
+
@reset_url = "/api/account/reset"
|
894
|
+
@save_url = "/api/account/save"
|
895
|
+
@load_url = "/api/account/load"
|
885
896
|
@login_key = "email"
|
886
897
|
@password_key = "password"
|
898
|
+
@host = ""
|
887
899
|
for prop,val of opts
|
888
900
|
@[prop] = val
|
889
901
|
login : (username, password, callback)->
|
890
902
|
opts = {}
|
891
903
|
opts[@login_key] = username
|
892
904
|
opts[@password_key] = password
|
893
|
-
|
894
|
-
|
905
|
+
@send
|
906
|
+
url : @login_url
|
907
|
+
data : opts
|
908
|
+
success : (resp) =>
|
909
|
+
callback(resp)
|
910
|
+
logout : (callback)->
|
911
|
+
@send
|
912
|
+
url : @logout_url
|
913
|
+
success : (resp) =>
|
914
|
+
callback(resp)
|
895
915
|
register : (opts, callback)->
|
896
|
-
$.post @register_url, opts, (resp) =>
|
916
|
+
$.post (@host + @register_url), opts, (resp) =>
|
897
917
|
callback(resp)
|
898
918
|
sendInviteCode : (code, callback)->
|
899
|
-
$.post @enter_code_url, {code : code}, (resp) =>
|
919
|
+
$.post (@host + @enter_code_url), {code : code}, (resp) =>
|
900
920
|
callback(resp)
|
901
921
|
save : (opts) ->
|
902
922
|
opts ||= {}
|
903
923
|
$.ajax_qs
|
904
924
|
type : 'POST'
|
905
|
-
url : @save_url
|
925
|
+
url : @host + @save_url
|
906
926
|
data : opts.data
|
907
927
|
progress : opts.progress
|
908
928
|
success : opts.success
|
@@ -911,7 +931,7 @@ class @AccountAdapter
|
|
911
931
|
opts ||= {}
|
912
932
|
$.ajax_qs
|
913
933
|
type : 'POST'
|
914
|
-
url : @load_url
|
934
|
+
url : @host + @load_url
|
915
935
|
data : opts.data
|
916
936
|
progress : opts.progress
|
917
937
|
success : opts.success
|
@@ -919,20 +939,22 @@ class @AccountAdapter
|
|
919
939
|
resetPassword : (login, callback)->
|
920
940
|
opts = {}
|
921
941
|
opts[@login_key] = login
|
922
|
-
$.post @reset_url, opts, (resp) =>
|
942
|
+
$.post (@host + @reset_url), opts, (resp) =>
|
923
943
|
callback(resp) if callback?
|
924
944
|
send : (opts)->
|
945
|
+
def_err_fn = ->
|
946
|
+
opts.success({meta : 500, data : ['An error occurred.']})
|
925
947
|
$.ajax_qs
|
926
948
|
type : 'POST'
|
927
|
-
url : opts.url
|
949
|
+
url : @host + opts.url
|
928
950
|
data : opts.data
|
929
951
|
progress : opts.progress
|
930
952
|
success : opts.success
|
931
|
-
error : opts.error
|
953
|
+
error : opts.error || def_err_fn
|
932
954
|
delete : (opts)->
|
933
955
|
$.ajax_qs
|
934
956
|
type : 'DELETE'
|
935
|
-
url : opts.url
|
957
|
+
url : @host + opts.url
|
936
958
|
data : opts.data
|
937
959
|
progress : opts.progress
|
938
960
|
success : opts.success
|
@@ -952,7 +974,7 @@ class @AppView extends @View
|
|
952
974
|
</div>
|
953
975
|
"""
|
954
976
|
ko.addTemplate "app-slide", """
|
955
|
-
<div class="view-slider" data-bind="style : {width : transition.opts.width + 'px', height : transition.opts.height + 'px'}, carousel :
|
977
|
+
<div class="view-slider" data-bind="style : {width : transition.opts.width + 'px', height : transition.opts.height + 'px'}, carousel : task">
|
956
978
|
<div data-bind='foreach : viewList()'>
|
957
979
|
<div class="slide-item" data-bind="template : { name : getViewName }, attr : {id : templateID, class : 'slide-item slide-item-' + $index()}, css : {}, style : {width : owner.transition.opts.width + 'px', height : owner.transition.opts.height + 'px'}, bindelem : true"></div>
|
958
980
|
</div>
|
@@ -974,7 +996,7 @@ class @AppView extends @View
|
|
974
996
|
console.log(data)
|
975
997
|
@current_user.handleData(data) if data != null
|
976
998
|
redirectTo : (path) ->
|
977
|
-
|
999
|
+
History.pushState(null, null, path)
|
978
1000
|
|
979
1001
|
@initApp = ->
|
980
1002
|
appViewModel = @appViewModel
|
@@ -982,14 +1004,20 @@ class @AppView extends @View
|
|
982
1004
|
appViewModel.setUser(@CURRENT_USER)
|
983
1005
|
|
984
1006
|
# navigation
|
985
|
-
|
986
|
-
|
987
|
-
appViewModel.route('/')
|
988
|
-
else
|
989
|
-
appViewModel.route(hash)
|
990
|
-
, { unescape : ",/" }
|
1007
|
+
History.Adapter.bind window, 'statechange', ->
|
1008
|
+
appViewModel.route(History.getRelativeUrl())
|
991
1009
|
|
992
1010
|
# layout bindings
|
993
1011
|
$('body').koBind(appViewModel)
|
994
1012
|
appViewModel.afterRender()
|
995
1013
|
|
1014
|
+
# override links
|
1015
|
+
$('a').live 'click', ->
|
1016
|
+
if this.href.includes(History.getRootUrl())
|
1017
|
+
History.pushState null, null, this.href
|
1018
|
+
return false
|
1019
|
+
else
|
1020
|
+
return true
|
1021
|
+
|
1022
|
+
appViewModel.route(History.getRelativeUrl())
|
1023
|
+
|
@@ -1,195 +1 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery history plugin
|
3
|
-
*
|
4
|
-
* The MIT License
|
5
|
-
*
|
6
|
-
* Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
|
7
|
-
* Copyright (c) 2010 Takayuki Miwa
|
8
|
-
*
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
|
-
* of this software and associated documentation files (the "Software"), to deal
|
11
|
-
* in the Software without restriction, including without limitation the rights
|
12
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13
|
-
* copies of the Software, and to permit persons to whom the Software is
|
14
|
-
* furnished to do so, subject to the following conditions:
|
15
|
-
*
|
16
|
-
* The above copyright notice and this permission notice shall be included in
|
17
|
-
* all copies or substantial portions of the Software.
|
18
|
-
*
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
|
-
* THE SOFTWARE.
|
26
|
-
*/
|
27
|
-
|
28
|
-
(function($) {
|
29
|
-
var locationWrapper = {
|
30
|
-
put: function(hash, win) {
|
31
|
-
(win || window).location.hash = this.encoder(hash);
|
32
|
-
},
|
33
|
-
get: function(win) {
|
34
|
-
var hash = ((win || window).location.hash).replace(/^#/, '');
|
35
|
-
try {
|
36
|
-
return $.browser.mozilla ? hash : decodeURIComponent(hash);
|
37
|
-
}
|
38
|
-
catch (error) {
|
39
|
-
return hash;
|
40
|
-
}
|
41
|
-
},
|
42
|
-
encoder: encodeURIComponent
|
43
|
-
};
|
44
|
-
|
45
|
-
var iframeWrapper = {
|
46
|
-
id: "__jQuery_history",
|
47
|
-
init: function() {
|
48
|
-
var html = '<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />';
|
49
|
-
$("body").prepend(html);
|
50
|
-
return this;
|
51
|
-
},
|
52
|
-
_document: function() {
|
53
|
-
return $("#"+ this.id)[0].contentWindow.document;
|
54
|
-
},
|
55
|
-
put: function(hash) {
|
56
|
-
var doc = this._document();
|
57
|
-
doc.open();
|
58
|
-
doc.close();
|
59
|
-
locationWrapper.put(hash, doc);
|
60
|
-
},
|
61
|
-
get: function() {
|
62
|
-
return locationWrapper.get(this._document());
|
63
|
-
}
|
64
|
-
};
|
65
|
-
|
66
|
-
function initObjects(options) {
|
67
|
-
options = $.extend({
|
68
|
-
unescape: false
|
69
|
-
}, options || {});
|
70
|
-
|
71
|
-
locationWrapper.encoder = encoder(options.unescape);
|
72
|
-
|
73
|
-
function encoder(unescape_) {
|
74
|
-
if(unescape_ === true) {
|
75
|
-
return function(hash){ return hash; };
|
76
|
-
}
|
77
|
-
if(typeof unescape_ == "string" &&
|
78
|
-
(unescape_ = partialDecoder(unescape_.split("")))
|
79
|
-
|| typeof unescape_ == "function") {
|
80
|
-
return function(hash) { return unescape_(encodeURIComponent(hash)); };
|
81
|
-
}
|
82
|
-
return encodeURIComponent;
|
83
|
-
}
|
84
|
-
|
85
|
-
function partialDecoder(chars) {
|
86
|
-
var re = new RegExp($.map(chars, encodeURIComponent).join("|"), "ig");
|
87
|
-
return function(enc) { return enc.replace(re, decodeURIComponent); };
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
var implementations = {};
|
92
|
-
|
93
|
-
implementations.base = {
|
94
|
-
callback: undefined,
|
95
|
-
type: undefined,
|
96
|
-
|
97
|
-
check: function() {},
|
98
|
-
load: function(hash) {},
|
99
|
-
init: function(callback, options) {
|
100
|
-
initObjects(options);
|
101
|
-
self.callback = callback;
|
102
|
-
self._options = options;
|
103
|
-
self._init();
|
104
|
-
},
|
105
|
-
|
106
|
-
_init: function() {},
|
107
|
-
_options: {}
|
108
|
-
};
|
109
|
-
|
110
|
-
implementations.timer = {
|
111
|
-
_appState: undefined,
|
112
|
-
_init: function() {
|
113
|
-
var current_hash = locationWrapper.get();
|
114
|
-
self._appState = current_hash;
|
115
|
-
self.callback(current_hash);
|
116
|
-
setInterval(self.check, 100);
|
117
|
-
},
|
118
|
-
check: function() {
|
119
|
-
var current_hash = locationWrapper.get();
|
120
|
-
if(current_hash != self._appState) {
|
121
|
-
self._appState = current_hash;
|
122
|
-
self.callback(current_hash);
|
123
|
-
}
|
124
|
-
},
|
125
|
-
load: function(hash) {
|
126
|
-
if(hash != self._appState) {
|
127
|
-
locationWrapper.put(hash);
|
128
|
-
self._appState = hash;
|
129
|
-
self.callback(hash);
|
130
|
-
}
|
131
|
-
}
|
132
|
-
};
|
133
|
-
|
134
|
-
implementations.iframeTimer = {
|
135
|
-
_appState: undefined,
|
136
|
-
_init: function() {
|
137
|
-
var current_hash = locationWrapper.get();
|
138
|
-
self._appState = current_hash;
|
139
|
-
iframeWrapper.init().put(current_hash);
|
140
|
-
self.callback(current_hash);
|
141
|
-
setInterval(self.check, 100);
|
142
|
-
},
|
143
|
-
check: function() {
|
144
|
-
var iframe_hash = iframeWrapper.get(),
|
145
|
-
location_hash = locationWrapper.get();
|
146
|
-
|
147
|
-
if (location_hash != iframe_hash) {
|
148
|
-
if (location_hash == self._appState) { // user used Back or Forward button
|
149
|
-
self._appState = iframe_hash;
|
150
|
-
locationWrapper.put(iframe_hash);
|
151
|
-
self.callback(iframe_hash);
|
152
|
-
} else { // user loaded new bookmark
|
153
|
-
self._appState = location_hash;
|
154
|
-
iframeWrapper.put(location_hash);
|
155
|
-
self.callback(location_hash);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
},
|
159
|
-
load: function(hash) {
|
160
|
-
if(hash != self._appState) {
|
161
|
-
locationWrapper.put(hash);
|
162
|
-
iframeWrapper.put(hash);
|
163
|
-
self._appState = hash;
|
164
|
-
self.callback(hash);
|
165
|
-
}
|
166
|
-
}
|
167
|
-
};
|
168
|
-
|
169
|
-
implementations.hashchangeEvent = {
|
170
|
-
_init: function() {
|
171
|
-
self.callback(locationWrapper.get());
|
172
|
-
$(window).bind('hashchange', self.check);
|
173
|
-
},
|
174
|
-
check: function() {
|
175
|
-
self.callback(locationWrapper.get());
|
176
|
-
},
|
177
|
-
load: function(hash) {
|
178
|
-
locationWrapper.put(hash);
|
179
|
-
}
|
180
|
-
};
|
181
|
-
|
182
|
-
var self = $.extend({}, implementations.base);
|
183
|
-
|
184
|
-
if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) {
|
185
|
-
self.type = 'iframeTimer';
|
186
|
-
} else if("onhashchange" in window) {
|
187
|
-
self.type = 'hashchangeEvent';
|
188
|
-
} else {
|
189
|
-
self.type = 'timer';
|
190
|
-
}
|
191
|
-
|
192
|
-
$.extend(self, implementations[self.type]);
|
193
|
-
$.history = self;
|
194
|
-
})(jQuery);
|
195
|
-
|
1
|
+
window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()}(window),function(a,b){"use strict";var c=a.document,d=a.setTimeout||d,e=a.clearTimeout||e,f=a.setInterval||f,g=a.History=a.History||{};if(typeof g.initHtml4!="undefined")throw new Error("History.js HTML4 Support has already been loaded...");g.initHtml4=function(){if(typeof g.initHtml4.initialized!="undefined")return!1;g.initHtml4.initialized=!0,g.enabled=!0,g.savedHashes=[],g.isLastHash=function(a){var b=g.getHashByIndex(),c;return c=a===b,c},g.saveHash=function(a){return g.isLastHash(a)?!1:(g.savedHashes.push(a),!0)},g.getHashByIndex=function(a){var b=null;return typeof a=="undefined"?b=g.savedHashes[g.savedHashes.length-1]:a<0?b=g.savedHashes[g.savedHashes.length+a]:b=g.savedHashes[a],b},g.discardedHashes={},g.discardedStates={},g.discardState=function(a,b,c){var d=g.getHashByState(a),e;return e={discardedState:a,backState:c,forwardState:b},g.discardedStates[d]=e,!0},g.discardHash=function(a,b,c){var d={discardedHash:a,backState:c,forwardState:b};return g.discardedHashes[a]=d,!0},g.discardedState=function(a){var b=g.getHashByState(a),c;return c=g.discardedStates[b]||!1,c},g.discardedHash=function(a){var b=g.discardedHashes[a]||!1;return b},g.recycleState=function(a){var b=g.getHashByState(a);return g.discardedState(a)&&delete g.discardedStates[b],!0},g.emulated.hashChange&&(g.hashChangeInit=function(){g.checkerFunction=null;var b="",d,e,h,i;return g.isInternetExplorer()?(d="historyjs-iframe",e=c.createElement("iframe"),e.setAttribute("id",d),e.style.display="none",c.body.appendChild(e),e.contentWindow.document.open(),e.contentWindow.document.close(),h="",i=!1,g.checkerFunction=function(){if(i)return!1;i=!0;var c=g.getHash()||"",d=g.unescapeHash(e.contentWindow.document.location.hash)||"";return c!==b?(b=c,d!==c&&(h=d=c,e.contentWindow.document.open(),e.contentWindow.document.close(),e.contentWindow.document.location.hash=g.escapeHash(c)),g.Adapter.trigger(a,"hashchange")):d!==h&&(h=d,g.setHash(d,!1)),i=!1,!0}):g.checkerFunction=function(){var c=g.getHash();return c!==b&&(b=c,g.Adapter.trigger(a,"hashchange")),!0},g.intervalList.push(f(g.checkerFunction,g.options.hashChangeInterval)),!0},g.Adapter.onDomLoad(g.hashChangeInit)),g.emulated.pushState&&(g.onHashChange=function(b){var d=b&&b.newURL||c.location.href,e=g.getHashByUrl(d),f=null,h=null,i=null,j;return g.isLastHash(e)?(g.busy(!1),!1):(g.doubleCheckComplete(),g.saveHash(e),e&&g.isTraditionalAnchor(e)?(g.Adapter.trigger(a,"anchorchange"),g.busy(!1),!1):(f=g.extractState(g.getFullUrl(e||c.location.href,!1),!0),g.isLastSavedState(f)?(g.busy(!1),!1):(h=g.getHashByState(f),j=g.discardedState(f),j?(g.getHashByIndex(-2)===g.getHashByState(j.forwardState)?g.back(!1):g.forward(!1),!1):(g.pushState(f.data,f.title,f.url,!1),!0))))},g.Adapter.bind(a,"hashchange",g.onHashChange),g.pushState=function(b,d,e,f){if(g.getHashByUrl(e))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(f!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.pushState,args:arguments,queue:f}),!1;g.busy(!0);var h=g.createStateObject(b,d,e),i=g.getHashByState(h),j=g.getState(!1),k=g.getHashByState(j),l=g.getHash();return g.storeState(h),g.expectedStateId=h.id,g.recycleState(h),g.setTitle(h),i===k?(g.busy(!1),!1):i!==l&&i!==g.getShortUrl(c.location.href)?(g.setHash(i,!1),!1):(g.saveState(h),g.Adapter.trigger(a,"statechange"),g.busy(!1),!0)},g.replaceState=function(a,b,c,d){if(g.getHashByUrl(c))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(d!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.replaceState,args:arguments,queue:d}),!1;g.busy(!0);var e=g.createStateObject(a,b,c),f=g.getState(!1),h=g.getStateByIndex(-2);return g.discardState(f,e,h),g.pushState(e.data,e.title,e.url,!1),!0}),g.emulated.pushState&&g.getHash()&&!g.emulated.hashChange&&g.Adapter.onDomLoad(function(){g.Adapter.trigger(a,"hashchange")})},typeof g.init!="undefined"&&g.init()}(window),function(a,b){"use strict";var c=a.console||b,d=a.document,e=a.navigator,f=a.sessionStorage||!1,g=a.setTimeout,h=a.clearTimeout,i=a.setInterval,j=a.clearInterval,k=a.JSON,l=a.alert,m=a.History=a.History||{},n=a.history;k.stringify=k.stringify||k.encode,k.parse=k.parse||k.decode;if(typeof m.init!="undefined")throw new Error("History.js Core has already been loaded...");m.init=function(){return typeof m.Adapter=="undefined"?!1:(typeof m.initCore!="undefined"&&m.initCore(),typeof m.initHtml4!="undefined"&&m.initHtml4(),!0)},m.initCore=function(){if(typeof m.initCore.initialized!="undefined")return!1;m.initCore.initialized=!0,m.options=m.options||{},m.options.hashChangeInterval=m.options.hashChangeInterval||100,m.options.safariPollInterval=m.options.safariPollInterval||500,m.options.doubleCheckInterval=m.options.doubleCheckInterval||500,m.options.storeInterval=m.options.storeInterval||1e3,m.options.busyDelay=m.options.busyDelay||250,m.options.debug=m.options.debug||!1,m.options.initialTitle=m.options.initialTitle||d.title,m.intervalList=[],m.clearAllIntervals=function(){var a,b=m.intervalList;if(typeof b!="undefined"&&b!==null){for(a=0;a<b.length;a++)j(b[a]);m.intervalList=null}},m.debug=function(){(m.options.debug||!1)&&m.log.apply(m,arguments)},m.log=function(){var a=typeof c!="undefined"&&typeof c.log!="undefined"&&typeof c.log.apply!="undefined",b=d.getElementById("log"),e,f,g,h,i;a?(h=Array.prototype.slice.call(arguments),e=h.shift(),typeof c.debug!="undefined"?c.debug.apply(c,[e,h]):c.log.apply(c,[e,h])):e="\n"+arguments[0]+"\n";for(f=1,g=arguments.length;f<g;++f){i=arguments[f];if(typeof i=="object"&&typeof k!="undefined")try{i=k.stringify(i)}catch(j){}e+="\n"+i+"\n"}return b?(b.value+=e+"\n-----\n",b.scrollTop=b.scrollHeight-b.clientHeight):a||l(e),!0},m.getInternetExplorerMajorVersion=function(){var a=m.getInternetExplorerMajorVersion.cached=typeof m.getInternetExplorerMajorVersion.cached!="undefined"?m.getInternetExplorerMajorVersion.cached:function(){var a=3,b=d.createElement("div"),c=b.getElementsByTagName("i");while((b.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->")&&c[0]);return a>4?a:!1}();return a},m.isInternetExplorer=function(){var a=m.isInternetExplorer.cached=typeof m.isInternetExplorer.cached!="undefined"?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion());return a},m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)a+=":"+d.location.port;return a+="/",a},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return a.length===1&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){var a=m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl();return a},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||d.location.href,c;return c=b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"}),c},m.getBasePageUrl=function(){var a=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/";return a},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=typeof b=="undefined"?!0:b,/[a-z]+\:\/\//.test(a)||(d==="/"?c=m.getRootUrl()+a.replace(/^\/+/,""):d==="#"?c=m.getPageUrl().replace(/#.*/,"")+a:d==="?"?c=m.getPageUrl().replace(/[\?#].*/,"")+a:b?c=m.getBaseUrl()+a.replace(/^(\.\/)+/,""):c=m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),b},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){typeof a=="undefined"&&(a=!0),typeof b=="undefined"&&(b=!0);var c=m.getLastSavedState();return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b=m.extractId(a.url),c;if(!b){c=m.getStateString(a);if(typeof m.stateToId[c]!="undefined")b=m.stateToId[c];else if(typeof m.store.stateToId[c]!="undefined")b=m.store.stateToId[c];else{for(;;){b=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof m.idToState[b]=="undefined"&&typeof m.store.idToState[b]=="undefined")break}m.stateToId[c]=b,m.idToState[b]=a}}return b},m.normalizeState=function(a){var b,c;if(!a||typeof a!="object")a={};if(typeof a.normalized!="undefined")return a;if(!a.data||typeof a.data!="object")a.data={};b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(m.unescapeString(a.url||d.location.href)),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data);if(b.title||c)b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id;return b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d),d},m.getStateById=function(a){a=String(a);var c=m.idToState[a]||m.store.idToState[a]||b;return c},m.getStateString=function(a){var b,c,d;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},d=k.stringify(c),d},m.getStateId=function(a){var b,c;return b=m.normalizeState(a),c=b.id,c},m.getHashByState=function(a){var b,c;return b=m.normalizeState(a),c=b.hash,c},m.extractId=function(a){var b,c,d;return c=/(.*)\&_suid=([0-9]+)$/.exec(a),d=c?c[1]||a:a,b=c?String(c[2]||""):"",b||!1},m.isTraditionalAnchor=function(a){var b=!/[\/\?\.]/.test(a);return b},m.extractState=function(a,b){var c=null,d,e;return b=b||!1,d=m.extractId(a),d&&(c=m.getStateById(d)),c||(e=m.getFullUrl(a),d=m.getIdByUrl(e)||!1,d&&(c=m.getStateById(d)),!c&&b&&!m.isTraditionalAnchor(a)&&(c=m.createStateObject(null,null,e))),c},m.getIdByUrl=function(a){var c=m.urlToId[a]||m.store.urlToId[a]||b;return c},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b=!1,c;return c=m.extractState(a.url),b=c&&c.id!==a.id,b},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b=!1,c,d,e;return m.savedStates.length&&(c=a.id,d=m.getLastSavedState(),e=d.id,b=c===e),b},m.saveState=function(a){return m.isLastSavedState(a)?!1:(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){var b=null;return typeof a=="undefined"?b=m.savedStates[m.savedStates.length-1]:a<0?b=m.savedStates[m.savedStates.length+a]:b=m.savedStates[a],b},m.getHash=function(){var a=m.unescapeHash(d.location.hash);return a},m.unescapeString=function(b){var c=b,d;for(;;){d=a.unescape(c);if(d===c)break;c=d}return c},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=m.unescapeString(b),b},m.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},m.setHash=function(a,b){var c,e,f;return b!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(c=m.escapeHash(a),m.busy(!0),e=m.extractState(a,!0),e&&!m.emulated.pushState?m.pushState(e.data,e.title,e.url,!1):d.location.hash!==c&&(m.bugs.setHash?(f=m.getPageUrl(),m.pushState(null,null,f+"#"+c,!1)):d.location.hash=c),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.escape(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b),b},m.setTitle=function(a){var b=a.title,c;b||(c=m.getStateByIndex(0),c&&c.url===a.url&&(b=c.title||m.options.initialTitle));try{d.getElementsByTagName("title")[0].innerHTML=b.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=b,m},m.queues=[],m.busy=function(a){typeof a!="undefined"?m.busy.flag=a:typeof m.busy.flag=="undefined"&&(m.busy.flag=!1);if(!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(m.busy.flag)return;for(a=m.queues.length-1;a>=0;--a){c=m.queues[a];if(c.length===0)continue;d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay)}};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return typeof a=="function"&&(a={callback:a}),typeof b!="undefined"&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b=m.extractState(d.location.href),c;if(!m.isLastSavedState(b))c=b;else return;return c||(c=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m};if(m.emulated.pushState){var o=function(){};m.pushState=m.pushState||o,m.replaceState=m.replaceState||o}else m.onPopState=function(b,c){var e=!1,f=!1,g,h;return m.doubleCheckComplete(),g=m.getHash(),g?(h=m.extractState(g||d.location.href,!0),h?m.replaceState(h.data,h.title,h.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(e=m.Adapter.extractEventData("state",b,c)||!1,e?f=m.getStateById(e):m.expectedStateId?f=m.getStateById(m.expectedStateId):f=m.extractState(d.location.href),f||(f=m.createStateObject(null,null,d.location.href)),m.expectedStateId=!1,m.isLastSavedState(f)?(m.busy(!1),!1):(m.storeState(f),m.saveState(f),m.setTitle(f),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(p){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"beforeunload",m.clearAllIntervals),m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(d.location.href,!0))),f&&(m.onUnload=function(){var a,b;try{a=k.parse(f.getItem("History.store"))||{}}catch(c){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState){if(!m.idToState.hasOwnProperty(b))continue;a.idToState[b]=m.idToState[b]}for(b in m.urlToId){if(!m.urlToId.hasOwnProperty(b))continue;a.urlToId[b]=m.urlToId[b]}for(b in m.stateToId){if(!m.stateToId.hasOwnProperty(b))continue;a.stateToId[b]=m.stateToId[b]}m.store=a,m.normalizeStore(),f.setItem("History.store",k.stringify(a))},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload));if(!m.emulated.pushState){m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval));if(e.vendor==="Apple Computer, Inc."||(e.appCodeName||"")==="Mozilla")m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})}},m.init()}(window)
|
@@ -0,0 +1,195 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery history plugin
|
3
|
+
*
|
4
|
+
* The MIT License
|
5
|
+
*
|
6
|
+
* Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
|
7
|
+
* Copyright (c) 2010 Takayuki Miwa
|
8
|
+
*
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
14
|
+
* furnished to do so, subject to the following conditions:
|
15
|
+
*
|
16
|
+
* The above copyright notice and this permission notice shall be included in
|
17
|
+
* all copies or substantial portions of the Software.
|
18
|
+
*
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
|
+
* THE SOFTWARE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
(function($) {
|
29
|
+
var locationWrapper = {
|
30
|
+
put: function(hash, win) {
|
31
|
+
(win || window).location.hash = this.encoder(hash);
|
32
|
+
},
|
33
|
+
get: function(win) {
|
34
|
+
var hash = ((win || window).location.hash).replace(/^#/, '');
|
35
|
+
try {
|
36
|
+
return $.browser.mozilla ? hash : decodeURIComponent(hash);
|
37
|
+
}
|
38
|
+
catch (error) {
|
39
|
+
return hash;
|
40
|
+
}
|
41
|
+
},
|
42
|
+
encoder: encodeURIComponent
|
43
|
+
};
|
44
|
+
|
45
|
+
var iframeWrapper = {
|
46
|
+
id: "__jQuery_history",
|
47
|
+
init: function() {
|
48
|
+
var html = '<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />';
|
49
|
+
$("body").prepend(html);
|
50
|
+
return this;
|
51
|
+
},
|
52
|
+
_document: function() {
|
53
|
+
return $("#"+ this.id)[0].contentWindow.document;
|
54
|
+
},
|
55
|
+
put: function(hash) {
|
56
|
+
var doc = this._document();
|
57
|
+
doc.open();
|
58
|
+
doc.close();
|
59
|
+
locationWrapper.put(hash, doc);
|
60
|
+
},
|
61
|
+
get: function() {
|
62
|
+
return locationWrapper.get(this._document());
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
function initObjects(options) {
|
67
|
+
options = $.extend({
|
68
|
+
unescape: false
|
69
|
+
}, options || {});
|
70
|
+
|
71
|
+
locationWrapper.encoder = encoder(options.unescape);
|
72
|
+
|
73
|
+
function encoder(unescape_) {
|
74
|
+
if(unescape_ === true) {
|
75
|
+
return function(hash){ return hash; };
|
76
|
+
}
|
77
|
+
if(typeof unescape_ == "string" &&
|
78
|
+
(unescape_ = partialDecoder(unescape_.split("")))
|
79
|
+
|| typeof unescape_ == "function") {
|
80
|
+
return function(hash) { return unescape_(encodeURIComponent(hash)); };
|
81
|
+
}
|
82
|
+
return encodeURIComponent;
|
83
|
+
}
|
84
|
+
|
85
|
+
function partialDecoder(chars) {
|
86
|
+
var re = new RegExp($.map(chars, encodeURIComponent).join("|"), "ig");
|
87
|
+
return function(enc) { return enc.replace(re, decodeURIComponent); };
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
var implementations = {};
|
92
|
+
|
93
|
+
implementations.base = {
|
94
|
+
callback: undefined,
|
95
|
+
type: undefined,
|
96
|
+
|
97
|
+
check: function() {},
|
98
|
+
load: function(hash) {},
|
99
|
+
init: function(callback, options) {
|
100
|
+
initObjects(options);
|
101
|
+
self.callback = callback;
|
102
|
+
self._options = options;
|
103
|
+
self._init();
|
104
|
+
},
|
105
|
+
|
106
|
+
_init: function() {},
|
107
|
+
_options: {}
|
108
|
+
};
|
109
|
+
|
110
|
+
implementations.timer = {
|
111
|
+
_appState: undefined,
|
112
|
+
_init: function() {
|
113
|
+
var current_hash = locationWrapper.get();
|
114
|
+
self._appState = current_hash;
|
115
|
+
self.callback(current_hash);
|
116
|
+
setInterval(self.check, 100);
|
117
|
+
},
|
118
|
+
check: function() {
|
119
|
+
var current_hash = locationWrapper.get();
|
120
|
+
if(current_hash != self._appState) {
|
121
|
+
self._appState = current_hash;
|
122
|
+
self.callback(current_hash);
|
123
|
+
}
|
124
|
+
},
|
125
|
+
load: function(hash) {
|
126
|
+
if(hash != self._appState) {
|
127
|
+
locationWrapper.put(hash);
|
128
|
+
self._appState = hash;
|
129
|
+
self.callback(hash);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
implementations.iframeTimer = {
|
135
|
+
_appState: undefined,
|
136
|
+
_init: function() {
|
137
|
+
var current_hash = locationWrapper.get();
|
138
|
+
self._appState = current_hash;
|
139
|
+
iframeWrapper.init().put(current_hash);
|
140
|
+
self.callback(current_hash);
|
141
|
+
setInterval(self.check, 100);
|
142
|
+
},
|
143
|
+
check: function() {
|
144
|
+
var iframe_hash = iframeWrapper.get(),
|
145
|
+
location_hash = locationWrapper.get();
|
146
|
+
|
147
|
+
if (location_hash != iframe_hash) {
|
148
|
+
if (location_hash == self._appState) { // user used Back or Forward button
|
149
|
+
self._appState = iframe_hash;
|
150
|
+
locationWrapper.put(iframe_hash);
|
151
|
+
self.callback(iframe_hash);
|
152
|
+
} else { // user loaded new bookmark
|
153
|
+
self._appState = location_hash;
|
154
|
+
iframeWrapper.put(location_hash);
|
155
|
+
self.callback(location_hash);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
},
|
159
|
+
load: function(hash) {
|
160
|
+
if(hash != self._appState) {
|
161
|
+
locationWrapper.put(hash);
|
162
|
+
iframeWrapper.put(hash);
|
163
|
+
self._appState = hash;
|
164
|
+
self.callback(hash);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
};
|
168
|
+
|
169
|
+
implementations.hashchangeEvent = {
|
170
|
+
_init: function() {
|
171
|
+
self.callback(locationWrapper.get());
|
172
|
+
$(window).bind('hashchange', self.check);
|
173
|
+
},
|
174
|
+
check: function() {
|
175
|
+
self.callback(locationWrapper.get());
|
176
|
+
},
|
177
|
+
load: function(hash) {
|
178
|
+
locationWrapper.put(hash);
|
179
|
+
}
|
180
|
+
};
|
181
|
+
|
182
|
+
var self = $.extend({}, implementations.base);
|
183
|
+
|
184
|
+
if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) {
|
185
|
+
self.type = 'iframeTimer';
|
186
|
+
} else if("onhashchange" in window) {
|
187
|
+
self.type = 'hashchangeEvent';
|
188
|
+
} else {
|
189
|
+
self.type = 'timer';
|
190
|
+
}
|
191
|
+
|
192
|
+
$.extend(self, implementations[self.type]);
|
193
|
+
$.history = self;
|
194
|
+
})(jQuery);
|
195
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quick_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alan Graham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-26 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Framework for single-page web applications
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- vendor/assets/javascripts/quick_script/jquery-ui.min.js
|
51
51
|
- vendor/assets/javascripts/quick_script/jquery.fileupload.js
|
52
52
|
- vendor/assets/javascripts/quick_script/jquery.history.js
|
53
|
+
- vendor/assets/javascripts/quick_script/jquery.history.old.js
|
53
54
|
- vendor/assets/javascripts/quick_script/jquery.iframe-transport.js
|
54
55
|
- vendor/assets/javascripts/quick_script/jquery.min.js
|
55
56
|
- vendor/assets/javascripts/quick_script/jquery.poshytip.min.js
|