X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/0fd55a38c4873d5916a3553d7510b9308f4eee6d..03c5ba6e50339d7bc470eb6d7f051483eff1e96b:/platforma/static/js/wiki/base.js?ds=inline diff --git a/platforma/static/js/wiki/base.js b/platforma/static/js/wiki/base.js new file mode 100644 index 00000000..8c626d98 --- /dev/null +++ b/platforma/static/js/wiki/base.js @@ -0,0 +1,58 @@ +(function($) +{ + $.wiki = {}; + + $.wiki.Perspective = function(document, callback) { + // initialization + }; + + $.wiki.Perspective.toString = function() { + return this.perspective_id; + } + + $.wiki.Perspective.prototype.onEnter = function () { + // called when perspective in initialized + document.location.hash = '#' + this.perspective_id; + console.log(document.location.hash); + }; + + $.wiki.Perspective.prototype.onExit = function () { + // called when user switches to another perspective + }; + + $.wiki.Perspective.prototype.freezeState = function () { + // free UI state (don't store data here) + }; + + $.wiki.Perspective.prototype.unfreezeState = function (frozenState) { + // restore UI state + }; + + $.wiki.renderStub = function($container, $stub, data) + { + var $elem = $stub.clone(); + $elem.removeClass('row-stub'); + $container.append($elem); + + $('*[data-stub-value]', $elem).each(function() { + var $this = $(this); + var field = $this.attr('data-stub-value'); + var value = data[field]; + + if(value === null || value === undefined) return; + + if(!$this.attr('data-stub-target')) { + $this.text(value); + } + else { + $this.attr($this.attr('data-stub-target'), value); + $this.removeAttr('data-stub-target'); + $this.removeAttr('data-stub-value'); + } + }); + + $elem.show(); + return $elem; + }; + +})(jQuery);