compass-jquery-plugin 0.3.2.8 → 0.3.3.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/README.md +24 -6
- data/VERSION.yml +3 -3
- data/lib/jquery/gridify/grid_column.rb +6 -6
- data/lib/jquery/gridify/grid_options.rb +4 -4
- data/lib/jquery/mark_it_up.rb +2 -0
- data/lib/jquery/mobile.rb +0 -1
- data/templates/dynatree/jquery.dynatree.js +2896 -2880
- data/templates/dynatree/jquery.dynatree.min.js +55 -54
- data/templates/dynatree/jquery/dynatree/aero.scss +4 -2
- data/templates/dynatree/jquery/dynatree/aqua.scss +4 -2
- data/templates/dynatree/jquery/dynatree/crystal.scss +4 -2
- data/templates/dynatree/jquery/dynatree/xp.scss +5 -3
- data/templates/emulators/emulators/bb.playbook.landscape.png +0 -0
- data/templates/emulators/emulators/bb.playbook.landscape.scss +18 -0
- data/templates/emulators/emulators/bb.playbook.portrait.png +0 -0
- data/templates/emulators/emulators/bb.playbook.portrait.scss +18 -0
- data/templates/emulators/emulators/{blackberry.torch.landscape.png → bb.torch.landscape.png} +0 -0
- data/templates/emulators/emulators/{blackberry.torch.landscape.scss → bb.torch.landscape.scss} +1 -3
- data/templates/emulators/emulators/{blackberry.torch.portrait.png → bb.torch.portrait.png} +0 -0
- data/templates/emulators/emulators/{blackberry.torch.portrait.scss → bb.torch.portrait.scss} +1 -3
- data/templates/emulators/emulators/galaxy.ace.landscape.png +0 -0
- data/templates/emulators/emulators/galaxy.ace.landscape.scss +18 -0
- data/templates/emulators/emulators/galaxy.ace.portrait.png +0 -0
- data/templates/emulators/emulators/galaxy.ace.portrait.scss +18 -0
- data/templates/emulators/emulators/galaxy.s.landscape.scss +0 -2
- data/templates/emulators/emulators/galaxy.s.portrait.scss +0 -2
- data/templates/emulators/emulators/galaxy.s2.landscape.scss +0 -2
- data/templates/emulators/emulators/galaxy.s2.portrait.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.10.1.landscape.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.10.1.portrait.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.7.landscape.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.7.portrait.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.8.9.landscape.scss +0 -2
- data/templates/emulators/emulators/galaxy.tab.8.9.portrait.scss +0 -2
- data/templates/emulators/emulators/htc.sensation.landscape.png +0 -0
- data/templates/emulators/emulators/htc.sensation.landscape.scss +18 -0
- data/templates/emulators/emulators/htc.sensation.portrait.png +0 -0
- data/templates/emulators/emulators/htc.sensation.portrait.scss +18 -0
- data/templates/emulators/emulators/ipad.landscape.scss +0 -2
- data/templates/emulators/emulators/ipad.portrait.scss +0 -2
- data/templates/emulators/emulators/iphone.3.landscape.scss +0 -2
- data/templates/emulators/emulators/iphone.3.portrait.scss +0 -2
- data/templates/emulators/emulators/{iphone.4.landscape .scss → iphone.4.landscape.scss} +0 -2
- data/templates/emulators/emulators/iphone.4.portrait.scss +0 -2
- data/templates/emulators/emulators/palm.pre.2.landscape.scss +0 -2
- data/templates/emulators/emulators/palm.pre.2.portrait.scss +0 -2
- data/templates/emulators/manifest.rb +17 -5
- data/templates/graphics/highcharts/dark-blue.js +159 -159
- data/templates/graphics/highcharts/dark-green.js +159 -159
- data/templates/graphics/highcharts/gray.js +154 -154
- data/templates/graphics/highcharts/grid.js +84 -84
- data/templates/graphics/highcharts/highslide-config.js +2 -2
- data/templates/graphics/highcharts/highslide-full.js +3310 -3310
- data/templates/graphics/highcharts/skies.js +72 -72
- data/templates/graphics/jquery.ganttView.js +1550 -1550
- data/templates/graphics/jquery.highcharts.js +11277 -11285
- data/templates/graphics/jquery.sparkline.js +1072 -1072
- data/templates/ical/jquery.ical.js +7637 -7637
- data/templates/ical/jquery/ical.print.scss +3 -3
- data/templates/jqgrid/i18n/jqgrid/locale-ar.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-bg.js +131 -131
- data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +131 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cat.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-cn.js +132 -132
- data/templates/jqgrid/i18n/jqgrid/locale-cs.js +129 -129
- data/templates/jqgrid/i18n/jqgrid/locale-da.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-de.js +134 -134
- data/templates/jqgrid/i18n/jqgrid/locale-el.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-en.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-es.js +129 -129
- data/templates/jqgrid/i18n/jqgrid/locale-fa.js +141 -141
- data/templates/jqgrid/i18n/jqgrid/locale-fi.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-fr.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-gl.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-he.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-hu.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-it.js +6 -6
- data/templates/jqgrid/i18n/jqgrid/locale-ja.js +153 -153
- data/templates/jqgrid/i18n/jqgrid/locale-lt.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-mne.js +134 -0
- data/templates/jqgrid/i18n/jqgrid/locale-mne.min.js +7 -0
- data/templates/jqgrid/i18n/jqgrid/locale-nl.js +145 -145
- data/templates/jqgrid/i18n/jqgrid/locale-no.js +12 -12
- data/templates/jqgrid/i18n/jqgrid/locale-pl.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-pt.js +126 -126
- data/templates/jqgrid/i18n/jqgrid/locale-ro.js +140 -140
- data/templates/jqgrid/i18n/jqgrid/locale-ru.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-sk.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-sr.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-sv.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-tr.js +127 -127
- data/templates/jqgrid/i18n/jqgrid/locale-ua.js +128 -128
- data/templates/jqgrid/jquery.jqGrid.js +13477 -13443
- data/templates/jqgrid/jquery.jqGrid.min.js +292 -287
- data/templates/jqgrid/jquery/jqGrid.scss +13 -12
- data/templates/jqgrid/manifest.rb +2 -0
- data/templates/jqtouch/jquery.jqtouch.js +9601 -9556
- data/templates/jqtouch/jquery.jqtouch.min.js +3 -3
- data/templates/jqtouch/jquery/touch/default.scss +2 -2
- data/templates/jqtouch/jquery/touch/jqt.scss +2 -2
- data/templates/jqtouch/jquery/touch/jqtouch.scss +26 -5
- data/templates/jquery/amplify.store.js +211 -211
- data/templates/jquery/config/initializers/jquery.rb +2 -0
- data/templates/jquery/history.adapter.jquery.js +42 -36
- data/templates/jquery/history.html4.js +563 -563
- data/templates/jquery/history.html4.min.js +5 -5
- data/templates/jquery/history.js +1721 -1694
- data/templates/jquery/history.min.js +28 -27
- data/templates/jquery/i18n/jquery.ui/datepicker-af.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ar-DZ.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-ar.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-az.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-bg.js +21 -21
- data/templates/jquery/i18n/jquery.ui/datepicker-bs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ca.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-cs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-da.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-de.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-el.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-AU.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-en-GB.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-NZ.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-eo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-es.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-et.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fa.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-fi.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-fo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr-CH.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-gl.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-he.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-hy.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-id.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-is.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-it.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-ja.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ko.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-kz.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-lt.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-lv.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-ml.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ms.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.min.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-no.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-pl.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-pt-BR.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-pt.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-rm.js +17 -17
- data/templates/jquery/i18n/jquery.ui/datepicker-ro.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ru.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-sk.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-sk.min.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-sl.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-sq.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr-SR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sv.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ta.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-th.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-tj.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-tr.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-uk.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-vi.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-CN.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-HK.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-TW.js +20 -20
- data/templates/jquery/jquery-ui.js +11913 -11882
- data/templates/jquery/jquery-ui.min.js +340 -339
- data/templates/jquery/jquery.bgiframe.js +27 -27
- data/templates/jquery/jquery.contextMenu.js +202 -202
- data/templates/jquery/jquery.cookie.js +26 -26
- data/templates/jquery/jquery.dotimeout.js +227 -227
- data/templates/jquery/jquery.dst.js +89 -89
- data/templates/jquery/jquery.easing.js +226 -0
- data/templates/jquery/jquery.easing.min.js +8 -0
- data/templates/jquery/jquery.farbtastic.js +294 -294
- data/templates/jquery/jquery.flashMessages.js +14 -14
- data/templates/jquery/jquery.form.js +761 -761
- data/templates/jquery/jquery.haml.js +247 -247
- data/templates/jquery/jquery.hotkeys.js +79 -79
- data/templates/jquery/jquery.js +1490 -928
- data/templates/jquery/jquery.layout.js +2454 -2454
- data/templates/jquery/jquery.mediahelpers.js +216 -0
- data/templates/jquery/jquery.mediahelpers.min.js +3 -0
- data/templates/jquery/jquery.min.js +177 -166
- data/templates/jquery/jquery.mousewheel.js +57 -57
- data/templates/jquery/jquery.offline.js +171 -171
- data/templates/jquery/jquery.pngFix.js +72 -72
- data/templates/jquery/jquery.rails.js +145 -145
- data/templates/jquery/jquery.replacetext.js +80 -80
- data/templates/jquery/jquery.themeswitchertool.js +195 -195
- data/templates/jquery/jquery.tmpl.js +460 -460
- data/templates/jquery/jquery.tmplPlus.js +78 -78
- data/templates/jquery/jquery.tokeninput.js +480 -475
- data/templates/jquery/jquery/ui/_theme.scss +14 -14
- data/templates/jquery/jquery/ui/black-tie/ui-icons_4ca300_256x240.png +0 -0
- data/templates/jquery/jquery/ui/black-tie/ui-icons_bbbbbb_256x240.png +0 -0
- data/templates/jquery/jquery/ui/black-tie/ui-icons_ededed_256x240.png +0 -0
- data/templates/jquery/jquery/ui/black-tie/ui-icons_ffcf29_256x240.png +0 -0
- data/templates/jquery/jquery/ui/vader/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/templates/jquery/jquery/ui/vader/ui-icons_bbbbbb_256x240.png +0 -0
- data/templates/jquery/jquery/ui/vader/ui-icons_c98000_256x240.png +0 -0
- data/templates/jquery/jquery/ui/vader/ui-icons_f29a00_256x240.png +0 -0
- data/templates/jquery/json.js +66 -66
- data/templates/jquery/json2.js +177 -177
- data/templates/jquery/manifest.rb +4 -0
- data/templates/jstree/jquery.jstree.js +5918 -5918
- data/templates/markitup/app/views/shared/_mark_it_up.parsed.preview.blue.html.haml +9 -0
- data/templates/markitup/app/views/shared/_mark_it_up.parsed.preview.html.haml +9 -0
- data/templates/markitup/app/views/shared/_mark_it_up.preview.blue.html.haml +8 -0
- data/templates/markitup/app/views/shared/_mark_it_up.preview.html.haml +8 -0
- data/templates/markitup/config/initializers/mark_it_up.rb +40 -0
- data/templates/markitup/jquery.markitup.js +586 -0
- data/templates/markitup/jquery.markitup.min.js +1 -0
- data/templates/markitup/jquery/markitup/preview/body.blue.png +0 -0
- data/templates/markitup/jquery/markitup/preview/bullet.blue.png +0 -0
- data/templates/markitup/jquery/markitup/preview/preview.blue.scss +58 -0
- data/templates/markitup/jquery/markitup/preview/preview.scss +7 -0
- data/templates/markitup/jquery/markitup/sets/bbcode.scss +34 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/clean.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/fonts.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/list-item.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/bbcode/underline.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css.scss +54 -0
- data/templates/markitup/jquery/markitup/sets/css/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/css.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/tag.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_align_center.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_align_justify.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_align_left.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_align_right.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_indent.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_letterspacing.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_linespacing.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_lowercase.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_padding_bottom.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_padding_left.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_padding_right.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_padding_top.png +0 -0
- data/templates/markitup/jquery/markitup/sets/css/text_uppercase.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default.scss +22 -0
- data/templates/markitup/jquery/markitup/sets/default/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/clean.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/image.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear.scss +38 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/dotclear/url.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html.scss +42 -0
- data/templates/markitup/jquery/markitup/sets/html/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/clean.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/image.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/list-item.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/paragraph.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/html/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown.scss +38 -0
- data/templates/markitup/jquery/markitup/sets/markdown/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markdown/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin.scss +38 -0
- data/templates/markitup/jquery/markitup/sets/markmin/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/markmin/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest.scss +38 -0
- data/templates/markitup/jquery/markitup/sets/rest/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/rest/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile.scss +44 -0
- data/templates/markitup/jquery/markitup/sets/textile/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/paragraph.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/textile/table.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy.scss +40 -0
- data/templates/markitup/jquery/markitup/sets/texy/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/disconnect.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/page_white_code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/texy/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags.scss +44 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/disconnect.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/txt2tags/underline.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki.scss +42 -0
- data/templates/markitup/jquery/markitup/sets/wiki/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/code.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/quotes.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/table.png +0 -0
- data/templates/markitup/jquery/markitup/sets/wiki/url.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode.scss +42 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/bold.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/clean.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h1.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h2.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h3.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h4.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h5.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/h6.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/image.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/italic.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/link.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/list-item.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/paragraph.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/picture.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/preview.png +0 -0
- data/templates/markitup/jquery/markitup/sets/xbbcode/stroke.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua.scss +136 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-container-white.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-container.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-footer-white.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-footer.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-header-white.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/bg-header.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/handle.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/spacer.gif +0 -0
- data/templates/markitup/jquery/markitup/skins/aqua/submenu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor.scss +141 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-container.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-bbcode.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-dotclear.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-html.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-markdown.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-textile.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor-wiki.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/bg-editor.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/handle.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/jtageditor/submenu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live.scss +135 -0
- data/templates/markitup/jquery/markitup/skins/live/bg-container.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/bg-footer.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/bg-header.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/editor.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/handle.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/live/submenu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup.scss +150 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-container.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-bbcode.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-dotclear.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-html.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-json.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-markdown.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-textile.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-wiki.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor-xml.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/bg-editor.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/handle.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/submenu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/simple.scss +117 -0
- data/templates/markitup/jquery/markitup/skins/simple/handle.png +0 -0
- data/templates/markitup/jquery/markitup/skins/simple/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/simple/submenu.png +0 -0
- data/templates/markitup/manifest.rb +311 -0
- data/templates/markitup/markitup/jquery.markitup.set.bbcode.js +40 -0
- data/templates/markitup/markitup/jquery.markitup.set.bbcode.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.css.js +53 -0
- data/templates/markitup/markitup/jquery.markitup.set.css.min.js +5 -0
- data/templates/markitup/markitup/jquery.markitup.set.default.js +30 -0
- data/templates/markitup/markitup/jquery.markitup.set.default.min.js +2 -0
- data/templates/markitup/markitup/jquery.markitup.set.dotclear.js +38 -0
- data/templates/markitup/markitup/jquery.markitup.set.dotclear.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.html.js +40 -0
- data/templates/markitup/markitup/jquery.markitup.set.html.min.js +4 -0
- data/templates/markitup/markitup/jquery.markitup.set.markdown.js +53 -0
- data/templates/markitup/markitup/jquery.markitup.set.markdown.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.markmin.js +50 -0
- data/templates/markitup/markitup/jquery.markitup.set.markmin.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.rest.js +52 -0
- data/templates/markitup/markitup/jquery.markitup.set.rest.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.textile.js +58 -0
- data/templates/markitup/markitup/jquery.markitup.set.textile.min.js +4 -0
- data/templates/markitup/markitup/jquery.markitup.set.texy.js +52 -0
- data/templates/markitup/markitup/jquery.markitup.set.texy.min.js +4 -0
- data/templates/markitup/markitup/jquery.markitup.set.txt2tags.js +42 -0
- data/templates/markitup/markitup/jquery.markitup.set.txt2tags.min.js +3 -0
- data/templates/markitup/markitup/jquery.markitup.set.wiki.js +61 -0
- data/templates/markitup/markitup/jquery.markitup.set.wiki.min.js +4 -0
- data/templates/markitup/markitup/jquery.markitup.set.xbbcode.js +36 -0
- data/templates/markitup/markitup/jquery.markitup.set.xbbcode.min.js +4 -0
- data/templates/mobile/config/initializers/mobile.rb +2 -0
- data/templates/mobile/jquery.mobile.js +4545 -4454
- data/templates/mobile/jquery.mobile.min.js +16 -7
- data/templates/mobile/jquery/mobile/960.fluid.scss +191 -0
- data/templates/mobile/jquery/mobile/960.scss +213 -0
- data/templates/mobile/jquery/mobile/_base.scss +37 -20
- data/templates/mobile/jquery/mobile/default.scss +48 -56
- data/templates/mobile/jquery/mobile/valencia.scss +43 -44
- data/templates/mobile/manifest.rb +2 -0
- data/templates/ribbon/jquery.ribbon.js +195 -195
- data/templates/ribbon/jquery.ribbon.min.js +1 -1
- data/templates/ribbon/jquery/ribbon/office.scss +12 -12
- data/templates/ribbon/jquery/ribbon/windows7.scss +12 -12
- data/templates/secret_sauce/secret_sauce.js +8 -8
- data/templates/tools/flowplayer.js +897 -897
- data/templates/tools/jquery.tools.js +3647 -3647
- data/templates/tools/jquery.tools.min.js +47 -47
- data/templates/tools/swfobject.js +760 -760
- metadata +350 -22
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
(function(f){var i=f.document,j=f.setInterval||j,a=f.History=f.History||{};if(typeof a.initHtml4!=="undefined")throw Error("History.js HTML4 Support has already been loaded...");a.initHtml4=function(){if(typeof a.initHtml4.initialized!=="undefined")return!1;else a.initHtml4.initialized=!0;a.enabled=!0;a.savedHashes=[];a.isLastHash=function(b){var c=a.getHashByIndex();return b===c};a.saveHash=function(b){if(a.isLastHash(b))return!1;a.savedHashes.push(b);return!0};a.getHashByIndex=function(b){var c=
|
|
5
5
|
null;return c=typeof b==="undefined"?a.savedHashes[a.savedHashes.length-1]:b<0?a.savedHashes[a.savedHashes.length+b]:a.savedHashes[b]};a.discardedHashes={};a.discardedStates={};a.discardState=function(b,c,e){var g=a.getHashByState(b);a.discardedStates[g]={discardedState:b,backState:e,forwardState:c};return!0};a.discardHash=function(b,c,e){a.discardedHashes[b]={discardedHash:b,backState:e,forwardState:c};return!0};a.discardedState=function(b){b=a.getHashByState(b);return a.discardedStates[b]||!1};
|
|
6
6
|
a.discardedHash=function(b){return a.discardedHashes[b]||!1};a.recycleState=function(b){var c=a.getHashByState(b);a.discardedState(b)&&delete a.discardedStates[c];return!0};if(a.emulated.hashChange)a.hashChangeInit=function(){a.checkerFunction=null;var b="";if(a.isInternetExplorer()){var c=i.createElement("iframe");c.setAttribute("id","historyjs-iframe");c.style.display="none";i.body.appendChild(c);c.contentWindow.document.open();c.contentWindow.document.close();var e="",g=!1;a.checkerFunction=function(){if(g)return!1;
|
|
7
|
-
g=!0;var d=a.getHash()||"",h=a.unescapeHash(c.contentWindow.document.location.hash)||"";if(d!==b){b=d;if(h!==d)e=d,c.contentWindow.document.open(),c.contentWindow.document.close(),c.contentWindow.document.location.hash=a.escapeHash(d);a.Adapter.trigger(f,"hashchange")}else h!==e&&(e=h,a.setHash(h,!1));g=!1;return!0}}else a.checkerFunction=function(){var c=a.getHash();c!==b&&(b=c,a.Adapter.trigger(f,"hashchange"));return!0};j(a.checkerFunction,a.options.hashChangeInterval);return!0},
|
|
8
|
-
if(a.emulated.pushState&&(a.onHashChange=function(b){var c=a.getHashByUrl(b&&b.newURL||i.location.href),b=null;if(a.isLastHash(c))return a.busy(!1),!1;a.doubleCheckComplete();a.saveHash(c);if(c&&a.isTraditionalAnchor(c))return a.Adapter.trigger(f,"anchorchange"),a.busy(!1),!1;b=a.extractState(a.getFullUrl(c||i.location.href,!1),!0);if(a.isLastSavedState(b))return a.busy(!1),!1;a.getHashByState(b);if(c=a.discardedState(b))return a.getHashByIndex(-2)===a.getHashByState(c.forwardState)?
|
|
9
|
-
!1;a.pushState(b.data,b.title,b.url,!1);return!0},a.Adapter.bind(f,"hashchange",a.onHashChange),a.pushState=function(b,c,e,g){if(a.getHashByUrl(e))throw Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(g!==!1&&a.busy())return a.pushQueue({scope:a,callback:a.pushState,args:arguments,queue:g}),!1;a.busy(!0);var d=a.createStateObject(b,c,e),h=a.getHashByState(d),k=a.getState(!1),k=a.getHashByState(k),j=a.getHash();a.storeState(d);a.expectedStateId=
|
|
10
|
-
a.setTitle(d);if(h===k)return a.busy(!1),!1;if(h!==j&&h!==a.getShortUrl(i.location.href))return a.setHash(h,!1),!1;a.saveState(d);a.Adapter.trigger(f,"statechange");a.busy(!1);return!0},a.replaceState=function(b,c,e,g){if(a.getHashByUrl(e))throw Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(g!==!1&&a.busy())return a.pushQueue({scope:a,callback:a.replaceState,args:arguments,queue:g}),!1;a.busy(!0);var d=a.createStateObject(b,c,e),
|
|
11
|
-
a.discardState(h,d,f);a.pushState(d.data,d.title,d.url,!1);return!0},a.getHash()&&!a.emulated.hashChange))a.Adapter.onDomLoad(function(){a.Adapter.trigger(f,"hashchange")})};a.init()})(window);
|
|
7
|
+
g=!0;var d=a.getHash()||"",h=a.unescapeHash(c.contentWindow.document.location.hash)||"";if(d!==b){b=d;if(h!==d)e=d,c.contentWindow.document.open(),c.contentWindow.document.close(),c.contentWindow.document.location.hash=a.escapeHash(d);a.Adapter.trigger(f,"hashchange")}else h!==e&&(e=h,a.setHash(h,!1));g=!1;return!0}}else a.checkerFunction=function(){var c=a.getHash();c!==b&&(b=c,a.Adapter.trigger(f,"hashchange"));return!0};a.intervalList.push(j(a.checkerFunction,a.options.hashChangeInterval));return!0},
|
|
8
|
+
a.Adapter.onDomLoad(a.hashChangeInit);if(a.emulated.pushState&&(a.onHashChange=function(b){var c=a.getHashByUrl(b&&b.newURL||i.location.href),b=null;if(a.isLastHash(c))return a.busy(!1),!1;a.doubleCheckComplete();a.saveHash(c);if(c&&a.isTraditionalAnchor(c))return a.Adapter.trigger(f,"anchorchange"),a.busy(!1),!1;b=a.extractState(a.getFullUrl(c||i.location.href,!1),!0);if(a.isLastSavedState(b))return a.busy(!1),!1;a.getHashByState(b);if(c=a.discardedState(b))return a.getHashByIndex(-2)===a.getHashByState(c.forwardState)?
|
|
9
|
+
a.back(!1):a.forward(!1),!1;a.pushState(b.data,b.title,b.url,!1);return!0},a.Adapter.bind(f,"hashchange",a.onHashChange),a.pushState=function(b,c,e,g){if(a.getHashByUrl(e))throw Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(g!==!1&&a.busy())return a.pushQueue({scope:a,callback:a.pushState,args:arguments,queue:g}),!1;a.busy(!0);var d=a.createStateObject(b,c,e),h=a.getHashByState(d),k=a.getState(!1),k=a.getHashByState(k),j=a.getHash();a.storeState(d);a.expectedStateId=
|
|
10
|
+
d.id;a.recycleState(d);a.setTitle(d);if(h===k)return a.busy(!1),!1;if(h!==j&&h!==a.getShortUrl(i.location.href))return a.setHash(h,!1),!1;a.saveState(d);a.Adapter.trigger(f,"statechange");a.busy(!1);return!0},a.replaceState=function(b,c,e,g){if(a.getHashByUrl(e))throw Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(g!==!1&&a.busy())return a.pushQueue({scope:a,callback:a.replaceState,args:arguments,queue:g}),!1;a.busy(!0);var d=a.createStateObject(b,c,e),
|
|
11
|
+
h=a.getState(!1),f=a.getStateByIndex(-2);a.discardState(h,d,f);a.pushState(d.data,d.title,d.url,!1);return!0},a.getHash()&&!a.emulated.hashChange))a.Adapter.onDomLoad(function(){a.Adapter.trigger(f,"hashchange")})};a.init()})(window);
|
data/templates/jquery/history.js
CHANGED
|
@@ -6,1843 +6,1870 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
(function(window, undefined) {
|
|
9
|
-
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
// --------------------------------------------------------------------------
|
|
12
|
+
// Initialise
|
|
13
|
+
|
|
14
|
+
// Localise Globals
|
|
15
|
+
var
|
|
16
|
+
console = window.console || undefined, // Prevent a JSLint complain
|
|
17
|
+
document = window.document, // Make sure we are using the correct document
|
|
18
|
+
navigator = window.navigator, // Make sure we are using the correct navigator
|
|
19
|
+
amplify = window.amplify || false, // Amplify.js
|
|
20
|
+
setTimeout = window.setTimeout,
|
|
21
|
+
clearTimeout = window.clearTimeout,
|
|
22
|
+
setInterval = window.setInterval,
|
|
23
|
+
clearInterval = window.clearInterval,
|
|
24
|
+
JSON = window.JSON,
|
|
25
|
+
History = window.History = window.History || {}, // Public History Object
|
|
26
|
+
history = window.history; // Old History Object
|
|
27
|
+
|
|
28
|
+
// MooTools Compatibility
|
|
29
|
+
JSON.stringify = JSON.stringify || JSON.encode;
|
|
30
|
+
JSON.parse = JSON.parse || JSON.decode;
|
|
31
|
+
|
|
32
|
+
// Check Existence
|
|
33
|
+
if (typeof History.init !== 'undefined') {
|
|
34
|
+
throw new Error('History.js Core has already been loaded...');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Initialise History
|
|
38
|
+
History.init = function() {
|
|
39
|
+
// Check Load Status of Adapter
|
|
40
|
+
if (typeof History.Adapter === 'undefined') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
10
43
|
|
|
11
|
-
//
|
|
12
|
-
|
|
44
|
+
// Check Load Status of Core
|
|
45
|
+
if (typeof History.initCore !== 'undefined') {
|
|
46
|
+
History.initCore();
|
|
47
|
+
}
|
|
13
48
|
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
document = window.document, // Make sure we are using the correct document
|
|
18
|
-
navigator = window.navigator, // Make sure we are using the correct navigator
|
|
19
|
-
amplify = window.amplify || false, // Amplify.js
|
|
20
|
-
setTimeout = window.setTimeout,
|
|
21
|
-
clearTimeout = window.clearTimeout,
|
|
22
|
-
setInterval = window.setInterval,
|
|
23
|
-
JSON = window.JSON,
|
|
24
|
-
History = window.History = window.History || {}, // Public History Object
|
|
25
|
-
history = window.history; // Old History Object
|
|
26
|
-
|
|
27
|
-
// MooTools Compatibility
|
|
28
|
-
JSON.stringify = JSON.stringify || JSON.encode;
|
|
29
|
-
JSON.parse = JSON.parse || JSON.decode;
|
|
30
|
-
|
|
31
|
-
// Check Existence
|
|
32
|
-
if (typeof History.init !== 'undefined') {
|
|
33
|
-
throw new Error('History.js Core has already been loaded...');
|
|
49
|
+
// Check Load Status of HTML4 Support
|
|
50
|
+
if (typeof History.initHtml4 !== 'undefined') {
|
|
51
|
+
History.initHtml4();
|
|
34
52
|
}
|
|
35
53
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (typeof History.Adapter === 'undefined') {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
54
|
+
// Return true
|
|
55
|
+
return true;
|
|
56
|
+
};
|
|
42
57
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
History.initCore();
|
|
46
|
-
}
|
|
58
|
+
// --------------------------------------------------------------------------
|
|
59
|
+
// Initialise Core
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
// Initialise Core
|
|
62
|
+
History.initCore = function() {
|
|
63
|
+
// Initialise
|
|
64
|
+
if (typeof History.initCore.initialized !== 'undefined') {
|
|
65
|
+
// Already Loaded
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
History.initCore.initialized = true;
|
|
70
|
+
}
|
|
52
71
|
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
// ----------------------------------------------------------------------
|
|
73
|
+
// Options
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* History.options
|
|
77
|
+
* Configurable options
|
|
78
|
+
*/
|
|
79
|
+
History.options = History.options || {};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* History.options.hashChangeInterval
|
|
83
|
+
* How long should the interval be before hashchange checks
|
|
84
|
+
*/
|
|
85
|
+
History.options.hashChangeInterval = History.options.hashChangeInterval || 100;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* History.options.safariPollInterval
|
|
89
|
+
* How long should the interval be before safari poll checks
|
|
90
|
+
*/
|
|
91
|
+
History.options.safariPollInterval = History.options.safariPollInterval || 500;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* History.options.doubleCheckInterval
|
|
95
|
+
* How long should the interval be before we perform a double check
|
|
96
|
+
*/
|
|
97
|
+
History.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* History.options.storeInterval
|
|
101
|
+
* How long should we wait between store calls
|
|
102
|
+
*/
|
|
103
|
+
History.options.storeInterval = History.options.storeInterval || 1000;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* History.options.busyDelay
|
|
107
|
+
* How long should we wait between busy events
|
|
108
|
+
*/
|
|
109
|
+
History.options.busyDelay = History.options.busyDelay || 250;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* History.options.debug
|
|
113
|
+
* If true will enable debug messages to be logged
|
|
114
|
+
*/
|
|
115
|
+
History.options.debug = History.options.debug || false;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* History.options.initialTitle
|
|
119
|
+
* What is the title of the initial state
|
|
120
|
+
*/
|
|
121
|
+
History.options.initialTitle = History.options.initialTitle || document.title;
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// ----------------------------------------------------------------------
|
|
125
|
+
// Interval record
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* History.intervalList
|
|
129
|
+
* List of intervals set, to be cleared when document is unloaded.
|
|
130
|
+
*/
|
|
131
|
+
History.intervalList = [];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* History.clearAllIntervals
|
|
135
|
+
* Clears all setInterval instances.
|
|
136
|
+
*/
|
|
137
|
+
History.clearAllIntervals = function() {
|
|
138
|
+
var i, il = History.intervalList;
|
|
139
|
+
if (typeof il !== "undefined" && il !== null) {
|
|
140
|
+
for (i = 0; i < il.length; i++) {
|
|
141
|
+
clearInterval(il[i]);
|
|
142
|
+
}
|
|
143
|
+
History.intervalList = null;
|
|
144
|
+
}
|
|
55
145
|
};
|
|
146
|
+
History.Adapter.bind(window, "beforeunload", History.clearAllIntervals);
|
|
147
|
+
History.Adapter.bind(window, "unload", History.clearAllIntervals);
|
|
56
148
|
|
|
57
|
-
// --------------------------------------------------------------------------
|
|
58
|
-
// Initialise Core
|
|
59
149
|
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
150
|
+
// ----------------------------------------------------------------------
|
|
151
|
+
// Debug
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* History.debug(message,...)
|
|
155
|
+
* Logs the passed arguments if debug enabled
|
|
156
|
+
*/
|
|
157
|
+
History.debug = function() {
|
|
158
|
+
if ((History.options.debug || false)) {
|
|
159
|
+
History.log.apply(History, arguments);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* History.log(message,...)
|
|
165
|
+
* Logs the passed arguments
|
|
166
|
+
*/
|
|
167
|
+
History.log = function() {
|
|
168
|
+
// Prepare
|
|
169
|
+
var
|
|
170
|
+
consoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),
|
|
171
|
+
textarea = document.getElementById('log'),
|
|
172
|
+
message,
|
|
173
|
+
i,n
|
|
174
|
+
;
|
|
175
|
+
|
|
176
|
+
// Write to Console
|
|
177
|
+
if (consoleExists) {
|
|
178
|
+
var args = Array.prototype.slice.call(arguments);
|
|
179
|
+
message = args.shift();
|
|
180
|
+
if (typeof console.debug !== 'undefined') {
|
|
181
|
+
console.debug.apply(console, [message,args]);
|
|
66
182
|
}
|
|
67
183
|
else {
|
|
68
|
-
|
|
184
|
+
console.log.apply(console, [message,args]);
|
|
69
185
|
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
message = ("\n" + arguments[0] + "\n");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Write to log
|
|
192
|
+
for (i = 1,n = arguments.length; i < n; ++i) {
|
|
193
|
+
var arg = arguments[i];
|
|
194
|
+
if (typeof arg === 'object' && typeof JSON !== 'undefined') {
|
|
195
|
+
try {
|
|
196
|
+
arg = JSON.stringify(arg);
|
|
197
|
+
}
|
|
198
|
+
catch (Exception) {
|
|
199
|
+
// Recursive Object
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
message += "\n" + arg + "\n";
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Textarea
|
|
206
|
+
if (textarea) {
|
|
207
|
+
textarea.value += message + "\n-----\n";
|
|
208
|
+
textarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;
|
|
209
|
+
}
|
|
210
|
+
// No Textarea, No Console
|
|
211
|
+
else if (!consoleExists) {
|
|
212
|
+
alert(message);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Return true
|
|
216
|
+
return true;
|
|
217
|
+
};
|
|
70
218
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* History.options.doubleCheckInterval
|
|
94
|
-
* How long should the interval be before we perform a double check
|
|
95
|
-
*/
|
|
96
|
-
History.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* History.options.storeInterval
|
|
100
|
-
* How long should we wait between store calls
|
|
101
|
-
*/
|
|
102
|
-
History.options.storeInterval = History.options.storeInterval || 1000;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* History.options.busyDelay
|
|
106
|
-
* How long should we wait between busy events
|
|
107
|
-
*/
|
|
108
|
-
History.options.busyDelay = History.options.busyDelay || 250;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* History.options.debug
|
|
112
|
-
* If true will enable debug messages to be logged
|
|
113
|
-
*/
|
|
114
|
-
History.options.debug = History.options.debug || false;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* History.options.initialTitle
|
|
118
|
-
* What is the title of the initial state
|
|
119
|
-
*/
|
|
120
|
-
History.options.initialTitle = History.options.initialTitle || document.title;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// ----------------------------------------------------------------------
|
|
124
|
-
// Debug
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* History.debug(message,...)
|
|
128
|
-
* Logs the passed arguments if debug enabled
|
|
129
|
-
*/
|
|
130
|
-
History.debug = function() {
|
|
131
|
-
if ((History.options.debug || false)) {
|
|
132
|
-
History.log.apply(History, arguments);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* History.log(message,...)
|
|
138
|
-
* Logs the passed arguments
|
|
139
|
-
*/
|
|
140
|
-
History.log = function() {
|
|
141
|
-
// Prepare
|
|
142
|
-
var
|
|
143
|
-
consoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),
|
|
144
|
-
textarea = document.getElementById('log'),
|
|
145
|
-
message,
|
|
146
|
-
i,n
|
|
147
|
-
;
|
|
148
|
-
|
|
149
|
-
// Write to Console
|
|
150
|
-
if (consoleExists) {
|
|
151
|
-
var args = Array.prototype.slice.call(arguments);
|
|
152
|
-
message = args.shift();
|
|
153
|
-
if (typeof console.debug !== 'undefined') {
|
|
154
|
-
console.debug.apply(console, [message,args]);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
console.log.apply(console, [message,args]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
message = ("\n" + arguments[0] + "\n");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Write to log
|
|
165
|
-
for (i = 1,n = arguments.length; i < n; ++i) {
|
|
166
|
-
var arg = arguments[i];
|
|
167
|
-
if (typeof arg === 'object' && typeof JSON !== 'undefined') {
|
|
168
|
-
try {
|
|
169
|
-
arg = JSON.stringify(arg);
|
|
170
|
-
}
|
|
171
|
-
catch (Exception) {
|
|
172
|
-
// Recursive Object
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
message += "\n" + arg + "\n";
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Textarea
|
|
179
|
-
if (textarea) {
|
|
180
|
-
textarea.value += message + "\n-----\n";
|
|
181
|
-
textarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;
|
|
182
|
-
}
|
|
183
|
-
// No Textarea, No Console
|
|
184
|
-
else if (!consoleExists) {
|
|
185
|
-
alert(message);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Return true
|
|
189
|
-
return true;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// ----------------------------------------------------------------------
|
|
193
|
-
// Emulated Status
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* History.getInternetExplorerMajorVersion()
|
|
197
|
-
* Get's the major version of Internet Explorer
|
|
198
|
-
* @return {integer}
|
|
199
|
-
* @license Public Domain
|
|
200
|
-
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
|
201
|
-
* @author James Padolsey <https://gist.github.com/527683>
|
|
202
|
-
*/
|
|
203
|
-
History.getInternetExplorerMajorVersion = function() {
|
|
204
|
-
var result = History.getInternetExplorerMajorVersion.cached =
|
|
205
|
-
(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')
|
|
206
|
-
? History.getInternetExplorerMajorVersion.cached
|
|
207
|
-
: (function() {
|
|
208
|
-
var v = 3,
|
|
209
|
-
div = document.createElement('div'),
|
|
210
|
-
all = div.getElementsByTagName('i');
|
|
211
|
-
while ((div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0]) {
|
|
212
|
-
}
|
|
213
|
-
return (v > 4) ? v : false;
|
|
214
|
-
})()
|
|
215
|
-
;
|
|
216
|
-
return result;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* History.isInternetExplorer()
|
|
221
|
-
* Are we using Internet Explorer?
|
|
222
|
-
* @return {boolean}
|
|
223
|
-
* @license Public Domain
|
|
224
|
-
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
|
225
|
-
*/
|
|
226
|
-
History.isInternetExplorer = function() {
|
|
227
|
-
var result =
|
|
228
|
-
History.isInternetExplorer.cached =
|
|
229
|
-
(typeof History.isInternetExplorer.cached !== 'undefined')
|
|
230
|
-
? History.isInternetExplorer.cached
|
|
231
|
-
: Boolean(History.getInternetExplorerMajorVersion())
|
|
232
|
-
;
|
|
233
|
-
return result;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* History.emulated
|
|
238
|
-
* Which features require emulating?
|
|
239
|
-
*/
|
|
240
|
-
History.emulated = {
|
|
241
|
-
pushState: !Boolean(
|
|
242
|
-
window.history && window.history.pushState && window.history.replaceState
|
|
243
|
-
&& !(
|
|
244
|
-
(/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */
|
|
245
|
-
|| (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
|
|
246
|
-
)
|
|
247
|
-
),
|
|
248
|
-
hashChange: Boolean(
|
|
249
|
-
!(('onhashchange' in window) || ('onhashchange' in document))
|
|
250
|
-
||
|
|
251
|
-
(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)
|
|
252
|
-
)
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* History.enabled
|
|
257
|
-
* Is History enabled?
|
|
258
|
-
*/
|
|
259
|
-
History.enabled = !History.emulated.pushState;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* History.bugs
|
|
263
|
-
* Which bugs are present
|
|
264
|
-
*/
|
|
265
|
-
History.bugs = {
|
|
266
|
-
/**
|
|
267
|
-
* Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call
|
|
268
|
-
* https://bugs.webkit.org/show_bug.cgi?id=56249
|
|
269
|
-
*/
|
|
270
|
-
setHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\/5([0-2]|3[0-3])/.test(navigator.userAgent)),
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions
|
|
274
|
-
* https://bugs.webkit.org/show_bug.cgi?id=42940
|
|
275
|
-
*/
|
|
276
|
-
safariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\/5([0-2]|3[0-3])/.test(navigator.userAgent)),
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)
|
|
280
|
-
*/
|
|
281
|
-
ieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event
|
|
285
|
-
*/
|
|
286
|
-
hashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* History.isEmptyObject(obj)
|
|
291
|
-
* Checks to see if the Object is Empty
|
|
292
|
-
* @param {Object} obj
|
|
293
|
-
* @return {boolean}
|
|
294
|
-
*/
|
|
295
|
-
History.isEmptyObject = function(obj) {
|
|
296
|
-
for (var name in obj) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
return true;
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* History.cloneObject(obj)
|
|
304
|
-
* Clones a object
|
|
305
|
-
* @param {Object} obj
|
|
306
|
-
* @return {Object}
|
|
307
|
-
*/
|
|
308
|
-
History.cloneObject = function(obj) {
|
|
309
|
-
var hash,newObj;
|
|
310
|
-
if (obj) {
|
|
311
|
-
hash = JSON.stringify(obj);
|
|
312
|
-
newObj = JSON.parse(hash);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
newObj = {};
|
|
316
|
-
}
|
|
317
|
-
return newObj;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
// ----------------------------------------------------------------------
|
|
321
|
-
// URL Helpers
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* History.getRootUrl()
|
|
325
|
-
* Turns "http://mysite.com/dir/page.html?asd" into "http://mysite.com"
|
|
326
|
-
* @return {String} rootUrl
|
|
327
|
-
*/
|
|
328
|
-
History.getRootUrl = function() {
|
|
329
|
-
// Create
|
|
330
|
-
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host);
|
|
331
|
-
if (document.location.port || false) {
|
|
332
|
-
rootUrl += ':' + document.location.port;
|
|
333
|
-
}
|
|
334
|
-
rootUrl += '/';
|
|
335
|
-
|
|
336
|
-
// Return
|
|
337
|
-
return rootUrl;
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* History.getBaseHref()
|
|
342
|
-
* Fetches the `href` attribute of the `<base href="...">` element if it exists
|
|
343
|
-
* @return {String} baseHref
|
|
344
|
-
*/
|
|
345
|
-
History.getBaseHref = function() {
|
|
346
|
-
// Create
|
|
347
|
-
var
|
|
348
|
-
baseElements = document.getElementsByTagName('base'),
|
|
349
|
-
baseElement = null,
|
|
350
|
-
baseHref = '';
|
|
351
|
-
|
|
352
|
-
// Test for Base Element
|
|
353
|
-
if (baseElements.length === 1) {
|
|
354
|
-
// Prepare for Base Element
|
|
355
|
-
baseElement = baseElements[0];
|
|
356
|
-
baseHref = baseElement.href.replace(/[^\/]+$/, '');
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// Adjust trailing slash
|
|
360
|
-
baseHref = baseHref.replace(/\/+$/, '');
|
|
361
|
-
if (baseHref) baseHref += '/';
|
|
362
|
-
|
|
363
|
-
// Return
|
|
364
|
-
return baseHref;
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* History.getBaseUrl()
|
|
369
|
-
* Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)
|
|
370
|
-
* @return {String} baseUrl
|
|
371
|
-
*/
|
|
372
|
-
History.getBaseUrl = function() {
|
|
373
|
-
// Create
|
|
374
|
-
var baseUrl = History.getBaseHref() || History.getBasePageUrl() || History.getRootUrl();
|
|
375
|
-
|
|
376
|
-
// Return
|
|
377
|
-
return baseUrl;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* History.getPageUrl()
|
|
382
|
-
* Fetches the URL of the current page
|
|
383
|
-
* @return {String} pageUrl
|
|
384
|
-
*/
|
|
385
|
-
History.getPageUrl = function() {
|
|
386
|
-
// Fetch
|
|
387
|
-
var
|
|
388
|
-
State = History.getState(false, false),
|
|
389
|
-
stateUrl = (State || {}).url || document.location.href;
|
|
390
|
-
|
|
391
|
-
// Create
|
|
392
|
-
var pageUrl = stateUrl.replace(/\/+$/, '').replace(/[^\/]+$/, function(part, index, string) {
|
|
393
|
-
return (/\./).test(part) ? part : part + '/';
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
// Return
|
|
397
|
-
return pageUrl;
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* History.getBasePageUrl()
|
|
402
|
-
* Fetches the Url of the directory of the current page
|
|
403
|
-
* @return {String} basePageUrl
|
|
404
|
-
*/
|
|
405
|
-
History.getBasePageUrl = function() {
|
|
406
|
-
// Create
|
|
407
|
-
var basePageUrl = document.location.href.replace(/[#\?].*/, '').replace(/[^\/]+$/,
|
|
408
|
-
function(part, index, string) {
|
|
409
|
-
return (/[^\/]$/).test(part) ? '' : part;
|
|
410
|
-
}).replace(/\/+$/, '') + '/';
|
|
411
|
-
|
|
412
|
-
// Return
|
|
413
|
-
return basePageUrl;
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* History.getFullUrl(url)
|
|
418
|
-
* Ensures that we have an absolute URL and not a relative URL
|
|
419
|
-
* @param {string} url
|
|
420
|
-
* @param {Boolean} allowBaseHref
|
|
421
|
-
* @return {string} fullUrl
|
|
422
|
-
*/
|
|
423
|
-
History.getFullUrl = function(url, allowBaseHref) {
|
|
424
|
-
// Prepare
|
|
425
|
-
var fullUrl = url, firstChar = url.substring(0, 1);
|
|
426
|
-
allowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;
|
|
427
|
-
|
|
428
|
-
// Check
|
|
429
|
-
if (/[a-z]+\:\/\//.test(url)) {
|
|
430
|
-
// Full URL
|
|
431
|
-
}
|
|
432
|
-
else if (firstChar === '/') {
|
|
433
|
-
// Root URL
|
|
434
|
-
fullUrl = History.getRootUrl() + url.replace(/^\/+/, '');
|
|
435
|
-
}
|
|
436
|
-
else if (firstChar === '#') {
|
|
437
|
-
// Anchor URL
|
|
438
|
-
fullUrl = History.getPageUrl().replace(/#.*/, '') + url;
|
|
439
|
-
}
|
|
440
|
-
else if (firstChar === '?') {
|
|
441
|
-
// Query URL
|
|
442
|
-
fullUrl = History.getPageUrl().replace(/[\?#].*/, '') + url;
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
// Relative URL
|
|
446
|
-
if (allowBaseHref) {
|
|
447
|
-
fullUrl = History.getBaseUrl() + url.replace(/^(\.\/)+/, '');
|
|
448
|
-
} else {
|
|
449
|
-
fullUrl = History.getBasePageUrl() + url.replace(/^(\.\/)+/, '');
|
|
450
|
-
}
|
|
451
|
-
// We have an if condition above as we do not want hashes
|
|
452
|
-
// which are relative to the baseHref in our URLs
|
|
453
|
-
// as if the baseHref changes, then all our bookmarks
|
|
454
|
-
// would now point to different locations
|
|
455
|
-
// whereas the basePageUrl will always stay the same
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// Return
|
|
459
|
-
return fullUrl.replace(/\#$/, '');
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* History.getShortUrl(url)
|
|
464
|
-
* Ensures that we have a relative URL and not a absolute URL
|
|
465
|
-
* @param {string} url
|
|
466
|
-
* @return {string} url
|
|
467
|
-
*/
|
|
468
|
-
History.getShortUrl = function(url) {
|
|
469
|
-
// Prepare
|
|
470
|
-
var shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();
|
|
471
|
-
|
|
472
|
-
// Trim baseUrl
|
|
473
|
-
if (History.emulated.pushState) {
|
|
474
|
-
// We are in a if statement as when pushState is not emulated
|
|
475
|
-
// The actual url these short urls are relative to can change
|
|
476
|
-
// So within the same session, we the url may end up somewhere different
|
|
477
|
-
shortUrl = shortUrl.replace(baseUrl, '');
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// Trim rootUrl
|
|
481
|
-
shortUrl = shortUrl.replace(rootUrl, '/');
|
|
482
|
-
|
|
483
|
-
// Ensure we can still detect it as a state
|
|
484
|
-
if (History.isTraditionalAnchor(shortUrl)) {
|
|
485
|
-
shortUrl = './' + shortUrl;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// Clean It
|
|
489
|
-
shortUrl = shortUrl.replace(/^(\.\/)+/g, './').replace(/\#$/, '');
|
|
490
|
-
|
|
491
|
-
// Return
|
|
492
|
-
return shortUrl;
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
// ----------------------------------------------------------------------
|
|
496
|
-
// State Storage
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* History.store
|
|
500
|
-
* The store for all session specific data
|
|
501
|
-
*/
|
|
502
|
-
History.store = amplify ? (amplify.store('History.store') || {}) : {};
|
|
503
|
-
History.store.idToState = History.store.idToState || {};
|
|
504
|
-
History.store.urlToId = History.store.urlToId || {};
|
|
505
|
-
History.store.stateToId = History.store.stateToId || {};
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* History.idToState
|
|
509
|
-
* 1-1: State ID to State Object
|
|
510
|
-
*/
|
|
511
|
-
History.idToState = History.idToState || {};
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* History.stateToId
|
|
515
|
-
* 1-1: State String to State ID
|
|
516
|
-
*/
|
|
517
|
-
History.stateToId = History.stateToId || {};
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* History.urlToId
|
|
521
|
-
* 1-1: State URL to State ID
|
|
522
|
-
*/
|
|
523
|
-
History.urlToId = History.urlToId || {};
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* History.storedStates
|
|
527
|
-
* Store the states in an array
|
|
528
|
-
*/
|
|
529
|
-
History.storedStates = History.storedStates || [];
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* History.savedStates
|
|
533
|
-
* Saved the states in an array
|
|
534
|
-
*/
|
|
535
|
-
History.savedStates = History.savedStates || [];
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* History.getState()
|
|
539
|
-
* Get an object containing the data, title and url of the current state
|
|
540
|
-
* @param {Boolean} friendly
|
|
541
|
-
* @param {Boolean} create
|
|
542
|
-
* @return {Object} State
|
|
543
|
-
*/
|
|
544
|
-
History.getState = function(friendly, create) {
|
|
545
|
-
// Prepare
|
|
546
|
-
if (typeof friendly === 'undefined') {
|
|
547
|
-
friendly = true;
|
|
548
|
-
}
|
|
549
|
-
if (typeof create === 'undefined') {
|
|
550
|
-
create = true;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// Fetch
|
|
554
|
-
var State = History.getLastSavedState();
|
|
555
|
-
|
|
556
|
-
// Create
|
|
557
|
-
if (!State && create) {
|
|
558
|
-
State = History.createStateObject();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// Adjust
|
|
562
|
-
if (friendly) {
|
|
563
|
-
State = History.cloneObject(State);
|
|
564
|
-
State.url = State.cleanUrl || State.url;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
// Return
|
|
568
|
-
return State;
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* History.getIdByState(State)
|
|
573
|
-
* Gets a ID for a State
|
|
574
|
-
* @param {State} newState
|
|
575
|
-
* @return {String} id
|
|
576
|
-
*/
|
|
577
|
-
History.getIdByState = function(newState) {
|
|
578
|
-
|
|
579
|
-
// Fetch ID
|
|
580
|
-
var id = History.extractId(newState.url);
|
|
581
|
-
if (!id) {
|
|
582
|
-
// Find ID via State String
|
|
583
|
-
var str = History.getStateString(newState);
|
|
584
|
-
if (typeof History.stateToId[str] !== 'undefined') {
|
|
585
|
-
id = History.stateToId[str];
|
|
586
|
-
}
|
|
587
|
-
else if (typeof History.store.stateToId[str] !== 'undefined') {
|
|
588
|
-
id = History.store.stateToId[str];
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
// Generate a new ID
|
|
592
|
-
while (true) {
|
|
593
|
-
id = String(Math.floor(Math.random() * 1000));
|
|
594
|
-
if (typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined') {
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// Apply the new State to the ID
|
|
600
|
-
History.stateToId[str] = id;
|
|
601
|
-
History.idToState[id] = newState;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// Return ID
|
|
606
|
-
return id;
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* History.normalizeState(State)
|
|
611
|
-
* Expands a State Object
|
|
612
|
-
* @param {object} State
|
|
613
|
-
* @return {object}
|
|
614
|
-
*/
|
|
615
|
-
History.normalizeState = function(oldState) {
|
|
616
|
-
// Prepare
|
|
617
|
-
if (!oldState || (typeof oldState !== 'object')) {
|
|
618
|
-
oldState = {};
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// Check
|
|
622
|
-
if (typeof oldState.normalized !== 'undefined') {
|
|
623
|
-
return oldState;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Adjust
|
|
627
|
-
if (!oldState.data || (typeof oldState.data !== 'object')) {
|
|
628
|
-
oldState.data = {};
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// ----------------------------------------------------------------------
|
|
632
|
-
|
|
633
|
-
// Create
|
|
634
|
-
var newState = {};
|
|
635
|
-
newState.normalized = true;
|
|
636
|
-
newState.title = oldState.title || '';
|
|
637
|
-
newState.url = History.getFullUrl(History.unescapeString(oldState.url || document.location.href));
|
|
638
|
-
newState.hash = History.getShortUrl(newState.url);
|
|
639
|
-
newState.data = History.cloneObject(oldState.data);
|
|
640
|
-
|
|
641
|
-
// Fetch ID
|
|
642
|
-
newState.id = History.getIdByState(newState);
|
|
643
|
-
|
|
644
|
-
// ----------------------------------------------------------------------
|
|
645
|
-
|
|
646
|
-
// Clean the URL
|
|
647
|
-
newState.cleanUrl = newState.url.replace(/\??\&_suid.*/, '');
|
|
648
|
-
newState.url = newState.cleanUrl;
|
|
649
|
-
|
|
650
|
-
// Check to see if we have more than just a url
|
|
651
|
-
var dataNotEmpty = !History.isEmptyObject(newState.data);
|
|
652
|
-
|
|
653
|
-
// Apply
|
|
654
|
-
if (newState.title || dataNotEmpty) {
|
|
655
|
-
// Add ID to Hash
|
|
656
|
-
newState.hash = History.getShortUrl(newState.url).replace(/\??\&_suid.*/, '');
|
|
657
|
-
if (!/\?/.test(newState.hash)) {
|
|
658
|
-
newState.hash += '?';
|
|
219
|
+
// ----------------------------------------------------------------------
|
|
220
|
+
// Emulated Status
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* History.getInternetExplorerMajorVersion()
|
|
224
|
+
* Get's the major version of Internet Explorer
|
|
225
|
+
* @return {integer}
|
|
226
|
+
* @license Public Domain
|
|
227
|
+
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
|
228
|
+
* @author James Padolsey <https://gist.github.com/527683>
|
|
229
|
+
*/
|
|
230
|
+
History.getInternetExplorerMajorVersion = function() {
|
|
231
|
+
var result = History.getInternetExplorerMajorVersion.cached =
|
|
232
|
+
(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')
|
|
233
|
+
? History.getInternetExplorerMajorVersion.cached
|
|
234
|
+
: (function() {
|
|
235
|
+
var v = 3,
|
|
236
|
+
div = document.createElement('div'),
|
|
237
|
+
all = div.getElementsByTagName('i');
|
|
238
|
+
while ((div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0]) {
|
|
659
239
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
// ----------------------------------------------------------------------
|
|
667
|
-
|
|
668
|
-
// Update the URL if we have a duplicate
|
|
669
|
-
if ((History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState)) {
|
|
670
|
-
newState.url = newState.hashedUrl;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// ----------------------------------------------------------------------
|
|
674
|
-
|
|
675
|
-
// Return
|
|
676
|
-
return newState;
|
|
677
|
-
};
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* History.createStateObject(data,title,url)
|
|
681
|
-
* Creates a object based on the data, title and url state params
|
|
682
|
-
* @param {object} data
|
|
683
|
-
* @param {string} title
|
|
684
|
-
* @param {string} url
|
|
685
|
-
* @return {object}
|
|
686
|
-
*/
|
|
687
|
-
History.createStateObject = function(data, title, url) {
|
|
688
|
-
// Hashify
|
|
689
|
-
var State = {
|
|
690
|
-
'data': data,
|
|
691
|
-
'title': title,
|
|
692
|
-
'url': url
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
// Expand the State
|
|
696
|
-
State = History.normalizeState(State);
|
|
697
|
-
|
|
698
|
-
// Return object
|
|
699
|
-
return State;
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* History.getStateById(id)
|
|
704
|
-
* Get a state by it's UID
|
|
705
|
-
* @param {String} id
|
|
706
|
-
*/
|
|
707
|
-
History.getStateById = function(id) {
|
|
708
|
-
// Prepare
|
|
709
|
-
id = String(id);
|
|
710
|
-
|
|
711
|
-
// Retrieve
|
|
712
|
-
var State = History.idToState[id] || History.store.idToState[id] || undefined;
|
|
713
|
-
|
|
714
|
-
// Return State
|
|
715
|
-
return State;
|
|
716
|
-
};
|
|
240
|
+
return (v > 4) ? v : false;
|
|
241
|
+
})()
|
|
242
|
+
;
|
|
243
|
+
return result;
|
|
244
|
+
};
|
|
717
245
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
var str = JSON.stringify(cleanedState);
|
|
735
|
-
|
|
736
|
-
// Return
|
|
737
|
-
return str;
|
|
738
|
-
};
|
|
246
|
+
/**
|
|
247
|
+
* History.isInternetExplorer()
|
|
248
|
+
* Are we using Internet Explorer?
|
|
249
|
+
* @return {boolean}
|
|
250
|
+
* @license Public Domain
|
|
251
|
+
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
|
252
|
+
*/
|
|
253
|
+
History.isInternetExplorer = function() {
|
|
254
|
+
var result =
|
|
255
|
+
History.isInternetExplorer.cached =
|
|
256
|
+
(typeof History.isInternetExplorer.cached !== 'undefined')
|
|
257
|
+
? History.isInternetExplorer.cached
|
|
258
|
+
: Boolean(History.getInternetExplorerMajorVersion())
|
|
259
|
+
;
|
|
260
|
+
return result;
|
|
261
|
+
};
|
|
739
262
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
263
|
+
/**
|
|
264
|
+
* History.emulated
|
|
265
|
+
* Which features require emulating?
|
|
266
|
+
*/
|
|
267
|
+
History.emulated = {
|
|
268
|
+
pushState: !Boolean(
|
|
269
|
+
window.history && window.history.pushState && window.history.replaceState
|
|
270
|
+
&& !(
|
|
271
|
+
(/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */
|
|
272
|
+
|| (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
|
|
273
|
+
)
|
|
274
|
+
),
|
|
275
|
+
hashChange: Boolean(
|
|
276
|
+
!(('onhashchange' in window) || ('onhashchange' in document))
|
|
277
|
+
||
|
|
278
|
+
(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)
|
|
279
|
+
)
|
|
280
|
+
};
|
|
748
281
|
|
|
749
|
-
|
|
750
|
-
|
|
282
|
+
/**
|
|
283
|
+
* History.enabled
|
|
284
|
+
* Is History enabled?
|
|
285
|
+
*/
|
|
286
|
+
History.enabled = !History.emulated.pushState;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* History.bugs
|
|
290
|
+
* Which bugs are present
|
|
291
|
+
*/
|
|
292
|
+
History.bugs = {
|
|
293
|
+
/**
|
|
294
|
+
* Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call
|
|
295
|
+
* https://bugs.webkit.org/show_bug.cgi?id=56249
|
|
296
|
+
*/
|
|
297
|
+
setHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\/5([0-2]|3[0-3])/.test(navigator.userAgent)),
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions
|
|
301
|
+
* https://bugs.webkit.org/show_bug.cgi?id=42940
|
|
302
|
+
*/
|
|
303
|
+
safariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\/5([0-2]|3[0-3])/.test(navigator.userAgent)),
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)
|
|
307
|
+
*/
|
|
308
|
+
ieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event
|
|
312
|
+
*/
|
|
313
|
+
hashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)
|
|
314
|
+
};
|
|
751
315
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
316
|
+
/**
|
|
317
|
+
* History.isEmptyObject(obj)
|
|
318
|
+
* Checks to see if the Object is Empty
|
|
319
|
+
* @param {Object} obj
|
|
320
|
+
* @return {boolean}
|
|
321
|
+
*/
|
|
322
|
+
History.isEmptyObject = function(obj) {
|
|
323
|
+
for (var name in obj) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
};
|
|
755
328
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
329
|
+
/**
|
|
330
|
+
* History.cloneObject(obj)
|
|
331
|
+
* Clones a object
|
|
332
|
+
* @param {Object} obj
|
|
333
|
+
* @return {Object}
|
|
334
|
+
*/
|
|
335
|
+
History.cloneObject = function(obj) {
|
|
336
|
+
var hash,newObj;
|
|
337
|
+
if (obj) {
|
|
338
|
+
hash = JSON.stringify(obj);
|
|
339
|
+
newObj = JSON.parse(hash);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
newObj = {};
|
|
343
|
+
}
|
|
344
|
+
return newObj;
|
|
345
|
+
};
|
|
765
346
|
|
|
766
|
-
|
|
767
|
-
|
|
347
|
+
// ----------------------------------------------------------------------
|
|
348
|
+
// URL Helpers
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* History.getRootUrl()
|
|
352
|
+
* Turns "http://mysite.com/dir/page.html?asd" into "http://mysite.com"
|
|
353
|
+
* @return {String} rootUrl
|
|
354
|
+
*/
|
|
355
|
+
History.getRootUrl = function() {
|
|
356
|
+
// Create
|
|
357
|
+
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host);
|
|
358
|
+
if (document.location.port || false) {
|
|
359
|
+
rootUrl += ':' + document.location.port;
|
|
360
|
+
}
|
|
361
|
+
rootUrl += '/';
|
|
362
|
+
|
|
363
|
+
// Return
|
|
364
|
+
return rootUrl;
|
|
365
|
+
};
|
|
768
366
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
367
|
+
/**
|
|
368
|
+
* History.getBaseHref()
|
|
369
|
+
* Fetches the `href` attribute of the `<base href="...">` element if it exists
|
|
370
|
+
* @return {String} baseHref
|
|
371
|
+
*/
|
|
372
|
+
History.getBaseHref = function() {
|
|
373
|
+
// Create
|
|
374
|
+
var
|
|
375
|
+
baseElements = document.getElementsByTagName('base'),
|
|
376
|
+
baseElement = null,
|
|
377
|
+
baseHref = '';
|
|
378
|
+
|
|
379
|
+
// Test for Base Element
|
|
380
|
+
if (baseElements.length === 1) {
|
|
381
|
+
// Prepare for Base Element
|
|
382
|
+
baseElement = baseElements[0];
|
|
383
|
+
baseHref = baseElement.href.replace(/[^\/]+$/, '');
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Adjust trailing slash
|
|
387
|
+
baseHref = baseHref.replace(/\/+$/, '');
|
|
388
|
+
if (baseHref) baseHref += '/';
|
|
389
|
+
|
|
390
|
+
// Return
|
|
391
|
+
return baseHref;
|
|
392
|
+
};
|
|
772
393
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
parts = /(.*)\&_suid=([0-9]+)$/.exec(url_or_hash);
|
|
786
|
-
url = parts ? (parts[1] || url_or_hash) : url_or_hash;
|
|
787
|
-
id = parts ? String(parts[2] || '') : '';
|
|
788
|
-
|
|
789
|
-
// Return
|
|
790
|
-
return id || false;
|
|
791
|
-
};
|
|
394
|
+
/**
|
|
395
|
+
* History.getBaseUrl()
|
|
396
|
+
* Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)
|
|
397
|
+
* @return {String} baseUrl
|
|
398
|
+
*/
|
|
399
|
+
History.getBaseUrl = function() {
|
|
400
|
+
// Create
|
|
401
|
+
var baseUrl = History.getBaseHref() || History.getBasePageUrl() || History.getRootUrl();
|
|
402
|
+
|
|
403
|
+
// Return
|
|
404
|
+
return baseUrl;
|
|
405
|
+
};
|
|
792
406
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
407
|
+
/**
|
|
408
|
+
* History.getPageUrl()
|
|
409
|
+
* Fetches the URL of the current page
|
|
410
|
+
* @return {String} pageUrl
|
|
411
|
+
*/
|
|
412
|
+
History.getPageUrl = function() {
|
|
413
|
+
// Fetch
|
|
414
|
+
var
|
|
415
|
+
State = History.getState(false, false),
|
|
416
|
+
stateUrl = (State || {}).url || document.location.href;
|
|
417
|
+
|
|
418
|
+
// Create
|
|
419
|
+
var pageUrl = stateUrl.replace(/\/+$/, '').replace(/[^\/]+$/, function(part, index, string) {
|
|
420
|
+
return (/\./).test(part) ? part : part + '/';
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// Return
|
|
424
|
+
return pageUrl;
|
|
425
|
+
};
|
|
802
426
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
427
|
+
/**
|
|
428
|
+
* History.getBasePageUrl()
|
|
429
|
+
* Fetches the Url of the directory of the current page
|
|
430
|
+
* @return {String} basePageUrl
|
|
431
|
+
*/
|
|
432
|
+
History.getBasePageUrl = function() {
|
|
433
|
+
// Create
|
|
434
|
+
var basePageUrl = document.location.href.replace(/[#\?].*/, '').replace(/[^\/]+$/,
|
|
435
|
+
function(part, index, string) {
|
|
436
|
+
return (/[^\/]$/).test(part) ? '' : part;
|
|
437
|
+
}).replace(/\/+$/, '') + '/';
|
|
438
|
+
|
|
439
|
+
// Return
|
|
440
|
+
return basePageUrl;
|
|
441
|
+
};
|
|
806
442
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
443
|
+
/**
|
|
444
|
+
* History.getFullUrl(url)
|
|
445
|
+
* Ensures that we have an absolute URL and not a relative URL
|
|
446
|
+
* @param {string} url
|
|
447
|
+
* @param {Boolean} allowBaseHref
|
|
448
|
+
* @return {string} fullUrl
|
|
449
|
+
*/
|
|
450
|
+
History.getFullUrl = function(url, allowBaseHref) {
|
|
451
|
+
// Prepare
|
|
452
|
+
var fullUrl = url, firstChar = url.substring(0, 1);
|
|
453
|
+
allowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;
|
|
454
|
+
|
|
455
|
+
// Check
|
|
456
|
+
if (/[a-z]+\:\/\//.test(url)) {
|
|
457
|
+
// Full URL
|
|
458
|
+
}
|
|
459
|
+
else if (firstChar === '/') {
|
|
460
|
+
// Root URL
|
|
461
|
+
fullUrl = History.getRootUrl() + url.replace(/^\/+/, '');
|
|
462
|
+
}
|
|
463
|
+
else if (firstChar === '#') {
|
|
464
|
+
// Anchor URL
|
|
465
|
+
fullUrl = History.getPageUrl().replace(/#.*/, '') + url;
|
|
466
|
+
}
|
|
467
|
+
else if (firstChar === '?') {
|
|
468
|
+
// Query URL
|
|
469
|
+
fullUrl = History.getPageUrl().replace(/[\?#].*/, '') + url;
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
// Relative URL
|
|
473
|
+
if (allowBaseHref) {
|
|
474
|
+
fullUrl = History.getBaseUrl() + url.replace(/^(\.\/)+/, '');
|
|
475
|
+
} else {
|
|
476
|
+
fullUrl = History.getBasePageUrl() + url.replace(/^(\.\/)+/, '');
|
|
477
|
+
}
|
|
478
|
+
// We have an if condition above as we do not want hashes
|
|
479
|
+
// which are relative to the baseHref in our URLs
|
|
480
|
+
// as if the baseHref changes, then all our bookmarks
|
|
481
|
+
// would now point to different locations
|
|
482
|
+
// whereas the basePageUrl will always stay the same
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Return
|
|
486
|
+
return fullUrl.replace(/\#$/, '');
|
|
487
|
+
};
|
|
823
488
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
489
|
+
/**
|
|
490
|
+
* History.getShortUrl(url)
|
|
491
|
+
* Ensures that we have a relative URL and not a absolute URL
|
|
492
|
+
* @param {string} url
|
|
493
|
+
* @return {string} url
|
|
494
|
+
*/
|
|
495
|
+
History.getShortUrl = function(url) {
|
|
496
|
+
// Prepare
|
|
497
|
+
var shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();
|
|
498
|
+
|
|
499
|
+
// Trim baseUrl
|
|
500
|
+
if (History.emulated.pushState) {
|
|
501
|
+
// We are in a if statement as when pushState is not emulated
|
|
502
|
+
// The actual url these short urls are relative to can change
|
|
503
|
+
// So within the same session, we the url may end up somewhere different
|
|
504
|
+
shortUrl = shortUrl.replace(baseUrl, '');
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Trim rootUrl
|
|
508
|
+
shortUrl = shortUrl.replace(rootUrl, '/');
|
|
509
|
+
|
|
510
|
+
// Ensure we can still detect it as a state
|
|
511
|
+
if (History.isTraditionalAnchor(shortUrl)) {
|
|
512
|
+
shortUrl = './' + shortUrl;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Clean It
|
|
516
|
+
shortUrl = shortUrl.replace(/^(\.\/)+/g, './').replace(/\#$/, '');
|
|
517
|
+
|
|
518
|
+
// Return
|
|
519
|
+
return shortUrl;
|
|
520
|
+
};
|
|
828
521
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
522
|
+
// ----------------------------------------------------------------------
|
|
523
|
+
// State Storage
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* History.store
|
|
527
|
+
* The store for all session specific data
|
|
528
|
+
*/
|
|
529
|
+
History.store = amplify ? (amplify.store('History.store') || {}) : {};
|
|
530
|
+
History.store.idToState = History.store.idToState || {};
|
|
531
|
+
History.store.urlToId = History.store.urlToId || {};
|
|
532
|
+
History.store.stateToId = History.store.stateToId || {};
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* History.idToState
|
|
536
|
+
* 1-1: State ID to State Object
|
|
537
|
+
*/
|
|
538
|
+
History.idToState = History.idToState || {};
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* History.stateToId
|
|
542
|
+
* 1-1: State String to State ID
|
|
543
|
+
*/
|
|
544
|
+
History.stateToId = History.stateToId || {};
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* History.urlToId
|
|
548
|
+
* 1-1: State URL to State ID
|
|
549
|
+
*/
|
|
550
|
+
History.urlToId = History.urlToId || {};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* History.storedStates
|
|
554
|
+
* Store the states in an array
|
|
555
|
+
*/
|
|
556
|
+
History.storedStates = History.storedStates || [];
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* History.savedStates
|
|
560
|
+
* Saved the states in an array
|
|
561
|
+
*/
|
|
562
|
+
History.savedStates = History.savedStates || [];
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* History.getState()
|
|
566
|
+
* Get an object containing the data, title and url of the current state
|
|
567
|
+
* @param {Boolean} friendly
|
|
568
|
+
* @param {Boolean} create
|
|
569
|
+
* @return {Object} State
|
|
570
|
+
*/
|
|
571
|
+
History.getState = function(friendly, create) {
|
|
572
|
+
// Prepare
|
|
573
|
+
if (typeof friendly === 'undefined') {
|
|
574
|
+
friendly = true;
|
|
575
|
+
}
|
|
576
|
+
if (typeof create === 'undefined') {
|
|
577
|
+
create = true;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Fetch
|
|
581
|
+
var State = History.getLastSavedState();
|
|
582
|
+
|
|
583
|
+
// Create
|
|
584
|
+
if (!State && create) {
|
|
585
|
+
State = History.createStateObject();
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// Adjust
|
|
589
|
+
if (friendly) {
|
|
590
|
+
State = History.cloneObject(State);
|
|
591
|
+
State.url = State.cleanUrl || State.url;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Return
|
|
595
|
+
return State;
|
|
596
|
+
};
|
|
834
597
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
598
|
+
/**
|
|
599
|
+
* History.getIdByState(State)
|
|
600
|
+
* Gets a ID for a State
|
|
601
|
+
* @param {State} newState
|
|
602
|
+
* @return {String} id
|
|
603
|
+
*/
|
|
604
|
+
History.getIdByState = function(newState) {
|
|
605
|
+
|
|
606
|
+
// Fetch ID
|
|
607
|
+
var id = History.extractId(newState.url);
|
|
608
|
+
if (!id) {
|
|
609
|
+
// Find ID via State String
|
|
610
|
+
var str = History.getStateString(newState);
|
|
611
|
+
if (typeof History.stateToId[str] !== 'undefined') {
|
|
612
|
+
id = History.stateToId[str];
|
|
613
|
+
}
|
|
614
|
+
else if (typeof History.store.stateToId[str] !== 'undefined') {
|
|
615
|
+
id = History.store.stateToId[str];
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
// Generate a new ID
|
|
619
|
+
while (true) {
|
|
620
|
+
id = String(Math.floor(Math.random() * 1000));
|
|
621
|
+
if (typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined') {
|
|
622
|
+
break;
|
|
839
623
|
}
|
|
624
|
+
}
|
|
840
625
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
626
|
+
// Apply the new State to the ID
|
|
627
|
+
History.stateToId[str] = id;
|
|
628
|
+
History.idToState[id] = newState;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
844
631
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
*/
|
|
849
|
-
History.getIdByUrl = function(url) {
|
|
850
|
-
// Fetch
|
|
851
|
-
var id = History.urlToId[url] || History.store.urlToId[url] || undefined;
|
|
632
|
+
// Return ID
|
|
633
|
+
return id;
|
|
634
|
+
};
|
|
852
635
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
636
|
+
/**
|
|
637
|
+
* History.normalizeState(State)
|
|
638
|
+
* Expands a State Object
|
|
639
|
+
* @param {object} State
|
|
640
|
+
* @return {object}
|
|
641
|
+
*/
|
|
642
|
+
History.normalizeState = function(oldState) {
|
|
643
|
+
// Prepare
|
|
644
|
+
if (!oldState || (typeof oldState !== 'object')) {
|
|
645
|
+
oldState = {};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// Check
|
|
649
|
+
if (typeof oldState.normalized !== 'undefined') {
|
|
650
|
+
return oldState;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Adjust
|
|
654
|
+
if (!oldState.data || (typeof oldState.data !== 'object')) {
|
|
655
|
+
oldState.data = {};
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// ----------------------------------------------------------------------
|
|
659
|
+
|
|
660
|
+
// Create
|
|
661
|
+
var newState = {};
|
|
662
|
+
newState.normalized = true;
|
|
663
|
+
newState.title = oldState.title || '';
|
|
664
|
+
newState.url = History.getFullUrl(History.unescapeString(oldState.url || document.location.href));
|
|
665
|
+
newState.hash = History.getShortUrl(newState.url);
|
|
666
|
+
newState.data = History.cloneObject(oldState.data);
|
|
667
|
+
|
|
668
|
+
// Fetch ID
|
|
669
|
+
newState.id = History.getIdByState(newState);
|
|
670
|
+
|
|
671
|
+
// ----------------------------------------------------------------------
|
|
672
|
+
|
|
673
|
+
// Clean the URL
|
|
674
|
+
newState.cleanUrl = newState.url.replace(/\??\&_suid.*/, '');
|
|
675
|
+
newState.url = newState.cleanUrl;
|
|
676
|
+
|
|
677
|
+
// Check to see if we have more than just a url
|
|
678
|
+
var dataNotEmpty = !History.isEmptyObject(newState.data);
|
|
679
|
+
|
|
680
|
+
// Apply
|
|
681
|
+
if (newState.title || dataNotEmpty) {
|
|
682
|
+
// Add ID to Hash
|
|
683
|
+
newState.hash = History.getShortUrl(newState.url).replace(/\??\&_suid.*/, '');
|
|
684
|
+
if (!/\?/.test(newState.hash)) {
|
|
685
|
+
newState.hash += '?';
|
|
686
|
+
}
|
|
687
|
+
newState.hash += '&_suid=' + newState.id;
|
|
688
|
+
}
|
|
856
689
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
* Get an object containing the data, title and url of the current state
|
|
860
|
-
* @return {Object} State
|
|
861
|
-
*/
|
|
862
|
-
History.getLastSavedState = function() {
|
|
863
|
-
return History.savedStates[History.savedStates.length - 1] || undefined;
|
|
864
|
-
};
|
|
690
|
+
// Create the Hashed URL
|
|
691
|
+
newState.hashedUrl = History.getFullUrl(newState.hash);
|
|
865
692
|
|
|
866
|
-
|
|
867
|
-
* History.getLastStoredState()
|
|
868
|
-
* Get an object containing the data, title and url of the current state
|
|
869
|
-
* @return {Object} State
|
|
870
|
-
*/
|
|
871
|
-
History.getLastStoredState = function() {
|
|
872
|
-
return History.storedStates[History.storedStates.length - 1] || undefined;
|
|
873
|
-
};
|
|
693
|
+
// ----------------------------------------------------------------------
|
|
874
694
|
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
* @return {Boolean} hasDuplicate
|
|
880
|
-
*/
|
|
881
|
-
History.hasUrlDuplicate = function(newState) {
|
|
882
|
-
// Prepare
|
|
883
|
-
var hasDuplicate = false;
|
|
695
|
+
// Update the URL if we have a duplicate
|
|
696
|
+
if ((History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState)) {
|
|
697
|
+
newState.url = newState.hashedUrl;
|
|
698
|
+
}
|
|
884
699
|
|
|
885
|
-
|
|
886
|
-
var oldState = History.extractState(newState.url);
|
|
700
|
+
// ----------------------------------------------------------------------
|
|
887
701
|
|
|
888
|
-
|
|
889
|
-
|
|
702
|
+
// Return
|
|
703
|
+
return newState;
|
|
704
|
+
};
|
|
890
705
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
706
|
+
/**
|
|
707
|
+
* History.createStateObject(data,title,url)
|
|
708
|
+
* Creates a object based on the data, title and url state params
|
|
709
|
+
* @param {object} data
|
|
710
|
+
* @param {string} title
|
|
711
|
+
* @param {string} url
|
|
712
|
+
* @return {object}
|
|
713
|
+
*/
|
|
714
|
+
History.createStateObject = function(data, title, url) {
|
|
715
|
+
// Hashify
|
|
716
|
+
var State = {
|
|
717
|
+
'data': data,
|
|
718
|
+
'title': title,
|
|
719
|
+
'url': url
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// Expand the State
|
|
723
|
+
State = History.normalizeState(State);
|
|
724
|
+
|
|
725
|
+
// Return object
|
|
726
|
+
return State;
|
|
727
|
+
};
|
|
894
728
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
History.urlToId[newState.url] = newState.id;
|
|
729
|
+
/**
|
|
730
|
+
* History.getStateById(id)
|
|
731
|
+
* Get a state by it's UID
|
|
732
|
+
* @param {String} id
|
|
733
|
+
*/
|
|
734
|
+
History.getStateById = function(id) {
|
|
735
|
+
// Prepare
|
|
736
|
+
id = String(id);
|
|
904
737
|
|
|
905
|
-
|
|
906
|
-
|
|
738
|
+
// Retrieve
|
|
739
|
+
var State = History.idToState[id] || History.store.idToState[id] || undefined;
|
|
907
740
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
741
|
+
// Return State
|
|
742
|
+
return State;
|
|
743
|
+
};
|
|
911
744
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
745
|
+
/**
|
|
746
|
+
* Get a State's String
|
|
747
|
+
* @param {State} passedState
|
|
748
|
+
*/
|
|
749
|
+
History.getStateString = function(passedState) {
|
|
750
|
+
// Prepare
|
|
751
|
+
var State = History.normalizeState(passedState);
|
|
752
|
+
|
|
753
|
+
// Clean
|
|
754
|
+
var cleanedState = {
|
|
755
|
+
data: State.data,
|
|
756
|
+
title: passedState.title,
|
|
757
|
+
url: passedState.url
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// Fetch
|
|
761
|
+
var str = JSON.stringify(cleanedState);
|
|
762
|
+
|
|
763
|
+
// Return
|
|
764
|
+
return str;
|
|
765
|
+
};
|
|
932
766
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
767
|
+
/**
|
|
768
|
+
* Get a State's ID
|
|
769
|
+
* @param {State} passedState
|
|
770
|
+
* @return {String} id
|
|
771
|
+
*/
|
|
772
|
+
History.getStateId = function(passedState) {
|
|
773
|
+
// Prepare
|
|
774
|
+
var State = History.normalizeState(passedState);
|
|
936
775
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
* Push a State
|
|
940
|
-
* @param {Object} newState
|
|
941
|
-
* @return {boolean} changed
|
|
942
|
-
*/
|
|
943
|
-
History.saveState = function(newState) {
|
|
944
|
-
// Check Hash
|
|
945
|
-
if (History.isLastSavedState(newState)) {
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
776
|
+
// Fetch
|
|
777
|
+
var id = State.id;
|
|
948
778
|
|
|
949
|
-
|
|
950
|
-
|
|
779
|
+
// Return
|
|
780
|
+
return id;
|
|
781
|
+
};
|
|
951
782
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
783
|
+
/**
|
|
784
|
+
* History.getHashByState(State)
|
|
785
|
+
* Creates a Hash for the State Object
|
|
786
|
+
* @param {State} passedState
|
|
787
|
+
* @return {String} hash
|
|
788
|
+
*/
|
|
789
|
+
History.getHashByState = function(passedState) {
|
|
790
|
+
// Prepare
|
|
791
|
+
var hash, State = History.normalizeState(passedState);
|
|
792
|
+
|
|
793
|
+
// Fetch
|
|
794
|
+
hash = State.hash;
|
|
795
|
+
|
|
796
|
+
// Return
|
|
797
|
+
return hash;
|
|
798
|
+
};
|
|
955
799
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
else {
|
|
976
|
-
// Get from the beginning
|
|
977
|
-
State = History.savedStates[index];
|
|
978
|
-
}
|
|
800
|
+
/**
|
|
801
|
+
* History.extractId(url_or_hash)
|
|
802
|
+
* Get a State ID by it's URL or Hash
|
|
803
|
+
* @param {string} url_or_hash
|
|
804
|
+
* @return {string} id
|
|
805
|
+
*/
|
|
806
|
+
History.extractId = function (url_or_hash) {
|
|
807
|
+
// Prepare
|
|
808
|
+
var id;
|
|
809
|
+
|
|
810
|
+
// Extract
|
|
811
|
+
var parts,url;
|
|
812
|
+
parts = /(.*)\&_suid=([0-9]+)$/.exec(url_or_hash);
|
|
813
|
+
url = parts ? (parts[1] || url_or_hash) : url_or_hash;
|
|
814
|
+
id = parts ? String(parts[2] || '') : '';
|
|
815
|
+
|
|
816
|
+
// Return
|
|
817
|
+
return id || false;
|
|
818
|
+
};
|
|
979
819
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
820
|
+
/**
|
|
821
|
+
* History.isTraditionalAnchor
|
|
822
|
+
* Checks to see if the url is a traditional anchor or not
|
|
823
|
+
* @param {String} url_or_hash
|
|
824
|
+
* @return {Boolean}
|
|
825
|
+
*/
|
|
826
|
+
History.isTraditionalAnchor = function(url_or_hash) {
|
|
827
|
+
// Check
|
|
828
|
+
var isTraditional = !(/[\/\?\.]/.test(url_or_hash));
|
|
829
|
+
|
|
830
|
+
// Return
|
|
831
|
+
return isTraditional;
|
|
832
|
+
};
|
|
983
833
|
|
|
984
|
-
|
|
985
|
-
|
|
834
|
+
/**
|
|
835
|
+
* History.extractState
|
|
836
|
+
* Get a State by it's URL or Hash
|
|
837
|
+
* @param {String} url_or_hash
|
|
838
|
+
* @return {State|null}
|
|
839
|
+
*/
|
|
840
|
+
History.extractState = function(url_or_hash, create) {
|
|
841
|
+
// Prepare
|
|
842
|
+
var State = null;
|
|
843
|
+
create = create || false;
|
|
844
|
+
|
|
845
|
+
// Fetch SUID
|
|
846
|
+
var id = History.extractId(url_or_hash);
|
|
847
|
+
if (id) {
|
|
848
|
+
State = History.getStateById(id);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// Fetch SUID returned no State
|
|
852
|
+
if (!State) {
|
|
853
|
+
// Fetch URL
|
|
854
|
+
var url = History.getFullUrl(url_or_hash);
|
|
855
|
+
|
|
856
|
+
// Check URL
|
|
857
|
+
id = History.getIdByUrl(url) || false;
|
|
858
|
+
if (id) {
|
|
859
|
+
State = History.getStateById(id);
|
|
860
|
+
}
|
|
986
861
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
History.getHash = function() {
|
|
993
|
-
var hash = History.unescapeHash(document.location.hash);
|
|
994
|
-
return hash;
|
|
995
|
-
};
|
|
862
|
+
// Create State
|
|
863
|
+
if (!State && create && !History.isTraditionalAnchor(url_or_hash)) {
|
|
864
|
+
State = History.createStateObject(null, null, url);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
996
867
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
* @param {String} str
|
|
1001
|
-
* @return {string}
|
|
1002
|
-
*/
|
|
1003
|
-
History.unescapeString = function(str) {
|
|
1004
|
-
// Prepare
|
|
1005
|
-
var result = str;
|
|
1006
|
-
|
|
1007
|
-
// Unescape hash
|
|
1008
|
-
var tmp;
|
|
1009
|
-
while (true) {
|
|
1010
|
-
tmp = window.unescape(result);
|
|
1011
|
-
if (tmp === result) {
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
result = tmp;
|
|
1015
|
-
}
|
|
868
|
+
// Return
|
|
869
|
+
return State;
|
|
870
|
+
};
|
|
1016
871
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
872
|
+
/**
|
|
873
|
+
* History.getIdByUrl()
|
|
874
|
+
* Get a State ID by a State URL
|
|
875
|
+
*/
|
|
876
|
+
History.getIdByUrl = function(url) {
|
|
877
|
+
// Fetch
|
|
878
|
+
var id = History.urlToId[url] || History.store.urlToId[url] || undefined;
|
|
1020
879
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
* @param {String} hash
|
|
1025
|
-
* @return {string}
|
|
1026
|
-
*/
|
|
1027
|
-
History.unescapeHash = function(hash) {
|
|
1028
|
-
// Prepare
|
|
1029
|
-
var result = History.normalizeHash(hash);
|
|
880
|
+
// Return
|
|
881
|
+
return id;
|
|
882
|
+
};
|
|
1030
883
|
|
|
1031
|
-
|
|
1032
|
-
|
|
884
|
+
/**
|
|
885
|
+
* History.getLastSavedState()
|
|
886
|
+
* Get an object containing the data, title and url of the current state
|
|
887
|
+
* @return {Object} State
|
|
888
|
+
*/
|
|
889
|
+
History.getLastSavedState = function() {
|
|
890
|
+
return History.savedStates[History.savedStates.length - 1] || undefined;
|
|
891
|
+
};
|
|
1033
892
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
893
|
+
/**
|
|
894
|
+
* History.getLastStoredState()
|
|
895
|
+
* Get an object containing the data, title and url of the current state
|
|
896
|
+
* @return {Object} State
|
|
897
|
+
*/
|
|
898
|
+
History.getLastStoredState = function() {
|
|
899
|
+
return History.storedStates[History.storedStates.length - 1] || undefined;
|
|
900
|
+
};
|
|
1037
901
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
902
|
+
/**
|
|
903
|
+
* History.hasUrlDuplicate
|
|
904
|
+
* Checks if a Url will have a url conflict
|
|
905
|
+
* @param {Object} newState
|
|
906
|
+
* @return {Boolean} hasDuplicate
|
|
907
|
+
*/
|
|
908
|
+
History.hasUrlDuplicate = function(newState) {
|
|
909
|
+
// Prepare
|
|
910
|
+
var hasDuplicate = false;
|
|
1045
911
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
};
|
|
912
|
+
// Fetch
|
|
913
|
+
var oldState = History.extractState(newState.url);
|
|
1049
914
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
* Sets the document hash
|
|
1053
|
-
* @param {string} hash
|
|
1054
|
-
* @return {History}
|
|
1055
|
-
*/
|
|
1056
|
-
History.setHash = function(hash, queue) {
|
|
1057
|
-
// Handle Queueing
|
|
1058
|
-
if (queue !== false && History.busy()) {
|
|
1059
|
-
// Wait + Push to Queue
|
|
1060
|
-
//History.debug('History.setHash: we must wait', arguments);
|
|
1061
|
-
History.pushQueue({
|
|
1062
|
-
scope: History,
|
|
1063
|
-
callback: History.setHash,
|
|
1064
|
-
args: arguments,
|
|
1065
|
-
queue: queue
|
|
1066
|
-
});
|
|
1067
|
-
return false;
|
|
1068
|
-
}
|
|
915
|
+
// Check
|
|
916
|
+
hasDuplicate = oldState && oldState.id !== newState.id;
|
|
1069
917
|
|
|
1070
|
-
|
|
1071
|
-
|
|
918
|
+
// Return
|
|
919
|
+
return hasDuplicate;
|
|
920
|
+
};
|
|
1072
921
|
|
|
1073
|
-
|
|
1074
|
-
|
|
922
|
+
/**
|
|
923
|
+
* History.storeState
|
|
924
|
+
* Store a State
|
|
925
|
+
* @param {Object} newState
|
|
926
|
+
* @return {Object} newState
|
|
927
|
+
*/
|
|
928
|
+
History.storeState = function(newState) {
|
|
929
|
+
// Store the State
|
|
930
|
+
History.urlToId[newState.url] = newState.id;
|
|
931
|
+
|
|
932
|
+
// Push the State
|
|
933
|
+
History.storedStates.push(History.cloneObject(newState));
|
|
934
|
+
|
|
935
|
+
// Return newState
|
|
936
|
+
return newState;
|
|
937
|
+
};
|
|
1075
938
|
|
|
1076
|
-
|
|
1077
|
-
|
|
939
|
+
/**
|
|
940
|
+
* History.isLastSavedState(newState)
|
|
941
|
+
* Tests to see if the state is the last state
|
|
942
|
+
* @param {Object} newState
|
|
943
|
+
* @return {boolean} isLast
|
|
944
|
+
*/
|
|
945
|
+
History.isLastSavedState = function(newState) {
|
|
946
|
+
// Prepare
|
|
947
|
+
var isLast = false;
|
|
948
|
+
|
|
949
|
+
// Check
|
|
950
|
+
if (History.savedStates.length) {
|
|
951
|
+
var
|
|
952
|
+
newId = newState.id,
|
|
953
|
+
oldState = History.getLastSavedState(),
|
|
954
|
+
oldId = oldState.id;
|
|
955
|
+
|
|
956
|
+
// Check
|
|
957
|
+
isLast = (newId === oldId);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// Return
|
|
961
|
+
return isLast;
|
|
962
|
+
};
|
|
1078
963
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
964
|
+
/**
|
|
965
|
+
* History.saveState
|
|
966
|
+
* Push a State
|
|
967
|
+
* @param {Object} newState
|
|
968
|
+
* @return {boolean} changed
|
|
969
|
+
*/
|
|
970
|
+
History.saveState = function(newState) {
|
|
971
|
+
// Check Hash
|
|
972
|
+
if (History.isLastSavedState(newState)) {
|
|
973
|
+
return false;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// Push the State
|
|
977
|
+
History.savedStates.push(History.cloneObject(newState));
|
|
978
|
+
|
|
979
|
+
// Return true
|
|
980
|
+
return true;
|
|
981
|
+
};
|
|
1084
982
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
983
|
+
/**
|
|
984
|
+
* History.getStateByIndex()
|
|
985
|
+
* Gets a state by the index
|
|
986
|
+
* @param {integer} index
|
|
987
|
+
* @return {Object}
|
|
988
|
+
*/
|
|
989
|
+
History.getStateByIndex = function(index) {
|
|
990
|
+
// Prepare
|
|
991
|
+
var State = null;
|
|
992
|
+
|
|
993
|
+
// Handle
|
|
994
|
+
if (typeof index === 'undefined') {
|
|
995
|
+
// Get the last inserted
|
|
996
|
+
State = History.savedStates[History.savedStates.length - 1];
|
|
997
|
+
}
|
|
998
|
+
else if (index < 0) {
|
|
999
|
+
// Get from the end
|
|
1000
|
+
State = History.savedStates[History.savedStates.length + index];
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
// Get from the beginning
|
|
1004
|
+
State = History.savedStates[index];
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Return State
|
|
1008
|
+
return State;
|
|
1009
|
+
};
|
|
1090
1010
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1011
|
+
// ----------------------------------------------------------------------
|
|
1012
|
+
// Hash Helpers
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* History.getHash()
|
|
1016
|
+
* Gets the current document hash
|
|
1017
|
+
* @return {string}
|
|
1018
|
+
*/
|
|
1019
|
+
History.getHash = function() {
|
|
1020
|
+
var hash = History.unescapeHash(document.location.hash);
|
|
1021
|
+
return hash;
|
|
1022
|
+
};
|
|
1094
1023
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1024
|
+
/**
|
|
1025
|
+
* History.unescapeString()
|
|
1026
|
+
* Unescape a string
|
|
1027
|
+
* @param {String} str
|
|
1028
|
+
* @return {string}
|
|
1029
|
+
*/
|
|
1030
|
+
History.unescapeString = function(str) {
|
|
1031
|
+
// Prepare
|
|
1032
|
+
var result = str;
|
|
1033
|
+
|
|
1034
|
+
// Unescape hash
|
|
1035
|
+
var tmp;
|
|
1036
|
+
while (true) {
|
|
1037
|
+
tmp = window.unescape(result);
|
|
1038
|
+
if (tmp === result) {
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
result = tmp;
|
|
1042
|
+
}
|
|
1097
1043
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
else {
|
|
1102
|
-
// Normal hash apply
|
|
1103
|
-
document.location.hash = adjustedHash;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1044
|
+
// Return result
|
|
1045
|
+
return result;
|
|
1046
|
+
};
|
|
1106
1047
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1048
|
+
/**
|
|
1049
|
+
* History.unescapeHash()
|
|
1050
|
+
* normalize and Unescape a Hash
|
|
1051
|
+
* @param {String} hash
|
|
1052
|
+
* @return {string}
|
|
1053
|
+
*/
|
|
1054
|
+
History.unescapeHash = function(hash) {
|
|
1055
|
+
// Prepare
|
|
1056
|
+
var result = History.normalizeHash(hash);
|
|
1057
|
+
|
|
1058
|
+
// Unescape hash
|
|
1059
|
+
result = History.unescapeString(result);
|
|
1060
|
+
|
|
1061
|
+
// Return result
|
|
1062
|
+
return result;
|
|
1063
|
+
};
|
|
1110
1064
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
// Escape hash
|
|
1120
|
-
result = window.escape(result);
|
|
1121
|
-
|
|
1122
|
-
// IE6 Escape Bug
|
|
1123
|
-
if (!History.bugs.hashEscape) {
|
|
1124
|
-
// Restore common parts
|
|
1125
|
-
result = result
|
|
1126
|
-
.replace(/\%21/g, '!')
|
|
1127
|
-
.replace(/\%26/g, '&')
|
|
1128
|
-
.replace(/\%3D/g, '=')
|
|
1129
|
-
.replace(/\%3F/g, '?');
|
|
1130
|
-
}
|
|
1065
|
+
/**
|
|
1066
|
+
* History.normalizeHash()
|
|
1067
|
+
* normalize a hash across browsers
|
|
1068
|
+
* @return {string}
|
|
1069
|
+
*/
|
|
1070
|
+
History.normalizeHash = function(hash) {
|
|
1071
|
+
var result = hash.replace(/[^#]*#/, '').replace(/#.*/, '');
|
|
1131
1072
|
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1073
|
+
// Return result
|
|
1074
|
+
return result;
|
|
1075
|
+
};
|
|
1135
1076
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1077
|
+
/**
|
|
1078
|
+
* History.setHash(hash)
|
|
1079
|
+
* Sets the document hash
|
|
1080
|
+
* @param {string} hash
|
|
1081
|
+
* @return {History}
|
|
1082
|
+
*/
|
|
1083
|
+
History.setHash = function(hash, queue) {
|
|
1084
|
+
// Handle Queueing
|
|
1085
|
+
if (queue !== false && History.busy()) {
|
|
1086
|
+
// Wait + Push to Queue
|
|
1087
|
+
//History.debug('History.setHash: we must wait', arguments);
|
|
1088
|
+
History.pushQueue({
|
|
1089
|
+
scope: History,
|
|
1090
|
+
callback: History.setHash,
|
|
1091
|
+
args: arguments,
|
|
1092
|
+
queue: queue
|
|
1093
|
+
});
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// Log
|
|
1098
|
+
//History.debug('History.setHash: called',hash);
|
|
1099
|
+
|
|
1100
|
+
// Prepare
|
|
1101
|
+
var adjustedHash = History.escapeHash(hash);
|
|
1102
|
+
|
|
1103
|
+
// Make Busy + Continue
|
|
1104
|
+
History.busy(true);
|
|
1105
|
+
|
|
1106
|
+
// Check if hash is a state
|
|
1107
|
+
var State = History.extractState(hash, true);
|
|
1108
|
+
if (State && !History.emulated.pushState) {
|
|
1109
|
+
// Hash is a state so skip the setHash
|
|
1110
|
+
//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);
|
|
1111
|
+
|
|
1112
|
+
// PushState
|
|
1113
|
+
History.pushState(State.data, State.title, State.url, false);
|
|
1114
|
+
}
|
|
1115
|
+
else if (document.location.hash !== adjustedHash) {
|
|
1116
|
+
// Hash is a proper hash, so apply it
|
|
1117
|
+
|
|
1118
|
+
// Handle browser bugs
|
|
1119
|
+
if (History.bugs.setHash) {
|
|
1120
|
+
// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249
|
|
1121
|
+
|
|
1122
|
+
// Fetch the base page
|
|
1123
|
+
var pageUrl = History.getPageUrl();
|
|
1124
|
+
|
|
1125
|
+
// Safari hash apply
|
|
1126
|
+
History.pushState(null, null, pageUrl + '#' + adjustedHash, false);
|
|
1127
|
+
}
|
|
1128
|
+
else {
|
|
1129
|
+
// Normal hash apply
|
|
1130
|
+
document.location.hash = adjustedHash;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1147
1133
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1134
|
+
// Chain
|
|
1135
|
+
return History;
|
|
1136
|
+
};
|
|
1150
1137
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1138
|
+
/**
|
|
1139
|
+
* History.escape()
|
|
1140
|
+
* normalize and Escape a Hash
|
|
1141
|
+
* @return {string}
|
|
1142
|
+
*/
|
|
1143
|
+
History.escapeHash = function(hash) {
|
|
1144
|
+
var result = History.normalizeHash(hash);
|
|
1145
|
+
|
|
1146
|
+
// Escape hash
|
|
1147
|
+
result = window.escape(result);
|
|
1148
|
+
|
|
1149
|
+
// IE6 Escape Bug
|
|
1150
|
+
if (!History.bugs.hashEscape) {
|
|
1151
|
+
// Restore common parts
|
|
1152
|
+
result = result
|
|
1153
|
+
.replace(/\%21/g, '!')
|
|
1154
|
+
.replace(/\%26/g, '&')
|
|
1155
|
+
.replace(/\%3D/g, '=')
|
|
1156
|
+
.replace(/\%3F/g, '?');
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// Return result
|
|
1160
|
+
return result;
|
|
1161
|
+
};
|
|
1154
1162
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1163
|
+
/**
|
|
1164
|
+
* History.getHashByUrl(url)
|
|
1165
|
+
* Extracts the Hash from a URL
|
|
1166
|
+
* @param {string} url
|
|
1167
|
+
* @return {string} url
|
|
1168
|
+
*/
|
|
1169
|
+
History.getHashByUrl = function(url) {
|
|
1170
|
+
// Extract the hash
|
|
1171
|
+
var hash = String(url)
|
|
1172
|
+
.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')
|
|
1173
|
+
;
|
|
1174
|
+
|
|
1175
|
+
// Unescape hash
|
|
1176
|
+
hash = History.unescapeHash(hash);
|
|
1177
|
+
|
|
1178
|
+
// Return hash
|
|
1179
|
+
return hash;
|
|
1180
|
+
};
|
|
1172
1181
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1182
|
+
/**
|
|
1183
|
+
* History.setTitle(title)
|
|
1184
|
+
* Applies the title to the document
|
|
1185
|
+
* @param {State} newState
|
|
1186
|
+
* @return {Boolean}
|
|
1187
|
+
*/
|
|
1188
|
+
History.setTitle = function(newState) {
|
|
1189
|
+
// Prepare
|
|
1190
|
+
var title = newState.title;
|
|
1191
|
+
|
|
1192
|
+
// Initial
|
|
1193
|
+
if (!title) {
|
|
1194
|
+
var firstState = History.getStateByIndex(0);
|
|
1195
|
+
if (firstState && firstState.url === newState.url) {
|
|
1196
|
+
title = firstState.title || History.options.initialTitle;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// Apply
|
|
1201
|
+
try {
|
|
1202
|
+
document.getElementsByTagName('title')[0].innerHTML = title.replace('<', '<').replace('>', '>').replace(' & ', ' & ');
|
|
1203
|
+
}
|
|
1204
|
+
catch (Exception) {
|
|
1205
|
+
}
|
|
1206
|
+
document.title = title;
|
|
1207
|
+
|
|
1208
|
+
// Chain
|
|
1209
|
+
return History;
|
|
1210
|
+
};
|
|
1180
1211
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1212
|
+
// ----------------------------------------------------------------------
|
|
1213
|
+
// Queueing
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* History.queues
|
|
1217
|
+
* The list of queues to use
|
|
1218
|
+
* First In, First Out
|
|
1219
|
+
*/
|
|
1220
|
+
History.queues = [];
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* History.busy(value)
|
|
1224
|
+
* @param {boolean} value [optional]
|
|
1225
|
+
* @return {boolean} busy
|
|
1226
|
+
*/
|
|
1227
|
+
History.busy = function(value) {
|
|
1228
|
+
// Apply
|
|
1229
|
+
if (typeof value !== 'undefined') {
|
|
1230
|
+
//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);
|
|
1231
|
+
History.busy.flag = value;
|
|
1232
|
+
}
|
|
1233
|
+
// Default
|
|
1234
|
+
else if (typeof History.busy.flag === 'undefined') {
|
|
1235
|
+
History.busy.flag = false;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// Queue
|
|
1239
|
+
if (!History.busy.flag) {
|
|
1240
|
+
// Execute the next item in the queue
|
|
1241
|
+
clearTimeout(History.busy.timeout);
|
|
1242
|
+
var fireNext = function() {
|
|
1243
|
+
if (History.busy.flag) return;
|
|
1244
|
+
for (var i = History.queues.length - 1; i >= 0; --i) {
|
|
1245
|
+
var queue = History.queues[i];
|
|
1246
|
+
if (queue.length === 0) continue;
|
|
1247
|
+
var item = queue.shift();
|
|
1248
|
+
History.fireQueueItem(item);
|
|
1249
|
+
History.busy.timeout = setTimeout(fireNext, History.options.busyDelay);
|
|
1250
|
+
}
|
|
1183
1251
|
};
|
|
1252
|
+
History.busy.timeout = setTimeout(fireNext, History.options.busyDelay);
|
|
1253
|
+
}
|
|
1184
1254
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1255
|
+
// Return
|
|
1256
|
+
return History.busy.flag;
|
|
1257
|
+
};
|
|
1187
1258
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1259
|
+
/**
|
|
1260
|
+
* History.fireQueueItem(item)
|
|
1261
|
+
* Fire a Queue Item
|
|
1262
|
+
* @param {Object} item
|
|
1263
|
+
* @return {Mixed} result
|
|
1264
|
+
*/
|
|
1265
|
+
History.fireQueueItem = function(item) {
|
|
1266
|
+
return item.callback.apply(item.scope || History, item.args || []);
|
|
1267
|
+
};
|
|
1194
1268
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);
|
|
1204
|
-
History.busy.flag = value;
|
|
1205
|
-
}
|
|
1206
|
-
// Default
|
|
1207
|
-
else if (typeof History.busy.flag === 'undefined') {
|
|
1208
|
-
History.busy.flag = false;
|
|
1209
|
-
}
|
|
1269
|
+
/**
|
|
1270
|
+
* History.pushQueue(callback,args)
|
|
1271
|
+
* Add an item to the queue
|
|
1272
|
+
* @param {Object} item [scope,callback,args,queue]
|
|
1273
|
+
*/
|
|
1274
|
+
History.pushQueue = function(item) {
|
|
1275
|
+
// Prepare the queue
|
|
1276
|
+
History.queues[item.queue || 0] = History.queues[item.queue || 0] || [];
|
|
1210
1277
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
// Execute the next item in the queue
|
|
1214
|
-
clearTimeout(History.busy.timeout);
|
|
1215
|
-
var fireNext = function() {
|
|
1216
|
-
if (History.busy.flag) return;
|
|
1217
|
-
for (var i = History.queues.length - 1; i >= 0; --i) {
|
|
1218
|
-
var queue = History.queues[i];
|
|
1219
|
-
if (queue.length === 0) continue;
|
|
1220
|
-
var item = queue.shift();
|
|
1221
|
-
History.fireQueueItem(item);
|
|
1222
|
-
History.busy.timeout = setTimeout(fireNext, History.options.busyDelay);
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
History.busy.timeout = setTimeout(fireNext, History.options.busyDelay);
|
|
1226
|
-
}
|
|
1278
|
+
// Add to the queue
|
|
1279
|
+
History.queues[item.queue || 0].push(item);
|
|
1227
1280
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1281
|
+
// Chain
|
|
1282
|
+
return History;
|
|
1283
|
+
};
|
|
1231
1284
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1285
|
+
/**
|
|
1286
|
+
* History.queue (item,queue), (func,queue), (func), (item)
|
|
1287
|
+
* Either firs the item now if not busy, or adds it to the queue
|
|
1288
|
+
*/
|
|
1289
|
+
History.queue = function(item, queue) {
|
|
1290
|
+
// Prepare
|
|
1291
|
+
if (typeof item === 'function') {
|
|
1292
|
+
item = {
|
|
1293
|
+
callback: item
|
|
1240
1294
|
};
|
|
1295
|
+
}
|
|
1296
|
+
if (typeof queue !== 'undefined') {
|
|
1297
|
+
item.queue = queue;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// Handle
|
|
1301
|
+
if (History.busy()) {
|
|
1302
|
+
History.pushQueue(item);
|
|
1303
|
+
} else {
|
|
1304
|
+
History.fireQueueItem(item);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// Chain
|
|
1308
|
+
return History;
|
|
1309
|
+
};
|
|
1241
1310
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1311
|
+
/**
|
|
1312
|
+
* History.clearQueue()
|
|
1313
|
+
* Clears the Queue
|
|
1314
|
+
*/
|
|
1315
|
+
History.clearQueue = function() {
|
|
1316
|
+
History.busy.flag = false;
|
|
1317
|
+
History.queues = [];
|
|
1318
|
+
return History;
|
|
1319
|
+
};
|
|
1250
1320
|
|
|
1251
|
-
// Add to the queue
|
|
1252
|
-
History.queues[item.queue || 0].push(item);
|
|
1253
1321
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
};
|
|
1322
|
+
// ----------------------------------------------------------------------
|
|
1323
|
+
// IE Bug Fix
|
|
1257
1324
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
// Prepare
|
|
1264
|
-
if (typeof item === 'function') {
|
|
1265
|
-
item = {
|
|
1266
|
-
callback: item
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
if (typeof queue !== 'undefined') {
|
|
1270
|
-
item.queue = queue;
|
|
1271
|
-
}
|
|
1325
|
+
/**
|
|
1326
|
+
* History.stateChanged
|
|
1327
|
+
* States whether or not the state has changed since the last double check was initialised
|
|
1328
|
+
*/
|
|
1329
|
+
History.stateChanged = false;
|
|
1272
1330
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// Chain
|
|
1281
|
-
return History;
|
|
1282
|
-
};
|
|
1283
|
-
|
|
1284
|
-
/**
|
|
1285
|
-
* History.clearQueue()
|
|
1286
|
-
* Clears the Queue
|
|
1287
|
-
*/
|
|
1288
|
-
History.clearQueue = function() {
|
|
1289
|
-
History.busy.flag = false;
|
|
1290
|
-
History.queues = [];
|
|
1291
|
-
return History;
|
|
1292
|
-
};
|
|
1331
|
+
/**
|
|
1332
|
+
* History.doubleChecker
|
|
1333
|
+
* Contains the timeout used for the double checks
|
|
1334
|
+
*/
|
|
1335
|
+
History.doubleChecker = false;
|
|
1293
1336
|
|
|
1337
|
+
/**
|
|
1338
|
+
* History.doubleCheckComplete()
|
|
1339
|
+
* Complete a double check
|
|
1340
|
+
* @return {History}
|
|
1341
|
+
*/
|
|
1342
|
+
History.doubleCheckComplete = function() {
|
|
1343
|
+
// Update
|
|
1344
|
+
History.stateChanged = true;
|
|
1294
1345
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1346
|
+
// Clear
|
|
1347
|
+
History.doubleCheckClear();
|
|
1297
1348
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
*/
|
|
1302
|
-
History.stateChanged = false;
|
|
1349
|
+
// Chain
|
|
1350
|
+
return History;
|
|
1351
|
+
};
|
|
1303
1352
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1353
|
+
/**
|
|
1354
|
+
* History.doubleCheckClear()
|
|
1355
|
+
* Clear a double check
|
|
1356
|
+
* @return {History}
|
|
1357
|
+
*/
|
|
1358
|
+
History.doubleCheckClear = function() {
|
|
1359
|
+
// Clear
|
|
1360
|
+
if (History.doubleChecker) {
|
|
1361
|
+
clearTimeout(History.doubleChecker);
|
|
1308
1362
|
History.doubleChecker = false;
|
|
1363
|
+
}
|
|
1309
1364
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
* @return {History}
|
|
1314
|
-
*/
|
|
1315
|
-
History.doubleCheckComplete = function() {
|
|
1316
|
-
// Update
|
|
1317
|
-
History.stateChanged = true;
|
|
1318
|
-
|
|
1319
|
-
// Clear
|
|
1320
|
-
History.doubleCheckClear();
|
|
1321
|
-
|
|
1322
|
-
// Chain
|
|
1323
|
-
return History;
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
/**
|
|
1327
|
-
* History.doubleCheckClear()
|
|
1328
|
-
* Clear a double check
|
|
1329
|
-
* @return {History}
|
|
1330
|
-
*/
|
|
1331
|
-
History.doubleCheckClear = function() {
|
|
1332
|
-
// Clear
|
|
1333
|
-
if (History.doubleChecker) {
|
|
1334
|
-
clearTimeout(History.doubleChecker);
|
|
1335
|
-
History.doubleChecker = false;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
// Chain
|
|
1339
|
-
return History;
|
|
1340
|
-
};
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
* History.doubleCheck()
|
|
1344
|
-
* Create a double check
|
|
1345
|
-
* @return {History}
|
|
1346
|
-
*/
|
|
1347
|
-
History.doubleCheck = function(tryAgain) {
|
|
1348
|
-
// Reset
|
|
1349
|
-
History.stateChanged = false;
|
|
1350
|
-
History.doubleCheckClear();
|
|
1351
|
-
|
|
1352
|
-
// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)
|
|
1353
|
-
// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940
|
|
1354
|
-
if (History.bugs.ieDoubleCheck) {
|
|
1355
|
-
// Apply Check
|
|
1356
|
-
History.doubleChecker = setTimeout(
|
|
1357
|
-
function() {
|
|
1358
|
-
History.doubleCheckClear();
|
|
1359
|
-
if (!History.stateChanged) {
|
|
1360
|
-
//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);
|
|
1361
|
-
// Re-Attempt
|
|
1362
|
-
tryAgain();
|
|
1363
|
-
}
|
|
1364
|
-
return true;
|
|
1365
|
-
},
|
|
1366
|
-
History.options.doubleCheckInterval
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
// Chain
|
|
1371
|
-
return History;
|
|
1372
|
-
};
|
|
1373
|
-
|
|
1374
|
-
// ----------------------------------------------------------------------
|
|
1375
|
-
// Safari Bug Fix
|
|
1376
|
-
|
|
1377
|
-
/**
|
|
1378
|
-
* History.safariStatePoll()
|
|
1379
|
-
* Poll the current state
|
|
1380
|
-
* @return {History}
|
|
1381
|
-
*/
|
|
1382
|
-
History.safariStatePoll = function() {
|
|
1383
|
-
// Poll the URL
|
|
1384
|
-
|
|
1385
|
-
// Get the Last State which has the new URL
|
|
1386
|
-
var
|
|
1387
|
-
urlState = History.extractState(document.location.href),
|
|
1388
|
-
newState;
|
|
1365
|
+
// Chain
|
|
1366
|
+
return History;
|
|
1367
|
+
};
|
|
1389
1368
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* History.doubleCheck()
|
|
1371
|
+
* Create a double check
|
|
1372
|
+
* @return {History}
|
|
1373
|
+
*/
|
|
1374
|
+
History.doubleCheck = function(tryAgain) {
|
|
1375
|
+
// Reset
|
|
1376
|
+
History.stateChanged = false;
|
|
1377
|
+
History.doubleCheckClear();
|
|
1378
|
+
|
|
1379
|
+
// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)
|
|
1380
|
+
// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940
|
|
1381
|
+
if (History.bugs.ieDoubleCheck) {
|
|
1382
|
+
// Apply Check
|
|
1383
|
+
History.doubleChecker = setTimeout(
|
|
1384
|
+
function() {
|
|
1385
|
+
History.doubleCheckClear();
|
|
1386
|
+
if (!History.stateChanged) {
|
|
1387
|
+
//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);
|
|
1388
|
+
// Re-Attempt
|
|
1389
|
+
tryAgain();
|
|
1390
|
+
}
|
|
1391
|
+
return true;
|
|
1392
|
+
},
|
|
1393
|
+
History.options.doubleCheckInterval
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
// Chain
|
|
1398
|
+
return History;
|
|
1399
|
+
};
|
|
1397
1400
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1401
|
+
// ----------------------------------------------------------------------
|
|
1402
|
+
// Safari Bug Fix
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* History.safariStatePoll()
|
|
1406
|
+
* Poll the current state
|
|
1407
|
+
* @return {History}
|
|
1408
|
+
*/
|
|
1409
|
+
History.safariStatePoll = function() {
|
|
1410
|
+
// Poll the URL
|
|
1411
|
+
|
|
1412
|
+
// Get the Last State which has the new URL
|
|
1413
|
+
var
|
|
1414
|
+
urlState = History.extractState(document.location.href),
|
|
1415
|
+
newState;
|
|
1416
|
+
|
|
1417
|
+
// Check for a difference
|
|
1418
|
+
if (!History.isLastSavedState(urlState)) {
|
|
1419
|
+
newState = urlState;
|
|
1420
|
+
}
|
|
1421
|
+
else {
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// Check if we have a state with that url
|
|
1426
|
+
// If not create it
|
|
1427
|
+
if (!newState) {
|
|
1428
|
+
//History.debug('History.safariStatePoll: new');
|
|
1429
|
+
newState = History.createStateObject();
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
// Apply the New State
|
|
1433
|
+
//History.debug('History.safariStatePoll: trigger');
|
|
1434
|
+
History.Adapter.trigger(window, 'popstate');
|
|
1435
|
+
|
|
1436
|
+
// Chain
|
|
1437
|
+
return History;
|
|
1438
|
+
};
|
|
1404
1439
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1440
|
+
// ----------------------------------------------------------------------
|
|
1441
|
+
// State Aliases
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* History.back(queue)
|
|
1445
|
+
* Send the browser history back one item
|
|
1446
|
+
* @param {Integer} queue [optional]
|
|
1447
|
+
*/
|
|
1448
|
+
History.back = function(queue) {
|
|
1449
|
+
//History.debug('History.back: called', arguments);
|
|
1450
|
+
|
|
1451
|
+
// Handle Queueing
|
|
1452
|
+
if (queue !== false && History.busy()) {
|
|
1453
|
+
// Wait + Push to Queue
|
|
1454
|
+
//History.debug('History.back: we must wait', arguments);
|
|
1455
|
+
History.pushQueue({
|
|
1456
|
+
scope: History,
|
|
1457
|
+
callback: History.back,
|
|
1458
|
+
args: arguments,
|
|
1459
|
+
queue: queue
|
|
1460
|
+
});
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// Make Busy + Continue
|
|
1465
|
+
History.busy(true);
|
|
1466
|
+
|
|
1467
|
+
// Fix certain browser bugs that prevent the state from changing
|
|
1468
|
+
History.doubleCheck(function() {
|
|
1469
|
+
History.back(false);
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
// Go back
|
|
1473
|
+
history.go(-1);
|
|
1474
|
+
|
|
1475
|
+
// End back closure
|
|
1476
|
+
return true;
|
|
1477
|
+
};
|
|
1408
1478
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1479
|
+
/**
|
|
1480
|
+
* History.forward(queue)
|
|
1481
|
+
* Send the browser history forward one item
|
|
1482
|
+
* @param {Integer} queue [optional]
|
|
1483
|
+
*/
|
|
1484
|
+
History.forward = function(queue) {
|
|
1485
|
+
//History.debug('History.forward: called', arguments);
|
|
1486
|
+
|
|
1487
|
+
// Handle Queueing
|
|
1488
|
+
if (queue !== false && History.busy()) {
|
|
1489
|
+
// Wait + Push to Queue
|
|
1490
|
+
//History.debug('History.forward: we must wait', arguments);
|
|
1491
|
+
History.pushQueue({
|
|
1492
|
+
scope: History,
|
|
1493
|
+
callback: History.forward,
|
|
1494
|
+
args: arguments,
|
|
1495
|
+
queue: queue
|
|
1496
|
+
});
|
|
1497
|
+
return false;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// Make Busy + Continue
|
|
1501
|
+
History.busy(true);
|
|
1502
|
+
|
|
1503
|
+
// Fix certain browser bugs that prevent the state from changing
|
|
1504
|
+
History.doubleCheck(function() {
|
|
1505
|
+
History.forward(false);
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
// Go forward
|
|
1509
|
+
history.go(1);
|
|
1510
|
+
|
|
1511
|
+
// End forward closure
|
|
1512
|
+
return true;
|
|
1513
|
+
};
|
|
1412
1514
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1515
|
+
/**
|
|
1516
|
+
* History.go(index,queue)
|
|
1517
|
+
* Send the browser history back or forward index times
|
|
1518
|
+
* @param {Integer} queue [optional]
|
|
1519
|
+
*/
|
|
1520
|
+
History.go = function(index, queue) {
|
|
1521
|
+
//History.debug('History.go: called', arguments);
|
|
1522
|
+
|
|
1523
|
+
// Prepare
|
|
1524
|
+
var i;
|
|
1525
|
+
|
|
1526
|
+
// Handle
|
|
1527
|
+
if (index > 0) {
|
|
1528
|
+
// Forward
|
|
1529
|
+
for (i = 1; i <= index; ++i) {
|
|
1530
|
+
History.forward(queue);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
else if (index < 0) {
|
|
1534
|
+
// Backward
|
|
1535
|
+
for (i = -1; i >= index; --i) {
|
|
1536
|
+
History.back(queue);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
throw new Error('History.go: History.go requires a positive or negative integer passed.');
|
|
1541
|
+
}
|
|
1415
1542
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
* @param {Integer} queue [optional]
|
|
1420
|
-
*/
|
|
1421
|
-
History.back = function(queue) {
|
|
1422
|
-
//History.debug('History.back: called', arguments);
|
|
1423
|
-
|
|
1424
|
-
// Handle Queueing
|
|
1425
|
-
if (queue !== false && History.busy()) {
|
|
1426
|
-
// Wait + Push to Queue
|
|
1427
|
-
//History.debug('History.back: we must wait', arguments);
|
|
1428
|
-
History.pushQueue({
|
|
1429
|
-
scope: History,
|
|
1430
|
-
callback: History.back,
|
|
1431
|
-
args: arguments,
|
|
1432
|
-
queue: queue
|
|
1433
|
-
});
|
|
1434
|
-
return false;
|
|
1435
|
-
}
|
|
1543
|
+
// Chain
|
|
1544
|
+
return History;
|
|
1545
|
+
};
|
|
1436
1546
|
|
|
1437
|
-
// Make Busy + Continue
|
|
1438
|
-
History.busy(true);
|
|
1439
1547
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
History.back(false);
|
|
1443
|
-
});
|
|
1548
|
+
// ----------------------------------------------------------------------
|
|
1549
|
+
// Initialise
|
|
1444
1550
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1551
|
+
/**
|
|
1552
|
+
* Create the initial State
|
|
1553
|
+
*/
|
|
1554
|
+
History.saveState(History.storeState(History.extractState(document.location.href, true)));
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Bind for Saving Store
|
|
1558
|
+
*/
|
|
1559
|
+
if (amplify) {
|
|
1560
|
+
History.onUnload = function() {
|
|
1561
|
+
// Prepare
|
|
1562
|
+
var
|
|
1563
|
+
currentStore = amplify.store('History.store') || {},
|
|
1564
|
+
item;
|
|
1565
|
+
|
|
1566
|
+
// Ensure
|
|
1567
|
+
currentStore.idToState = currentStore.idToState || {};
|
|
1568
|
+
currentStore.urlToId = currentStore.urlToId || {};
|
|
1569
|
+
currentStore.stateToId = currentStore.stateToId || {};
|
|
1570
|
+
|
|
1571
|
+
// Sync
|
|
1572
|
+
for (item in History.idToState) {
|
|
1573
|
+
if (!History.idToState.hasOwnProperty(item)) {
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
currentStore.idToState[item] = History.idToState[item];
|
|
1577
|
+
}
|
|
1578
|
+
for (item in History.urlToId) {
|
|
1579
|
+
if (!History.urlToId.hasOwnProperty(item)) {
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
currentStore.urlToId[item] = History.urlToId[item];
|
|
1583
|
+
}
|
|
1584
|
+
for (item in History.stateToId) {
|
|
1585
|
+
if (!History.stateToId.hasOwnProperty(item)) {
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
currentStore.stateToId[item] = History.stateToId[item];
|
|
1589
|
+
}
|
|
1447
1590
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1591
|
+
// Update
|
|
1592
|
+
History.store = currentStore;
|
|
1593
|
+
|
|
1594
|
+
// Store
|
|
1595
|
+
amplify.store('History.store', currentStore);
|
|
1596
|
+
};
|
|
1597
|
+
// For Internet Explorer
|
|
1598
|
+
History.intervalList.push(setInterval(History.onUnload, History.options.storeInterval));
|
|
1599
|
+
// For Other Browsers
|
|
1600
|
+
History.Adapter.bind(window, 'beforeunload', History.onUnload);
|
|
1601
|
+
History.Adapter.bind(window, 'unload', History.onUnload);
|
|
1602
|
+
// Both are enabled for consistency
|
|
1603
|
+
}
|
|
1451
1604
|
|
|
1452
|
-
/**
|
|
1453
|
-
* History.forward(queue)
|
|
1454
|
-
* Send the browser history forward one item
|
|
1455
|
-
* @param {Integer} queue [optional]
|
|
1456
|
-
*/
|
|
1457
|
-
History.forward = function(queue) {
|
|
1458
|
-
//History.debug('History.forward: called', arguments);
|
|
1459
|
-
|
|
1460
|
-
// Handle Queueing
|
|
1461
|
-
if (queue !== false && History.busy()) {
|
|
1462
|
-
// Wait + Push to Queue
|
|
1463
|
-
//History.debug('History.forward: we must wait', arguments);
|
|
1464
|
-
History.pushQueue({
|
|
1465
|
-
scope: History,
|
|
1466
|
-
callback: History.forward,
|
|
1467
|
-
args: arguments,
|
|
1468
|
-
queue: queue
|
|
1469
|
-
});
|
|
1470
|
-
return false;
|
|
1471
|
-
}
|
|
1472
1605
|
|
|
1473
|
-
|
|
1474
|
-
|
|
1606
|
+
// ----------------------------------------------------------------------
|
|
1607
|
+
// HTML5 State Support
|
|
1475
1608
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1609
|
+
if (History.emulated.pushState) {
|
|
1610
|
+
/*
|
|
1611
|
+
* Provide Skeleton for HTML4 Browsers
|
|
1612
|
+
*/
|
|
1480
1613
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1614
|
+
// Prepare
|
|
1615
|
+
var emptyFunction = function() {
|
|
1616
|
+
};
|
|
1617
|
+
History.pushState = History.pushState || emptyFunction;
|
|
1618
|
+
History.replaceState = History.replaceState || emptyFunction;
|
|
1619
|
+
}
|
|
1620
|
+
else {
|
|
1621
|
+
/*
|
|
1622
|
+
* Use native HTML5 History API Implementation
|
|
1623
|
+
*/
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* History.onPopState(event,extra)
|
|
1627
|
+
* Refresh the Current State
|
|
1628
|
+
*/
|
|
1629
|
+
History.onPopState = function(event) {
|
|
1630
|
+
// Reset the double check
|
|
1631
|
+
History.doubleCheckComplete();
|
|
1632
|
+
|
|
1633
|
+
// Check for a Hash, and handle apporiatly
|
|
1634
|
+
var currentHash = History.getHash();
|
|
1635
|
+
if (currentHash) {
|
|
1636
|
+
// Expand Hash
|
|
1637
|
+
var currentState = History.extractState(currentHash || document.location.href, true);
|
|
1638
|
+
if (currentState) {
|
|
1639
|
+
// We were able to parse it, it must be a State!
|
|
1640
|
+
// Let's forward to replaceState
|
|
1641
|
+
//History.debug('History.onPopState: state anchor', currentHash, currentState);
|
|
1642
|
+
History.replaceState(currentState.data, currentState.title, currentState.url, false);
|
|
1643
|
+
}
|
|
1644
|
+
else {
|
|
1645
|
+
// Traditional Anchor
|
|
1646
|
+
//History.debug('History.onPopState: traditional anchor', currentHash);
|
|
1647
|
+
History.Adapter.trigger(window, 'anchorchange');
|
|
1648
|
+
History.busy(false);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// We don't care for hashes
|
|
1652
|
+
History.expectedStateId = false;
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1483
1655
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1656
|
+
// Prepare
|
|
1657
|
+
var newState = false;
|
|
1658
|
+
|
|
1659
|
+
// Prepare
|
|
1660
|
+
event = event || {};
|
|
1661
|
+
if (typeof event.state === 'undefined') {
|
|
1662
|
+
// jQuery
|
|
1663
|
+
if (typeof event.originalEvent !== 'undefined' && typeof event.originalEvent.state !== 'undefined') {
|
|
1664
|
+
event.state = event.originalEvent.state || false;
|
|
1665
|
+
}
|
|
1666
|
+
// MooTools
|
|
1667
|
+
else if (typeof event.event !== 'undefined' && typeof event.event.state !== 'undefined') {
|
|
1668
|
+
event.state = event.event.state || false;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1487
1671
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
* Send the browser history back or forward index times
|
|
1491
|
-
* @param {Integer} queue [optional]
|
|
1492
|
-
*/
|
|
1493
|
-
History.go = function(index, queue) {
|
|
1494
|
-
//History.debug('History.go: called', arguments);
|
|
1672
|
+
// Ensure
|
|
1673
|
+
event.state = (event.state || false);
|
|
1495
1674
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1675
|
+
// Fetch State
|
|
1676
|
+
if (event.state) {
|
|
1677
|
+
// Vanilla: Back/forward button was used
|
|
1678
|
+
newState = History.getStateById(event.state);
|
|
1679
|
+
}
|
|
1680
|
+
else if (History.expectedStateId) {
|
|
1681
|
+
// Vanilla: A new state was pushed, and popstate was called manually
|
|
1682
|
+
newState = History.getStateById(History.expectedStateId);
|
|
1683
|
+
}
|
|
1684
|
+
else {
|
|
1685
|
+
// Initial State
|
|
1686
|
+
newState = History.extractState(document.location.href);
|
|
1687
|
+
}
|
|
1498
1688
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
else if (index < 0) {
|
|
1507
|
-
// Backward
|
|
1508
|
-
for (i = -1; i >= index; --i) {
|
|
1509
|
-
History.back(queue);
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
else {
|
|
1513
|
-
throw new Error('History.go: History.go requires a positive or negative integer passed.');
|
|
1514
|
-
}
|
|
1689
|
+
// The State did not exist in our store
|
|
1690
|
+
if (!newState) {
|
|
1691
|
+
// Regenerate the State
|
|
1692
|
+
newState = History.createStateObject(null, null, document.location.href);
|
|
1693
|
+
}
|
|
1515
1694
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
};
|
|
1695
|
+
// Clean
|
|
1696
|
+
History.expectedStateId = false;
|
|
1519
1697
|
|
|
1698
|
+
// Check if we are the same state
|
|
1699
|
+
if (History.isLastSavedState(newState)) {
|
|
1700
|
+
// There has been no change (just the page's hash has finally propagated)
|
|
1701
|
+
//History.debug('History.onPopState: no change', newState, History.savedStates);
|
|
1702
|
+
History.busy(false);
|
|
1703
|
+
return false;
|
|
1704
|
+
}
|
|
1520
1705
|
|
|
1521
|
-
//
|
|
1522
|
-
|
|
1706
|
+
// Store the State
|
|
1707
|
+
History.storeState(newState);
|
|
1708
|
+
History.saveState(newState);
|
|
1523
1709
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
*/
|
|
1527
|
-
History.saveState(History.storeState(History.extractState(document.location.href, true)));
|
|
1710
|
+
// Force update of the title
|
|
1711
|
+
History.setTitle(newState);
|
|
1528
1712
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (amplify) {
|
|
1533
|
-
History.onUnload = function() {
|
|
1534
|
-
// Prepare
|
|
1535
|
-
var
|
|
1536
|
-
currentStore = amplify.store('History.store') || {},
|
|
1537
|
-
item;
|
|
1538
|
-
|
|
1539
|
-
// Ensure
|
|
1540
|
-
currentStore.idToState = currentStore.idToState || {};
|
|
1541
|
-
currentStore.urlToId = currentStore.urlToId || {};
|
|
1542
|
-
currentStore.stateToId = currentStore.stateToId || {};
|
|
1543
|
-
|
|
1544
|
-
// Sync
|
|
1545
|
-
for (item in History.idToState) {
|
|
1546
|
-
if (!History.idToState.hasOwnProperty(item)) {
|
|
1547
|
-
continue;
|
|
1548
|
-
}
|
|
1549
|
-
currentStore.idToState[item] = History.idToState[item];
|
|
1550
|
-
}
|
|
1551
|
-
for (item in History.urlToId) {
|
|
1552
|
-
if (!History.urlToId.hasOwnProperty(item)) {
|
|
1553
|
-
continue;
|
|
1554
|
-
}
|
|
1555
|
-
currentStore.urlToId[item] = History.urlToId[item];
|
|
1556
|
-
}
|
|
1557
|
-
for (item in History.stateToId) {
|
|
1558
|
-
if (!History.stateToId.hasOwnProperty(item)) {
|
|
1559
|
-
continue;
|
|
1560
|
-
}
|
|
1561
|
-
currentStore.stateToId[item] = History.stateToId[item];
|
|
1562
|
-
}
|
|
1713
|
+
// Fire Our Event
|
|
1714
|
+
History.Adapter.trigger(window, 'statechange');
|
|
1715
|
+
History.busy(false);
|
|
1563
1716
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1717
|
+
// Return true
|
|
1718
|
+
return true;
|
|
1719
|
+
};
|
|
1720
|
+
History.Adapter.bind(window, 'popstate', History.onPopState);
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* History.pushState(data,title,url)
|
|
1724
|
+
* Add a new State to the history object, become it, and trigger onpopstate
|
|
1725
|
+
* We have to trigger for HTML4 compatibility
|
|
1726
|
+
* @param {object} data
|
|
1727
|
+
* @param {string} title
|
|
1728
|
+
* @param {string} url
|
|
1729
|
+
* @return {true}
|
|
1730
|
+
*/
|
|
1731
|
+
History.pushState = function(data, title, url, queue) {
|
|
1732
|
+
//History.debug('History.pushState: called', arguments);
|
|
1733
|
+
|
|
1734
|
+
// Check the State
|
|
1735
|
+
if (History.getHashByUrl(url) && History.emulated.pushState) {
|
|
1736
|
+
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
|
1576
1737
|
}
|
|
1577
1738
|
|
|
1739
|
+
// Handle Queueing
|
|
1740
|
+
if (queue !== false && History.busy()) {
|
|
1741
|
+
// Wait + Push to Queue
|
|
1742
|
+
//History.debug('History.pushState: we must wait', arguments);
|
|
1743
|
+
History.pushQueue({
|
|
1744
|
+
scope: History,
|
|
1745
|
+
callback: History.pushState,
|
|
1746
|
+
args: arguments,
|
|
1747
|
+
queue: queue
|
|
1748
|
+
});
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1578
1751
|
|
|
1579
|
-
//
|
|
1580
|
-
|
|
1752
|
+
// Make Busy + Continue
|
|
1753
|
+
History.busy(true);
|
|
1581
1754
|
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
* Provide Skeleton for HTML4 Browsers
|
|
1585
|
-
*/
|
|
1755
|
+
// Create the newState
|
|
1756
|
+
var newState = History.createStateObject(data, title, url);
|
|
1586
1757
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
History.replaceState = History.replaceState || emptyFunction;
|
|
1758
|
+
// Check it
|
|
1759
|
+
if (History.isLastSavedState(newState)) {
|
|
1760
|
+
// Won't be a change
|
|
1761
|
+
History.busy(false);
|
|
1592
1762
|
}
|
|
1593
1763
|
else {
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
/**
|
|
1599
|
-
* History.onPopState(event,extra)
|
|
1600
|
-
* Refresh the Current State
|
|
1601
|
-
*/
|
|
1602
|
-
History.onPopState = function(event) {
|
|
1603
|
-
// Reset the double check
|
|
1604
|
-
History.doubleCheckComplete();
|
|
1605
|
-
|
|
1606
|
-
// Check for a Hash, and handle apporiatly
|
|
1607
|
-
var currentHash = History.getHash();
|
|
1608
|
-
if (currentHash) {
|
|
1609
|
-
// Expand Hash
|
|
1610
|
-
var currentState = History.extractState(currentHash || document.location.href, true);
|
|
1611
|
-
if (currentState) {
|
|
1612
|
-
// We were able to parse it, it must be a State!
|
|
1613
|
-
// Let's forward to replaceState
|
|
1614
|
-
//History.debug('History.onPopState: state anchor', currentHash, currentState);
|
|
1615
|
-
History.replaceState(currentState.data, currentState.title, currentState.url, false);
|
|
1616
|
-
}
|
|
1617
|
-
else {
|
|
1618
|
-
// Traditional Anchor
|
|
1619
|
-
//History.debug('History.onPopState: traditional anchor', currentHash);
|
|
1620
|
-
History.Adapter.trigger(window, 'anchorchange');
|
|
1621
|
-
History.busy(false);
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
// We don't care for hashes
|
|
1625
|
-
History.expectedStateId = false;
|
|
1626
|
-
return false;
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
// Prepare
|
|
1630
|
-
var newState = false;
|
|
1631
|
-
|
|
1632
|
-
// Prepare
|
|
1633
|
-
event = event || {};
|
|
1634
|
-
if (typeof event.state === 'undefined') {
|
|
1635
|
-
// jQuery
|
|
1636
|
-
if (typeof event.originalEvent !== 'undefined' && typeof event.originalEvent.state !== 'undefined') {
|
|
1637
|
-
event.state = event.originalEvent.state || false;
|
|
1638
|
-
}
|
|
1639
|
-
// MooTools
|
|
1640
|
-
else if (typeof event.event !== 'undefined' && typeof event.event.state !== 'undefined') {
|
|
1641
|
-
event.state = event.event.state || false;
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
// Ensure
|
|
1646
|
-
event.state = (event.state || false);
|
|
1647
|
-
|
|
1648
|
-
// Fetch State
|
|
1649
|
-
if (event.state) {
|
|
1650
|
-
// Vanilla: Back/forward button was used
|
|
1651
|
-
newState = History.getStateById(event.state);
|
|
1652
|
-
}
|
|
1653
|
-
else if (History.expectedStateId) {
|
|
1654
|
-
// Vanilla: A new state was pushed, and popstate was called manually
|
|
1655
|
-
newState = History.getStateById(History.expectedStateId);
|
|
1656
|
-
}
|
|
1657
|
-
else {
|
|
1658
|
-
// Initial State
|
|
1659
|
-
newState = History.extractState(document.location.href);
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
// The State did not exist in our store
|
|
1663
|
-
if (!newState) {
|
|
1664
|
-
// Regenerate the State
|
|
1665
|
-
newState = History.createStateObject(null, null, document.location.href);
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// Clean
|
|
1669
|
-
History.expectedStateId = false;
|
|
1670
|
-
|
|
1671
|
-
// Check if we are the same state
|
|
1672
|
-
if (History.isLastSavedState(newState)) {
|
|
1673
|
-
// There has been no change (just the page's hash has finally propagated)
|
|
1674
|
-
//History.debug('History.onPopState: no change', newState, History.savedStates);
|
|
1675
|
-
History.busy(false);
|
|
1676
|
-
return false;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
// Store the State
|
|
1680
|
-
History.storeState(newState);
|
|
1681
|
-
History.saveState(newState);
|
|
1682
|
-
|
|
1683
|
-
// Force update of the title
|
|
1684
|
-
History.setTitle(newState);
|
|
1685
|
-
|
|
1686
|
-
// Fire Our Event
|
|
1687
|
-
History.Adapter.trigger(window, 'statechange');
|
|
1688
|
-
History.busy(false);
|
|
1689
|
-
|
|
1690
|
-
// Return true
|
|
1691
|
-
return true;
|
|
1692
|
-
};
|
|
1693
|
-
History.Adapter.bind(window, 'popstate', History.onPopState);
|
|
1694
|
-
|
|
1695
|
-
/**
|
|
1696
|
-
* History.pushState(data,title,url)
|
|
1697
|
-
* Add a new State to the history object, become it, and trigger onpopstate
|
|
1698
|
-
* We have to trigger for HTML4 compatibility
|
|
1699
|
-
* @param {object} data
|
|
1700
|
-
* @param {string} title
|
|
1701
|
-
* @param {string} url
|
|
1702
|
-
* @return {true}
|
|
1703
|
-
*/
|
|
1704
|
-
History.pushState = function(data, title, url, queue) {
|
|
1705
|
-
//History.debug('History.pushState: called', arguments);
|
|
1706
|
-
|
|
1707
|
-
// Check the State
|
|
1708
|
-
if (History.getHashByUrl(url) && History.emulated.pushState) {
|
|
1709
|
-
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
|
1710
|
-
}
|
|
1764
|
+
// Store the newState
|
|
1765
|
+
History.storeState(newState);
|
|
1766
|
+
History.expectedStateId = newState.id;
|
|
1711
1767
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
// Wait + Push to Queue
|
|
1715
|
-
//History.debug('History.pushState: we must wait', arguments);
|
|
1716
|
-
History.pushQueue({
|
|
1717
|
-
scope: History,
|
|
1718
|
-
callback: History.pushState,
|
|
1719
|
-
args: arguments,
|
|
1720
|
-
queue: queue
|
|
1721
|
-
});
|
|
1722
|
-
return false;
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
// Make Busy + Continue
|
|
1726
|
-
History.busy(true);
|
|
1768
|
+
// Push the newState
|
|
1769
|
+
history.pushState(newState.id, newState.title, newState.url);
|
|
1727
1770
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
// Check it
|
|
1732
|
-
if (History.isLastSavedState(newState)) {
|
|
1733
|
-
// Won't be a change
|
|
1734
|
-
History.busy(false);
|
|
1735
|
-
}
|
|
1736
|
-
else {
|
|
1737
|
-
// Store the newState
|
|
1738
|
-
History.storeState(newState);
|
|
1739
|
-
History.expectedStateId = newState.id;
|
|
1771
|
+
// Fire HTML5 Event
|
|
1772
|
+
History.Adapter.trigger(window, 'popstate');
|
|
1773
|
+
}
|
|
1740
1774
|
|
|
1741
|
-
|
|
1742
|
-
|
|
1775
|
+
// End pushState closure
|
|
1776
|
+
return true;
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* History.replaceState(data,title,url)
|
|
1781
|
+
* Replace the State and trigger onpopstate
|
|
1782
|
+
* We have to trigger for HTML4 compatibility
|
|
1783
|
+
* @param {object} data
|
|
1784
|
+
* @param {string} title
|
|
1785
|
+
* @param {string} url
|
|
1786
|
+
* @return {true}
|
|
1787
|
+
*/
|
|
1788
|
+
History.replaceState = function(data, title, url, queue) {
|
|
1789
|
+
//History.debug('History.replaceState: called', arguments);
|
|
1790
|
+
|
|
1791
|
+
// Check the State
|
|
1792
|
+
if (History.getHashByUrl(url) && History.emulated.pushState) {
|
|
1793
|
+
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
|
1794
|
+
}
|
|
1743
1795
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1796
|
+
// Handle Queueing
|
|
1797
|
+
if (queue !== false && History.busy()) {
|
|
1798
|
+
// Wait + Push to Queue
|
|
1799
|
+
//History.debug('History.replaceState: we must wait', arguments);
|
|
1800
|
+
History.pushQueue({
|
|
1801
|
+
scope: History,
|
|
1802
|
+
callback: History.replaceState,
|
|
1803
|
+
args: arguments,
|
|
1804
|
+
queue: queue
|
|
1805
|
+
});
|
|
1806
|
+
return false;
|
|
1807
|
+
}
|
|
1747
1808
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
};
|
|
1751
|
-
|
|
1752
|
-
/**
|
|
1753
|
-
* History.replaceState(data,title,url)
|
|
1754
|
-
* Replace the State and trigger onpopstate
|
|
1755
|
-
* We have to trigger for HTML4 compatibility
|
|
1756
|
-
* @param {object} data
|
|
1757
|
-
* @param {string} title
|
|
1758
|
-
* @param {string} url
|
|
1759
|
-
* @return {true}
|
|
1760
|
-
*/
|
|
1761
|
-
History.replaceState = function(data, title, url, queue) {
|
|
1762
|
-
//History.debug('History.replaceState: called', arguments);
|
|
1763
|
-
|
|
1764
|
-
// Check the State
|
|
1765
|
-
if (History.getHashByUrl(url) && History.emulated.pushState) {
|
|
1766
|
-
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
|
1767
|
-
}
|
|
1809
|
+
// Make Busy + Continue
|
|
1810
|
+
History.busy(true);
|
|
1768
1811
|
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
// Wait + Push to Queue
|
|
1772
|
-
//History.debug('History.replaceState: we must wait', arguments);
|
|
1773
|
-
History.pushQueue({
|
|
1774
|
-
scope: History,
|
|
1775
|
-
callback: History.replaceState,
|
|
1776
|
-
args: arguments,
|
|
1777
|
-
queue: queue
|
|
1778
|
-
});
|
|
1779
|
-
return false;
|
|
1780
|
-
}
|
|
1812
|
+
// Create the newState
|
|
1813
|
+
var newState = History.createStateObject(data, title, url);
|
|
1781
1814
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1815
|
+
// Check it
|
|
1816
|
+
if (History.isLastSavedState(newState)) {
|
|
1817
|
+
// Won't be a change
|
|
1818
|
+
History.busy(false);
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1821
|
+
// Store the newState
|
|
1822
|
+
History.storeState(newState);
|
|
1823
|
+
History.expectedStateId = newState.id;
|
|
1784
1824
|
|
|
1785
|
-
|
|
1786
|
-
|
|
1825
|
+
// Push the newState
|
|
1826
|
+
history.replaceState(newState.id, newState.title, newState.url);
|
|
1787
1827
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
History.busy(false);
|
|
1792
|
-
}
|
|
1793
|
-
else {
|
|
1794
|
-
// Store the newState
|
|
1795
|
-
History.storeState(newState);
|
|
1796
|
-
History.expectedStateId = newState.id;
|
|
1828
|
+
// Fire HTML5 Event
|
|
1829
|
+
History.Adapter.trigger(window, 'popstate');
|
|
1830
|
+
}
|
|
1797
1831
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1832
|
+
// End replaceState closure
|
|
1833
|
+
return true;
|
|
1834
|
+
};
|
|
1800
1835
|
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1836
|
+
// Be aware, the following is only for native pushState implementations
|
|
1837
|
+
// If you are wanting to include something for all browsers
|
|
1838
|
+
// Then include it above this if block
|
|
1804
1839
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1840
|
+
/**
|
|
1841
|
+
* Setup Safari Fix
|
|
1842
|
+
*/
|
|
1843
|
+
if (History.bugs.safariPoll) {
|
|
1844
|
+
History.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));
|
|
1845
|
+
}
|
|
1808
1846
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1847
|
+
/**
|
|
1848
|
+
* Ensure Cross Browser Compatibility
|
|
1849
|
+
*/
|
|
1850
|
+
if (navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName || '') === 'Mozilla') {
|
|
1851
|
+
/**
|
|
1852
|
+
* Fix Safari HashChange Issue
|
|
1853
|
+
*/
|
|
1812
1854
|
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
setInterval(History.safariStatePoll, History.options.safariPollInterval);
|
|
1818
|
-
}
|
|
1855
|
+
// Setup Alias
|
|
1856
|
+
History.Adapter.bind(window, 'hashchange', function() {
|
|
1857
|
+
History.Adapter.trigger(window, 'popstate');
|
|
1858
|
+
});
|
|
1819
1859
|
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
// Setup Alias
|
|
1829
|
-
History.Adapter.bind(window, 'hashchange', function() {
|
|
1830
|
-
History.Adapter.trigger(window, 'popstate');
|
|
1831
|
-
});
|
|
1832
|
-
|
|
1833
|
-
// Initialise Alias
|
|
1834
|
-
if (History.getHash()) {
|
|
1835
|
-
History.Adapter.onDomLoad(function() {
|
|
1836
|
-
History.Adapter.trigger(window, 'hashchange');
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1860
|
+
// Initialise Alias
|
|
1861
|
+
if (History.getHash()) {
|
|
1862
|
+
History.Adapter.onDomLoad(function() {
|
|
1863
|
+
History.Adapter.trigger(window, 'hashchange');
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1840
1867
|
|
|
1841
|
-
|
|
1868
|
+
} // !History.emulated.pushState
|
|
1842
1869
|
|
|
1843
|
-
|
|
1870
|
+
}; // History.initCore
|
|
1844
1871
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1872
|
+
// Try and Initialise History
|
|
1873
|
+
History.init();
|
|
1847
1874
|
|
|
1848
1875
|
})(window);
|