JAVASCRIPT   33

Undo.js

Guest on 23rd August 2021 10:22:34 AM

  1. var fluid_1_5=fluid_1_5||{};!function($,fluid){"use strict";fluid.registerNamespace("fluid.undo"),fluid.undo.STATE_INITIAL="state_initial",fluid.undo.STATE_CHANGED="state_changed",fluid.undo.STATE_REVERTED="state_reverted",fluid.undo.defaultRenderer=function(that,targetContainer){var str=that.options.strings,markup="<span class='flc-undo'><a href='#' class='flc-undo-undoControl'>"+str.undo+"</a><a href='#' class='flc-undo-redoControl'>"+str.redo+"</a></span>",markupNode=$(markup).attr({role:"region","aria-live":"polite","aria-relevant":"all"});return targetContainer.append(markupNode),markupNode},fluid.undo.refreshView=function(that){that.state===fluid.undo.STATE_INITIAL?(that.locate("undoContainer").hide(),that.locate("redoContainer").hide()):that.state===fluid.undo.STATE_CHANGED?(that.locate("undoContainer").show(),that.locate("redoContainer").hide()):that.state===fluid.undo.STATE_REVERTED&&(that.locate("undoContainer").hide(),that.locate("redoContainer").show())},fluid.undo.undoControlClick=function(that){return that.state!==fluid.undo.STATE_REVERTED&&(fluid.model.copyModel(that.extremalModel,that.component.model),that.component.updateModel(that.initialModel,that),that.state=fluid.undo.STATE_REVERTED,fluid.undo.refreshView(that),that.locate("redoControl").focus()),!1},fluid.undo.redoControlClick=function(that){return that.state!==fluid.undo.STATE_CHANGED&&(that.component.updateModel(that.extremalModel,that),that.state=fluid.undo.STATE_CHANGED,fluid.undo.refreshView(that),that.locate("undoControl").focus()),!1},fluid.undo.modelChanged=function(that,newModel,oldModel,source){source!==that&&(that.state=fluid.undo.STATE_CHANGED,fluid.model.copyModel(that.initialModel,oldModel),fluid.undo.refreshView(that))},fluid.undo.finalInit=function(that){fluid.tabindex(that.locate("undoControl"),0),fluid.tabindex(that.locate("redoControl"),0),fluid.model.copyModel(that.initialModel,that.component.model),fluid.model.copyModel(that.extremalModel,that.component.model)},fluid.defaults("fluid.undo",{gradeNames:["fluid.eventedComponent","autoInit"],members:{state:fluid.undo.STATE_INITIAL,initialModel:{},extremalModel:{},component:"{fluid.undoable}",container:{expander:{func:"{that}.options.renderer",args:["{that}","{that}.component.container"]}},dom:{expander:{funcName:"fluid.initDomBinder",args:["{that}","{that}.options.selectors"]}}},invokers:{undoControlClick:{funcName:"fluid.undo.undoControlClick",args:"{that}"},redoControlClick:{funcName:"fluid.undo.redoControlClick",args:"{that}"}},listeners:{onCreate:[{funcName:"fluid.undo.refreshView",args:"{that}"},{"this":"{that}.dom.undoControl",method:"click",args:"{that}.undoControlClick"},{"this":"{that}.dom.redoControl",method:"click",args:"{that}.redoControlClick"}],"{fluid.undoable}.events.modelChanged":{funcName:"fluid.undo.modelChanged",args:["{that}","{arguments}.0","{arguments}.1","{arguments}.2"]}},selectors:{undoContainer:".flc-undo-undoControl",undoControl:".flc-undo-undoControl",redoContainer:".flc-undo-redoControl",redoControl:".flc-undo-redoControl"},strings:{undo:"undo edit",redo:"redo edit"},renderer:fluid.undo.defaultRenderer}),fluid.defaults("fluid.undoable",{gradeNames:["fluid.modelComponent"],invokers:{updateModel:{}},events:{modelChanged:null}}),fluid.defaults("fluid.undoDecorator",{gradeNames:["fluid.undo","autoInit"]})}(jQuery,fluid_1_5);

Raw Paste


Login or Register to edit or fork this paste. It's free.